From 9d9d411289aea57ab26077de99b6bca80f513a3e Mon Sep 17 00:00:00 2001 From: jiangjinyuan <937804380@qq.com> Date: Fri, 4 Jun 2021 14:02:02 +0800 Subject: [PATCH 1/2] temp hack --- .gitignore | 4 + Gruntfile.js | 2 +- README.md | 1 + build/blocktrail-sdk-full.js | 27471 +++++++----- build/blocktrail-sdk-full.min.js | 2 +- build/blocktrail-sdk-with-backup-generator.js | 27475 +++++++----- ...locktrail-sdk-with-backup-generator.min.js | 2 +- build/blocktrail-sdk.js | 36059 +++++++++------- build/blocktrail-sdk.min.js | 2 +- build/jsPDF.min.js | 2 - lib/wallet_sweeper.js | 187 +- package.json | 2 +- 12 files changed, 56480 insertions(+), 34729 deletions(-) delete mode 100644 build/jsPDF.min.js diff --git a/.gitignore b/.gitignore index 18be7a9..33f981f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ bundle.js .dev*.js test/run-tests.html tmp/ + +package-lock.json + +.idea/ \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index b32c9f1..a5901d7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -118,7 +118,7 @@ module.exports = function (grunt) { exec: { // does 'sources concat' as tasks, because we don't want it minified by the asmcrypto grunt - asmcryptobuild: 'cd ./vendor/asmcrypto.js; npm install; grunt sources concat --with pbkdf2-hmac-sha512' + asmcryptobuild: 'cd ./vendor/asmcrypto.js; npm install; grunt sources concat' }, /* diff --git a/README.md b/README.md index 6fd0d1b..072d847 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The Blocktrail SDK is tested against; - 5.11 - 6.3.0 - 7.1.0 + - 8.10.0 (advise) - Browser: - Google Chrome 48 / latest - Firefox 49 / latest diff --git a/build/blocktrail-sdk-full.js b/build/blocktrail-sdk-full.js index c61f6f6..642e6d4 100644 --- a/build/blocktrail-sdk-full.js +++ b/build/blocktrail-sdk-full.js @@ -4590,7 +4590,7 @@ var FlateStream = (function() { }).call(this); (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.blocktrailSDK = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 300) { + // max inputs length + chunk = 300; + } else { + chunk = utxoArray.length; + } + for (i=0,j=utxoArray.length; i= 255) throw new TypeError('Alphabet too long') - - const BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) - - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - - if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') +// @ts-ignore +var _Buffer = require('safe-buffer').Buffer +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } BASE_MAP[xc] = i } - - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { - if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') - if (source.length === 0) return '' - - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length while (pbegin !== pend && source[pbegin] === 0) { pbegin++ zeroes++ } - - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - - // Process the bytes. + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. while (pbegin !== pend) { - let carry = source[pbegin] - - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (256 * b58[it]) >>> 0 - b58[it] = (carry % BASE) >>> 0 + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 carry = (carry / BASE) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i pbegin++ } - - // Skip leading zeroes in base58 result. - let it = size - length - while (it !== size && b58[it] === 0) { - it++ + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ } - - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } return str } - function decodeUnsafe (source) { - if (typeof source !== 'string') throw new TypeError('Expected String') - if (source.length === 0) return Buffer.alloc(0) - - let psz = 0 - - // Skip leading spaces. - if (source[psz] === ' ') return - - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return _Buffer.alloc(0) } + var psz = 0 + // Skip leading spaces. + if (source[psz] === ' ') { return } + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 while (source[psz] === LEADER) { zeroes++ psz++ } - - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - - // Process the characters. + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. while (source[psz]) { - // Decode character - let carry = BASE_MAP[source.charCodeAt(psz)] - - // Invalid character - if (carry === 255) return - - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (BASE * b256[it]) >>> 0 - b256[it] = (carry % 256) >>> 0 + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 carry = (carry / 256) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i psz++ } - - // Skip trailing spaces. - if (source[psz] === ' ') return - - // Skip leading zeroes in b256. - let it = size - length - while (it !== size && b256[it] === 0) { - it++ + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ } - - const vch = Buffer.allocUnsafe(zeroes + (size - it)) + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) vch.fill(0x00, 0, zeroes) - - let j = zeroes - while (it !== size) { - vch[j++] = b256[it++] + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] } - return vch } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) return buffer - + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } throw new Error('Non-base' + BASE + ' character') } - return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } +module.exports = base -},{"safe-buffer":322}],30:[function(require,module,exports){ +},{"safe-buffer":345}],30:[function(require,module,exports){ (function (exports) { 'use strict'; @@ -16366,7 +16499,7 @@ BigInteger.valueOf = nbv module.exports = BigInteger },{"../package.json":35}],33:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ // FIXME: Kind of a weird way to throw exceptions, consider removing var assert = require('assert') var BigInteger = require('./bigi') @@ -16459,8 +16592,8 @@ BigInteger.prototype.toHex = function(size) { return this.toBuffer(size).toString('hex') } -}).call(this,require("buffer").Buffer) -},{"./bigi":32,"assert":24,"buffer":131}],34:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./bigi":32,"assert":24,"buffer":130}],34:[function(require,module,exports){ var BigInteger = require('./bigi') //addons @@ -16469,21 +16602,27 @@ require('./convert') module.exports = BigInteger },{"./bigi":32,"./convert":33}],35:[function(require,module,exports){ module.exports={ - "_from": "bigi@^1.4.0", + "_args": [ + [ + "bigi@1.4.2", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] + ], + "_from": "bigi@1.4.2", "_id": "bigi@1.4.2", "_inBundle": false, "_integrity": "sha1-nGZalfiLiwj8Bc/XMfVhhZ1yWCU=", "_location": "/bigi", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "bigi@^1.4.0", + "raw": "bigi@1.4.2", "name": "bigi", "escapedName": "bigi", - "rawSpec": "^1.4.0", + "rawSpec": "1.4.2", "saveSpec": null, - "fetchSpec": "^1.4.0" + "fetchSpec": "1.4.2" }, "_requiredBy": [ "/bitcoinjs-lib", @@ -16491,15 +16630,12 @@ module.exports={ "/ecurve" ], "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", - "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825", - "_spec": "bigi@^1.4.0", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/bitcoinjs-lib", + "_spec": "1.4.2", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", "bugs": { "url": "https://github.com/cryptocoinjs/bigi/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Big integers.", "devDependencies": { "coveralls": "^2.11.2", @@ -16556,7 +16692,7 @@ module.exports={ } },{}],36:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ var bip39 = require('./lib/index') var sjcl = require('./sjcl') var assert = require('assert') @@ -16596,9 +16732,9 @@ module.exports = { validateMnemonic: bip39.validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"./lib/index":37,"./sjcl":38,"assert":24,"buffer":131}],37:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/index":37,"./sjcl":38,"assert":24,"buffer":130}],37:[function(require,module,exports){ +(function (Buffer){(function (){ var assert = require('assert') var createHash = require('create-hash') var randomBytes = require('randombytes') @@ -16729,8 +16865,8 @@ module.exports = { validateMnemonic: validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"../wordlists/en.json":39,"assert":24,"buffer":131,"create-hash":139,"randombytes":306,"unorm":355}],38:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"../wordlists/en.json":39,"assert":24,"buffer":130,"create-hash":138,"randombytes":327,"unorm":378}],38:[function(require,module,exports){ "use strict";function q(a){throw a;}var u=void 0,v=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl}); sjcl.cipher.aes=function(a){this.o[0][0][0]||this.t();var b,c,d,e,f=this.o[0][4],g=this.o[1];b=a.length;var h=1;4!==b&&(6!==b&&8!==b)&&q(new sjcl.exception.invalid("invalid aes key size"));this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& @@ -16793,7 +16929,7 @@ b.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&b.ct instanceof ArrayBuffer?sjcl q(new sjcl.exception.invalid("json decode: this isn't json!")),null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(d[4]):unescape(d[4]):null!=d[5]&&(b[d[2]]="true"===d[5]);return b},h:function(a,b,c){a===u&&(a={});if(b===u)return a;for(var d in b)b.hasOwnProperty(d)&&(c&&(a[d]!==u&&a[d]!==b[d])&&q(new sjcl.exception.invalid("required parameter overridden")),a[d]=b[d]);return a},la:function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&& a[d]!==b[d]&&(c[d]=a[d]);return c},ka:function(a,b){var c={},d;for(d=0;d {serialized scriptPubKey script} @@ -21134,7 +21270,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":53,"safe-buffer":322,"typeforce":353}],68:[function(require,module,exports){ +},{"../../script":53,"safe-buffer":345,"typeforce":376}],68:[function(require,module,exports){ // OP_HASH160 {scriptHash} OP_EQUAL var bscript = require('../../script') @@ -21170,7 +21306,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],69:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],69:[function(require,module,exports){ module.exports = { output: require('./output') } @@ -21219,7 +21355,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":322,"typeforce":353}],71:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,"typeforce":376}],71:[function(require,module,exports){ arguments[4][56][0].apply(exports,arguments) },{"./input":72,"./output":73,"dup":56}],72:[function(require,module,exports){ // {signature} {pubKey} @@ -21267,7 +21403,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":53,"typeforce":353}],73:[function(require,module,exports){ +},{"../../script":53,"typeforce":376}],73:[function(require,module,exports){ // OP_0 {pubKeyHash} var bscript = require('../../script') @@ -21302,7 +21438,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],74:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],74:[function(require,module,exports){ arguments[4][56][0].apply(exports,arguments) },{"./input":75,"./output":76,"dup":56}],75:[function(require,module,exports){ // {signature} {pubKey} @@ -21350,7 +21486,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],77:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],77:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var bcrypto = require('./crypto') @@ -21900,7 +22036,7 @@ Transaction.prototype.setWitness = function (index, witness) { module.exports = Transaction -},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,"typeforce":353,"varuint-bitcoin":361}],78:[function(require,module,exports){ +},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,"typeforce":376,"varuint-bitcoin":382}],78:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var baddress = require('./address') @@ -22719,7 +22855,7 @@ TransactionBuilder.prototype.__overMaximumFees = function (bytes) { module.exports = TransactionBuilder -},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,"typeforce":353}],79:[function(require,module,exports){ +},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,"typeforce":376}],79:[function(require,module,exports){ var typeforce = require('typeforce') var UINT31_MAX = Math.pow(2, 31) - 1 @@ -22774,8 +22910,8 @@ for (var typeName in typeforce) { module.exports = types -},{"typeforce":353}],80:[function(require,module,exports){ -(function (Buffer){ +},{"typeforce":376}],80:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') var bufferEquals = require('buffer-equals') var createHash = require('create-hash') @@ -22846,8 +22982,8 @@ module.exports = { verify: verify } -}).call(this,require("buffer").Buffer) -},{"bs58check":83,"buffer":131,"buffer-equals":128,"create-hash":139,"secp256k1":323,"varuint-bitcoin":361}],81:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":83,"buffer":130,"buffer-equals":127,"create-hash":138,"secp256k1":347,"varuint-bitcoin":382}],81:[function(require,module,exports){ // base-x encoding // Forked from https://github.com/cryptocoinjs/bs58 // Originally written by Mike Hearn for BitcoinJ @@ -22942,7 +23078,7 @@ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' module.exports = basex(ALPHABET) },{"base-x":81}],83:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ 'use strict' var base58 = require('bs58') @@ -23003,9 +23139,9 @@ module.exports = { decodeRaw: decodeUnsafe } -}).call(this,require("buffer").Buffer) -},{"bs58":82,"buffer":131,"create-hash":139}],84:[function(require,module,exports){ -(function (__dirname){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58":82,"buffer":130,"create-hash":138}],84:[function(require,module,exports){ +(function (__dirname){(function (){ var async = require('async'); var _ = require('lodash'); var fs = require('fs'); @@ -23400,8 +23536,8 @@ BackupGenerator.prototype.generatePDF = function(callback) { module.exports = BackupGenerator; -}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib") -},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,"async":28,"bowser":102,"fs":238,"lodash":89}],85:[function(require,module,exports){ +}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib") +},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,"async":28,"bowser":102,"fs":240,"lodash":89}],85:[function(require,module,exports){ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs" + "4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNr" + @@ -24061,11 +24197,11 @@ QrCode.prototype.toDataURL = function(text, options, cb) { module.exports = new QrCode(); -},{"qrcode-canvas":301}],88:[function(require,module,exports){ +},{"qrcode-canvas":322}],88:[function(require,module,exports){ exports = module.exports = require('./lib/backup_generator'); },{"./lib/backup_generator":84}],89:[function(require,module,exports){ -(function (global){ +(function (global){(function (){ /** * @license * lodash 3.1.0 (Custom Build) @@ -34891,7 +35027,7 @@ exports = module.exports = require('./lib/backup_generator'); } }.call(this)); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],90:[function(require,module,exports){ (function (module, exports) { 'use strict'; @@ -34945,7 +35081,11 @@ exports = module.exports = require('./lib/backup_generator'); var Buffer; try { - Buffer = require('buffer').Buffer; + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } } catch (e) { } @@ -34986,23 +35126,19 @@ exports = module.exports = require('./lib/backup_generator'); var start = 0; if (number[0] === '-') { start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { this.negative = 1; } - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } }; BN.prototype._initNumber = function _initNumber (number, base, endian) { @@ -35078,31 +35214,29 @@ exports = module.exports = require('./lib/backup_generator'); return this.strip(); }; - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // 'A' - 'F' + if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + // '0' - '9' + } else { + return (c - 48) & 0xf; + } + } - // '0' - '9' - } else { - r |= c & 0xf; - } + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } return r; } - BN.prototype._parseHex = function _parseHex (number, start) { + BN.prototype._parseHex = function _parseHex (number, start, endian) { // Create possibly bigger array to ensure that it fits the number this.length = Math.ceil((number.length - start) / 6); this.words = new Array(this.length); @@ -35110,25 +35244,38 @@ exports = module.exports = require('./lib/backup_generator'); this.words[i] = 0; } - var j, w; - // Scan 24-bit chunks and add them to the number + // 24-bits chunks var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } } + this.strip(); }; @@ -35199,6 +35346,8 @@ exports = module.exports = require('./lib/backup_generator'); this._iaddn(word); } } + + this.strip(); }; BN.prototype.copy = function copy (dest) { @@ -37867,7 +38016,13 @@ exports = module.exports = require('./lib/backup_generator'); } else if (cmp > 0) { r.isub(this.p); } else { - r.strip(); + if (r.strip !== undefined) { + // r is BN v4 instance + r.strip(); + } else { + // r is BN v5 instance + r._strip(); + } } return r; @@ -38321,7 +38476,7 @@ exports = module.exports = require('./lib/backup_generator'); }; })(typeof module === 'undefined' || module, this); -},{"buffer":104}],91:[function(require,module,exports){ +},{"buffer":239}],91:[function(require,module,exports){ var proto = {} module.exports = proto @@ -38661,7 +38816,7 @@ function to_base64(buf) { } -},{"base64-js":30,"to-utf8":350}],101:[function(require,module,exports){ +},{"base64-js":30,"to-utf8":373}],101:[function(require,module,exports){ module.exports = { writeUInt8: write_uint8 , writeInt8: write_int8 @@ -39094,9 +39249,7 @@ if (typeof self === 'object') { } } -},{"crypto":104}],104:[function(require,module,exports){ - -},{}],105:[function(require,module,exports){ +},{"crypto":239}],104:[function(require,module,exports){ // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js @@ -39326,7 +39479,7 @@ AES.prototype.scrub = function () { module.exports.AES = AES -},{"safe-buffer":322}],106:[function(require,module,exports){ +},{"safe-buffer":345}],105:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -39445,7 +39598,7 @@ StreamCipher.prototype.setAAD = function setAAD (buf) { module.exports = StreamCipher -},{"./aes":105,"./ghash":110,"./incr32":111,"buffer-xor":130,"cipher-base":135,"inherits":259,"safe-buffer":322}],107:[function(require,module,exports){ +},{"./aes":104,"./ghash":109,"./incr32":110,"buffer-xor":129,"cipher-base":134,"inherits":279,"safe-buffer":345}],106:[function(require,module,exports){ var ciphers = require('./encrypter') var deciphers = require('./decrypter') var modes = require('./modes/list.json') @@ -39460,7 +39613,7 @@ exports.createDecipher = exports.Decipher = deciphers.createDecipher exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"./decrypter":108,"./encrypter":109,"./modes/list.json":119}],108:[function(require,module,exports){ +},{"./decrypter":107,"./encrypter":108,"./modes/list.json":118}],107:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer var MODES = require('./modes') @@ -39586,7 +39739,7 @@ function createDecipher (suite, password) { exports.createDecipher = createDecipher exports.createDecipheriv = createDecipheriv -},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,"evp_bytestokey":237,"inherits":259,"safe-buffer":322}],109:[function(require,module,exports){ +},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,"evp_bytestokey":238,"inherits":279,"safe-buffer":345}],108:[function(require,module,exports){ var MODES = require('./modes') var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer @@ -39702,7 +39855,7 @@ function createCipher (suite, password) { exports.createCipheriv = createCipheriv exports.createCipher = createCipher -},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,"evp_bytestokey":237,"inherits":259,"safe-buffer":322}],110:[function(require,module,exports){ +},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,"evp_bytestokey":238,"inherits":279,"safe-buffer":345}],109:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var ZEROES = Buffer.alloc(16, 0) @@ -39793,7 +39946,7 @@ GHASH.prototype.final = function (abl, bl) { module.exports = GHASH -},{"safe-buffer":322}],111:[function(require,module,exports){ +},{"safe-buffer":345}],110:[function(require,module,exports){ function incr32 (iv) { var len = iv.length var item @@ -39810,7 +39963,7 @@ function incr32 (iv) { } module.exports = incr32 -},{}],112:[function(require,module,exports){ +},{}],111:[function(require,module,exports){ var xor = require('buffer-xor') exports.encrypt = function (self, block) { @@ -39829,7 +39982,7 @@ exports.decrypt = function (self, block) { return xor(out, pad) } -},{"buffer-xor":130}],113:[function(require,module,exports){ +},{"buffer-xor":129}],112:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var xor = require('buffer-xor') @@ -39864,7 +40017,7 @@ exports.encrypt = function (self, data, decrypt) { return out } -},{"buffer-xor":130,"safe-buffer":322}],114:[function(require,module,exports){ +},{"buffer-xor":129,"safe-buffer":345}],113:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -39908,7 +40061,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":322}],115:[function(require,module,exports){ +},{"safe-buffer":345}],114:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -39935,7 +40088,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":322}],116:[function(require,module,exports){ +},{"safe-buffer":345}],115:[function(require,module,exports){ var xor = require('buffer-xor') var Buffer = require('safe-buffer').Buffer var incr32 = require('../incr32') @@ -39967,7 +40120,7 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -},{"../incr32":111,"buffer-xor":130,"safe-buffer":322}],117:[function(require,module,exports){ +},{"../incr32":110,"buffer-xor":129,"safe-buffer":345}],116:[function(require,module,exports){ exports.encrypt = function (self, block) { return self._cipher.encryptBlock(block) } @@ -39976,7 +40129,7 @@ exports.decrypt = function (self, block) { return self._cipher.decryptBlock(block) } -},{}],118:[function(require,module,exports){ +},{}],117:[function(require,module,exports){ var modeModules = { ECB: require('./ecb'), CBC: require('./cbc'), @@ -39996,7 +40149,7 @@ for (var key in modes) { module.exports = modes -},{"./cbc":112,"./cfb":113,"./cfb1":114,"./cfb8":115,"./ctr":116,"./ecb":117,"./list.json":119,"./ofb":120}],119:[function(require,module,exports){ +},{"./cbc":111,"./cfb":112,"./cfb1":113,"./cfb8":114,"./ctr":115,"./ecb":116,"./list.json":118,"./ofb":119}],118:[function(require,module,exports){ module.exports={ "aes-128-ecb": { "cipher": "AES", @@ -40189,8 +40342,8 @@ module.exports={ } } -},{}],120:[function(require,module,exports){ -(function (Buffer){ +},{}],119:[function(require,module,exports){ +(function (Buffer){(function (){ var xor = require('buffer-xor') function getBlock (self) { @@ -40208,8 +40361,8 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -}).call(this,require("buffer").Buffer) -},{"buffer":131,"buffer-xor":130}],121:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130,"buffer-xor":129}],120:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -40238,7 +40391,7 @@ StreamCipher.prototype._final = function () { module.exports = StreamCipher -},{"./aes":105,"cipher-base":135,"inherits":259,"safe-buffer":322}],122:[function(require,module,exports){ +},{"./aes":104,"cipher-base":134,"inherits":279,"safe-buffer":345}],121:[function(require,module,exports){ var DES = require('browserify-des') var aes = require('browserify-aes/browser') var aesModes = require('browserify-aes/modes') @@ -40307,7 +40460,7 @@ exports.createDecipher = exports.Decipher = createDecipher exports.createDecipheriv = exports.Decipheriv = createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"browserify-aes/browser":107,"browserify-aes/modes":118,"browserify-des":123,"browserify-des/modes":124,"evp_bytestokey":237}],123:[function(require,module,exports){ +},{"browserify-aes/browser":106,"browserify-aes/modes":117,"browserify-des":122,"browserify-des/modes":123,"evp_bytestokey":238}],122:[function(require,module,exports){ var CipherBase = require('cipher-base') var des = require('des.js') var inherits = require('inherits') @@ -40359,7 +40512,7 @@ DES.prototype._final = function () { return Buffer.from(this._des.final()) } -},{"cipher-base":135,"des.js":206,"inherits":259,"safe-buffer":322}],124:[function(require,module,exports){ +},{"cipher-base":134,"des.js":207,"inherits":279,"safe-buffer":345}],123:[function(require,module,exports){ exports['des-ecb'] = { key: 8, iv: 0 @@ -40385,9 +40538,9 @@ exports['des-ede'] = { iv: 0 } -},{}],125:[function(require,module,exports){ +},{}],124:[function(require,module,exports){ arguments[4][82][0].apply(exports,arguments) -},{"base-x":29,"dup":82}],126:[function(require,module,exports){ +},{"base-x":29,"dup":82}],125:[function(require,module,exports){ 'use strict' var base58 = require('bs58') @@ -40439,7 +40592,7 @@ module.exports = function (checksumFn) { } } -},{"bs58":125,"safe-buffer":322}],127:[function(require,module,exports){ +},{"bs58":124,"safe-buffer":345}],126:[function(require,module,exports){ 'use strict' var createHash = require('create-hash') @@ -40453,8 +40606,8 @@ function sha256x2 (buffer) { module.exports = bs58checkBase(sha256x2) -},{"./base":126,"create-hash":139}],128:[function(require,module,exports){ -(function (Buffer){ +},{"./base":125,"create-hash":138}],127:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; module.exports = function (a, b) { if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { @@ -40482,9 +40635,9 @@ module.exports = function (a, b) { return true; }; -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":260}],129:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":280}],128:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function reverse (src) { var buffer = new Buffer(src.length) @@ -40496,9 +40649,9 @@ module.exports = function reverse (src) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],130:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],129:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) var buffer = new Buffer(length) @@ -40510,8 +40663,9 @@ module.exports = function xor (a, b) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],131:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],130:[function(require,module,exports){ +(function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. * @@ -42290,7 +42444,8 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":132,"ieee754":257}],132:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"base64-js":131,"buffer":130,"ieee754":278}],131:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -42358,7 +42513,8 @@ function toByteArray (b64) { ? validLen - 4 : validLen - for (var i = 0; i < len; i += 4) { + var i + for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | @@ -42417,9 +42573,7 @@ function fromByteArray (uint8) { // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } // pad the end with zeros, but make sure to not forget the extra bytes @@ -42443,7 +42597,7 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],133:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ 'use strict'; var BigInteger = require('bigi'); @@ -42630,8 +42784,8 @@ function fromWords(words) { } module.exports = { decode: decode, encode: encode, toWords: toWords, fromWords: fromWords }; -},{"bigi":34}],134:[function(require,module,exports){ -(function (Buffer){ +},{"bigi":34}],133:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; /** global: Buffer */ @@ -42733,8 +42887,8 @@ function decode(address) { } module.exports = { decode: decode, encode: encode }; -}).call(this,require("buffer").Buffer) -},{"./base32":133,"buffer":131}],135:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./base32":132,"buffer":130}],134:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var StringDecoder = require('string_decoder').StringDecoder @@ -42835,7 +42989,7 @@ CipherBase.prototype._toString = function (value, enc, fin) { module.exports = CipherBase -},{"inherits":259,"safe-buffer":322,"stream":338,"string_decoder":241}],136:[function(require,module,exports){ +},{"inherits":279,"safe-buffer":345,"stream":259,"string_decoder":260}],135:[function(require,module,exports){ /** * Expose `Emitter`. @@ -42949,6 +43103,13 @@ Emitter.prototype.removeEventListener = function(event, fn){ break; } } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + return this; }; @@ -42962,9 +43123,14 @@ Emitter.prototype.removeEventListener = function(event, fn){ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) + + var args = new Array(arguments.length - 1) , callbacks = this._callbacks['$' + event]; + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { @@ -43000,8 +43166,8 @@ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; -},{}],137:[function(require,module,exports){ -(function (Buffer){ +},{}],136:[function(require,module,exports){ +(function (Buffer){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -43110,9 +43276,9 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":260}],138:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":280}],137:[function(require,module,exports){ +(function (Buffer){(function (){ var elliptic = require('elliptic') var BN = require('bn.js') @@ -43238,8 +43404,8 @@ function formatReturnValue (bn, enc, len) { } } -}).call(this,require("buffer").Buffer) -},{"bn.js":90,"buffer":131,"elliptic":221}],139:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":90,"buffer":130,"elliptic":222}],138:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var MD5 = require('md5.js') @@ -43271,14 +43437,14 @@ module.exports = function createHash (alg) { return new Hash(sha(alg)) } -},{"cipher-base":135,"inherits":259,"md5.js":263,"ripemd160":321,"sha.js":330}],140:[function(require,module,exports){ +},{"cipher-base":134,"inherits":279,"md5.js":283,"ripemd160":344,"sha.js":354}],139:[function(require,module,exports){ var MD5 = require('md5.js') module.exports = function (buffer) { return new MD5().update(buffer).digest() } -},{"md5.js":263}],141:[function(require,module,exports){ +},{"md5.js":283}],140:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Legacy = require('./legacy') @@ -43342,7 +43508,7 @@ module.exports = function createHmac (alg, key) { return new Hmac(alg, key) } -},{"./legacy":142,"cipher-base":135,"create-hash/md5":140,"inherits":259,"ripemd160":321,"safe-buffer":322,"sha.js":330}],142:[function(require,module,exports){ +},{"./legacy":141,"cipher-base":134,"create-hash/md5":139,"inherits":279,"ripemd160":344,"safe-buffer":345,"sha.js":354}],141:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Buffer = require('safe-buffer').Buffer @@ -43390,7 +43556,7 @@ Hmac.prototype._final = function () { } module.exports = Hmac -},{"cipher-base":135,"inherits":259,"safe-buffer":322}],143:[function(require,module,exports){ +},{"cipher-base":134,"inherits":279,"safe-buffer":345}],142:[function(require,module,exports){ 'use strict' exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') @@ -43489,8 +43655,10 @@ exports.constants = { 'POINT_CONVERSION_HYBRID': 6 } -},{"browserify-cipher":122,"browserify-sign":162,"browserify-sign/algos":159,"create-ecdh":138,"create-hash":139,"create-hmac":141,"diffie-hellman":212,"pbkdf2":269,"public-encrypt":272,"randombytes":306,"randomfill":307}],144:[function(require,module,exports){ -var asn1 = exports; +},{"browserify-cipher":121,"browserify-sign":163,"browserify-sign/algos":160,"create-ecdh":137,"create-hash":138,"create-hmac":140,"diffie-hellman":213,"pbkdf2":290,"public-encrypt":292,"randombytes":327,"randomfill":328}],143:[function(require,module,exports){ +'use strict'; + +const asn1 = exports; asn1.bignum = require('bn.js'); @@ -43500,11 +43668,14 @@ asn1.constants = require('./asn1/constants'); asn1.decoders = require('./asn1/decoders'); asn1.encoders = require('./asn1/encoders'); -},{"./asn1/api":145,"./asn1/base":147,"./asn1/constants":151,"./asn1/decoders":153,"./asn1/encoders":156,"bn.js":90}],145:[function(require,module,exports){ -var asn1 = require('../asn1'); -var inherits = require('inherits'); +},{"./asn1/api":144,"./asn1/base":146,"./asn1/constants":150,"./asn1/decoders":152,"./asn1/encoders":155,"bn.js":157}],144:[function(require,module,exports){ +'use strict'; -var api = exports; +const encoders = require('./encoders'); +const decoders = require('./decoders'); +const inherits = require('inherits'); + +const api = exports; api.define = function define(name, body) { return new Entity(name, body); @@ -43516,34 +43687,27 @@ function Entity(name, body) { this.decoders = {}; this.encoders = {}; -}; +} -Entity.prototype._createNamed = function createNamed(base) { - var named; - try { - named = require('vm').runInThisContext( - '(function ' + this.name + '(entity) {\n' + - ' this._initNamed(entity);\n' + - '})' - ); - } catch (e) { - named = function (entity) { - this._initNamed(entity); - }; +Entity.prototype._createNamed = function createNamed(Base) { + const name = this.name; + + function Generated(entity) { + this._initNamed(entity, name); } - inherits(named, base); - named.prototype._initNamed = function initnamed(entity) { - base.call(this, entity); + inherits(Generated, Base); + Generated.prototype._initNamed = function _initNamed(entity, name) { + Base.call(this, entity, name); }; - return new named(this); + return new Generated(this); }; Entity.prototype._getDecoder = function _getDecoder(enc) { enc = enc || 'der'; // Lazily create decoder if (!this.decoders.hasOwnProperty(enc)) - this.decoders[enc] = this._createNamed(asn1.decoders[enc]); + this.decoders[enc] = this._createNamed(decoders[enc]); return this.decoders[enc]; }; @@ -43555,7 +43719,7 @@ Entity.prototype._getEncoder = function _getEncoder(enc) { enc = enc || 'der'; // Lazily create encoder if (!this.encoders.hasOwnProperty(enc)) - this.encoders[enc] = this._createNamed(asn1.encoders[enc]); + this.encoders[enc] = this._createNamed(encoders[enc]); return this.encoders[enc]; }; @@ -43563,10 +43727,12 @@ Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { return this._getEncoder(enc).encode(data, reporter); }; -},{"../asn1":144,"inherits":259,"vm":242}],146:[function(require,module,exports){ -var inherits = require('inherits'); -var Reporter = require('../base').Reporter; -var Buffer = require('buffer').Buffer; +},{"./decoders":152,"./encoders":155,"inherits":279}],145:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Reporter = require('../base/reporter').Reporter; +const Buffer = require('safer-buffer').Buffer; function DecoderBuffer(base, options) { Reporter.call(this, options); @@ -43582,13 +43748,34 @@ function DecoderBuffer(base, options) { inherits(DecoderBuffer, Reporter); exports.DecoderBuffer = DecoderBuffer; +DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + Buffer.isBuffer(data.base) && + data.constructor.name === 'DecoderBuffer' && + typeof data.offset === 'number' && + typeof data.length === 'number' && + typeof data.save === 'function' && + typeof data.restore === 'function' && + typeof data.isEmpty === 'function' && + typeof data.readUInt8 === 'function' && + typeof data.skip === 'function' && + typeof data.raw === 'function'; + + return isCompatible; +}; + DecoderBuffer.prototype.save = function save() { return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; }; DecoderBuffer.prototype.restore = function restore(save) { // Return skipped data - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); res.offset = save.offset; res.length = this.offset; @@ -43607,13 +43794,13 @@ DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { return this.base.readUInt8(this.offset++, true); else return this.error(fail || 'DecoderBuffer overrun'); -} +}; DecoderBuffer.prototype.skip = function skip(bytes, fail) { if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun'); - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); // Share reporter state res._reporterState = this._reporterState; @@ -43622,17 +43809,17 @@ DecoderBuffer.prototype.skip = function skip(bytes, fail) { res.length = this.offset + bytes; this.offset += bytes; return res; -} +}; DecoderBuffer.prototype.raw = function raw(save) { return this.base.slice(save ? save.offset : this.offset, this.length); -} +}; function EncoderBuffer(value, reporter) { if (Array.isArray(value)) { this.length = 0; this.value = value.map(function(item) { - if (!(item instanceof EncoderBuffer)) + if (!EncoderBuffer.isEncoderBuffer(item)) item = new EncoderBuffer(item, reporter); this.length += item.length; return item; @@ -43654,9 +43841,23 @@ function EncoderBuffer(value, reporter) { } exports.EncoderBuffer = EncoderBuffer; +EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + data.constructor.name === 'EncoderBuffer' && + typeof data.length === 'number' && + typeof data.join === 'function'; + + return isCompatible; +}; + EncoderBuffer.prototype.join = function join(out, offset) { if (!out) - out = new Buffer(this.length); + out = Buffer.alloc(this.length); if (!offset) offset = 0; @@ -43681,22 +43882,26 @@ EncoderBuffer.prototype.join = function join(out, offset) { return out; }; -},{"../base":147,"buffer":131,"inherits":259}],147:[function(require,module,exports){ -var base = exports; +},{"../base/reporter":148,"inherits":279,"safer-buffer":346}],146:[function(require,module,exports){ +'use strict'; + +const base = exports; base.Reporter = require('./reporter').Reporter; base.DecoderBuffer = require('./buffer').DecoderBuffer; base.EncoderBuffer = require('./buffer').EncoderBuffer; base.Node = require('./node'); -},{"./buffer":146,"./node":148,"./reporter":149}],148:[function(require,module,exports){ -var Reporter = require('../base').Reporter; -var EncoderBuffer = require('../base').EncoderBuffer; -var DecoderBuffer = require('../base').DecoderBuffer; -var assert = require('minimalistic-assert'); +},{"./buffer":145,"./node":147,"./reporter":148}],147:[function(require,module,exports){ +'use strict'; + +const Reporter = require('../base/reporter').Reporter; +const EncoderBuffer = require('../base/buffer').EncoderBuffer; +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const assert = require('minimalistic-assert'); // Supported tags -var tags = [ +const tags = [ 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', @@ -43704,13 +43909,13 @@ var tags = [ ]; // Public methods list -var methods = [ +const methods = [ 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains' ].concat(tags); // Overrided methods list -var overrided = [ +const overrided = [ '_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', @@ -43719,10 +43924,11 @@ var overrided = [ '_encodeNull', '_encodeInt', '_encodeBool' ]; -function Node(enc, parent) { - var state = {}; +function Node(enc, parent, name) { + const state = {}; this._baseState = state; + state.name = name; state.enc = enc; state.parent = parent || null; @@ -43752,28 +43958,28 @@ function Node(enc, parent) { } module.exports = Node; -var stateProps = [ +const stateProps = [ 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains' ]; Node.prototype.clone = function clone() { - var state = this._baseState; - var cstate = {}; + const state = this._baseState; + const cstate = {}; stateProps.forEach(function(prop) { cstate[prop] = state[prop]; }); - var res = new this.constructor(cstate.parent); + const res = new this.constructor(cstate.parent); res._baseState = cstate; return res; }; Node.prototype._wrap = function wrap() { - var state = this._baseState; + const state = this._baseState; methods.forEach(function(method) { this[method] = function _wrappedMethod() { - var clone = new this.constructor(this); + const clone = new this.constructor(this); state.children.push(clone); return clone[method].apply(clone, arguments); }; @@ -43781,7 +43987,7 @@ Node.prototype._wrap = function wrap() { }; Node.prototype._init = function init(body) { - var state = this._baseState; + const state = this._baseState; assert(state.parent === null); body.call(this); @@ -43794,10 +44000,10 @@ Node.prototype._init = function init(body) { }; Node.prototype._useArgs = function useArgs(args) { - var state = this._baseState; + const state = this._baseState; // Filter children and args - var children = args.filter(function(arg) { + const children = args.filter(function(arg) { return arg instanceof this.constructor; }, this); args = args.filter(function(arg) { @@ -43820,11 +44026,11 @@ Node.prototype._useArgs = function useArgs(args) { if (typeof arg !== 'object' || arg.constructor !== Object) return arg; - var res = {}; + const res = {}; Object.keys(arg).forEach(function(key) { if (key == (key | 0)) key |= 0; - var value = arg[key]; + const value = arg[key]; res[value] = key; }); return res; @@ -43838,7 +44044,7 @@ Node.prototype._useArgs = function useArgs(args) { overrided.forEach(function(method) { Node.prototype[method] = function _overrided() { - var state = this._baseState; + const state = this._baseState; throw new Error(method + ' not implemented for encoding: ' + state.enc); }; }); @@ -43849,8 +44055,8 @@ overrided.forEach(function(method) { tags.forEach(function(tag) { Node.prototype[tag] = function _tagMethod() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); assert(state.tag === null); state.tag = tag; @@ -43863,7 +44069,7 @@ tags.forEach(function(tag) { Node.prototype.use = function use(item) { assert(item); - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.use = item; @@ -43872,7 +44078,7 @@ Node.prototype.use = function use(item) { }; Node.prototype.optional = function optional() { - var state = this._baseState; + const state = this._baseState; state.optional = true; @@ -43880,7 +44086,7 @@ Node.prototype.optional = function optional() { }; Node.prototype.def = function def(val) { - var state = this._baseState; + const state = this._baseState; assert(state['default'] === null); state['default'] = val; @@ -43890,7 +44096,7 @@ Node.prototype.def = function def(val) { }; Node.prototype.explicit = function explicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.explicit = num; @@ -43899,7 +44105,7 @@ Node.prototype.explicit = function explicit(num) { }; Node.prototype.implicit = function implicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.implicit = num; @@ -43908,8 +44114,8 @@ Node.prototype.implicit = function implicit(num) { }; Node.prototype.obj = function obj() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); state.obj = true; @@ -43920,7 +44126,7 @@ Node.prototype.obj = function obj() { }; Node.prototype.key = function key(newKey) { - var state = this._baseState; + const state = this._baseState; assert(state.key === null); state.key = newKey; @@ -43929,7 +44135,7 @@ Node.prototype.key = function key(newKey) { }; Node.prototype.any = function any() { - var state = this._baseState; + const state = this._baseState; state.any = true; @@ -43937,7 +44143,7 @@ Node.prototype.any = function any() { }; Node.prototype.choice = function choice(obj) { - var state = this._baseState; + const state = this._baseState; assert(state.choice === null); state.choice = obj; @@ -43949,7 +44155,7 @@ Node.prototype.choice = function choice(obj) { }; Node.prototype.contains = function contains(item) { - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.contains = item; @@ -43962,22 +44168,22 @@ Node.prototype.contains = function contains(item) { // Node.prototype._decode = function decode(input, options) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options)); - var result = state['default']; - var present = true; + let result = state['default']; + let present = true; - var prevKey = null; + let prevKey = null; if (state.key !== null) prevKey = input.enterKey(state.key); // Check if tag is there if (state.optional) { - var tag = null; + let tag = null; if (state.explicit !== null) tag = state.explicit; else if (state.implicit !== null) @@ -43987,7 +44193,7 @@ Node.prototype._decode = function decode(input, options) { if (tag === null && !state.any) { // Trial and Error - var save = input.save(); + const save = input.save(); try { if (state.choice === null) this._decodeGeneric(state.tag, input, options); @@ -44007,26 +44213,27 @@ Node.prototype._decode = function decode(input, options) { } // Push object on stack - var prevObj; + let prevObj; if (state.obj && present) prevObj = input.enterObject(); if (present) { // Unwrap explicit values if (state.explicit !== null) { - var explicit = this._decodeTag(input, state.explicit); + const explicit = this._decodeTag(input, state.explicit); if (input.isError(explicit)) return explicit; input = explicit; } - var start = input.offset; + const start = input.offset; // Unwrap implicit and normal values if (state.use === null && state.choice === null) { + let save; if (state.any) - var save = input.save(); - var body = this._decodeTag( + save = input.save(); + const body = this._decodeTag( input, state.implicit !== null ? state.implicit : state.tag, state.any @@ -44047,12 +44254,13 @@ Node.prototype._decode = function decode(input, options) { options.track(input.path(), input.offset, input.length, 'content'); // Select proper method for tag - if (state.any) - result = result; - else if (state.choice === null) + if (state.any) { + // no-op + } else if (state.choice === null) { result = this._decodeGeneric(state.tag, input, options); - else + } else { result = this._decodeChoice(input, options); + } if (input.isError(result)) return result; @@ -44068,9 +44276,9 @@ Node.prototype._decode = function decode(input, options) { // Decode contained/encoded by schema, only in bit or octet strings if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { - var data = new DecoderBuffer(result); + const data = new DecoderBuffer(result); result = this._getUse(state.contains, input._reporterState.obj) - ._decode(data, options); + ._decode(data, options); } } @@ -44088,7 +44296,7 @@ Node.prototype._decode = function decode(input, options) { }; Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { - var state = this._baseState; + const state = this._baseState; if (tag === 'seq' || tag === 'set') return null; @@ -44113,7 +44321,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { if (state.use !== null) { return this._getUse(state.use, input._reporterState.obj) - ._decode(input, options); + ._decode(input, options); } else { return input.error('unknown tag: ' + tag); } @@ -44121,7 +44329,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { Node.prototype._getUse = function _getUse(entity, obj) { - var state = this._baseState; + const state = this._baseState; // Create altered use decoder if implicit is set state.useDecoder = this._use(entity, obj); assert(state.useDecoder._baseState.parent === null); @@ -44134,15 +44342,15 @@ Node.prototype._getUse = function _getUse(entity, obj) { }; Node.prototype._decodeChoice = function decodeChoice(input, options) { - var state = this._baseState; - var result = null; - var match = false; + const state = this._baseState; + let result = null; + let match = false; Object.keys(state.choice).some(function(key) { - var save = input.save(); - var node = state.choice[key]; + const save = input.save(); + const node = state.choice[key]; try { - var value = node._decode(input, options); + const value = node._decode(input, options); if (input.isError(value)) return false; @@ -44170,11 +44378,11 @@ Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { }; Node.prototype._encode = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; if (state['default'] !== null && state['default'] === data) return; - var result = this._encodeValue(data, reporter, parent); + const result = this._encodeValue(data, reporter, parent); if (result === undefined) return; @@ -44185,13 +44393,13 @@ Node.prototype._encode = function encode(data, reporter, parent) { }; Node.prototype._encodeValue = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter()); - var result = null; + let result = null; // Set reporter to share it with a child class this.reporter = reporter; @@ -44199,14 +44407,14 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { // Check if data is there if (state.optional && data === undefined) { if (state['default'] !== null) - data = state['default'] + data = state['default']; else return; } // Encode children first - var content = null; - var primitive = false; + let content = null; + let primitive = false; if (state.any) { // Anything that was given is translated to buffer result = this._createEncoderBuffer(data); @@ -44222,12 +44430,12 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (child._baseState.key === null) return reporter.error('Child should have a key'); - var prevKey = reporter.enterKey(child._baseState.key); + const prevKey = reporter.enterKey(child._baseState.key); if (typeof data !== 'object') return reporter.error('Child expected, but input is not object'); - var res = child._encode(data[child._baseState.key], reporter, data); + const res = child._encode(data[child._baseState.key], reporter, data); reporter.leaveKey(prevKey); return res; @@ -44244,10 +44452,10 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array'); - var child = this.clone(); + const child = this.clone(); child._baseState.implicit = null; content = this._createEncoderBuffer(data.map(function(item) { - var state = this._baseState; + const state = this._baseState; return this._getUse(state.args[0], data)._encode(item, reporter); }, child)); @@ -44260,10 +44468,9 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { } // Encode data itself - var result; if (!state.any && state.choice === null) { - var tag = state.implicit !== null ? state.implicit : state.tag; - var cls = state.implicit === null ? 'universal' : 'context'; + const tag = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? 'universal' : 'context'; if (tag === null) { if (state.use === null) @@ -44282,20 +44489,20 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { }; Node.prototype._encodeChoice = function encodeChoice(data, reporter) { - var state = this._baseState; + const state = this._baseState; - var node = state.choice[data.type]; + const node = state.choice[data.type]; if (!node) { assert( - false, - data.type + ' not found in ' + + false, + data.type + ' not found in ' + JSON.stringify(Object.keys(state.choice))); } return node._encode(data.value, reporter); }; Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { - var state = this._baseState; + const state = this._baseState; if (/str$/.test(tag)) return this._encodeStr(data, tag); @@ -44322,11 +44529,13 @@ Node.prototype._isNumstr = function isNumstr(str) { }; Node.prototype._isPrintstr = function isPrintstr(str) { - return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); }; -},{"../base":147,"minimalistic-assert":266}],149:[function(require,module,exports){ -var inherits = require('inherits'); +},{"../base/buffer":145,"../base/reporter":148,"minimalistic-assert":286}],148:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); function Reporter(options) { this._reporterState = { @@ -44343,13 +44552,13 @@ Reporter.prototype.isError = function isError(obj) { }; Reporter.prototype.save = function save() { - var state = this._reporterState; + const state = this._reporterState; return { obj: state.obj, pathLen: state.path.length }; }; Reporter.prototype.restore = function restore(data) { - var state = this._reporterState; + const state = this._reporterState; state.obj = data.obj; state.path = state.path.slice(0, data.pathLen); @@ -44360,13 +44569,13 @@ Reporter.prototype.enterKey = function enterKey(key) { }; Reporter.prototype.exitKey = function exitKey(index) { - var state = this._reporterState; + const state = this._reporterState; state.path = state.path.slice(0, index - 1); }; Reporter.prototype.leaveKey = function leaveKey(index, key, value) { - var state = this._reporterState; + const state = this._reporterState; this.exitKey(index); if (state.obj !== null) @@ -44378,26 +44587,26 @@ Reporter.prototype.path = function path() { }; Reporter.prototype.enterObject = function enterObject() { - var state = this._reporterState; + const state = this._reporterState; - var prev = state.obj; + const prev = state.obj; state.obj = {}; return prev; }; Reporter.prototype.leaveObject = function leaveObject(prev) { - var state = this._reporterState; + const state = this._reporterState; - var now = state.obj; + const now = state.obj; state.obj = prev; return now; }; Reporter.prototype.error = function error(msg) { - var err; - var state = this._reporterState; + let err; + const state = this._reporterState; - var inherited = msg instanceof ReporterError; + const inherited = msg instanceof ReporterError; if (inherited) { err = msg; } else { @@ -44416,7 +44625,7 @@ Reporter.prototype.error = function error(msg) { }; Reporter.prototype.wrapResult = function wrapResult(result) { - var state = this._reporterState; + const state = this._reporterState; if (!state.options.partial) return result; @@ -44429,7 +44638,7 @@ Reporter.prototype.wrapResult = function wrapResult(result) { function ReporterError(path, msg) { this.path = path; this.rethrow(msg); -}; +} inherits(ReporterError, Error); ReporterError.prototype.rethrow = function rethrow(msg) { @@ -44448,8 +44657,24 @@ ReporterError.prototype.rethrow = function rethrow(msg) { return this; }; -},{"inherits":259}],150:[function(require,module,exports){ -var constants = require('../constants'); +},{"inherits":279}],149:[function(require,module,exports){ +'use strict'; + +// Helper +function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; +} exports.tagClass = { 0: 'universal', @@ -44457,7 +44682,7 @@ exports.tagClass = { 2: 'context', 3: 'private' }; -exports.tagClassByName = constants._reverse(exports.tagClass); +exports.tagClassByName = reverse(exports.tagClass); exports.tag = { 0x00: 'end', @@ -44490,21 +44715,23 @@ exports.tag = { 0x1d: 'charstr', 0x1e: 'bmpstr' }; -exports.tagByName = constants._reverse(exports.tag); +exports.tagByName = reverse(exports.tag); -},{"../constants":151}],151:[function(require,module,exports){ -var constants = exports; +},{}],150:[function(require,module,exports){ +'use strict'; + +const constants = exports; // Helper constants._reverse = function reverse(map) { - var res = {}; + const res = {}; Object.keys(map).forEach(function(key) { // Convert key to integer if it is stringified if ((key | 0) == key) key = key | 0; - var value = map[key]; + const value = map[key]; res[value] = key; }); @@ -44513,15 +44740,17 @@ constants._reverse = function reverse(map) { constants.der = require('./der'); -},{"./der":150}],152:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":149}],151:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; -var bignum = asn1.bignum; +const inherits = require('inherits'); + +const bignum = require('bn.js'); +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DERDecoder(entity) { this.enc = 'der'; @@ -44531,12 +44760,13 @@ function DERDecoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DERDecoder; DERDecoder.prototype.decode = function decode(data, options) { - if (!(data instanceof base.DecoderBuffer)) - data = new base.DecoderBuffer(data, options); + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } return this.tree._decode(data, options); }; @@ -44544,16 +44774,16 @@ DERDecoder.prototype.decode = function decode(data, options) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { if (buffer.isEmpty()) return false; - var state = buffer.save(); - var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); + const state = buffer.save(); + const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; @@ -44564,14 +44794,14 @@ DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { }; DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { - var decodedTag = derDecodeTag(buffer, - 'Failed to decode tag of "' + tag + '"'); + const decodedTag = derDecodeTag(buffer, + 'Failed to decode tag of "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; - var len = derDecodeLen(buffer, - decodedTag.primitive, - 'Failed to get length of "' + tag + '"'); + let len = derDecodeLen(buffer, + decodedTag.primitive, + 'Failed to get length of "' + tag + '"'); // Failure if (buffer.isError(len)) @@ -44588,10 +44818,10 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); // Indefinite length... find END tag - var state = buffer.save(); - var res = this._skipUntilEnd( - buffer, - 'Failed to skip indefinite length body: "' + this.tag + '"'); + const state = buffer.save(); + const res = this._skipUntilEnd( + buffer, + 'Failed to skip indefinite length body: "' + this.tag + '"'); if (buffer.isError(res)) return res; @@ -44601,17 +44831,17 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { }; DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { - while (true) { - var tag = derDecodeTag(buffer, fail); + for (;;) { + const tag = derDecodeTag(buffer, fail); if (buffer.isError(tag)) return tag; - var len = derDecodeLen(buffer, tag.primitive, fail); + const len = derDecodeLen(buffer, tag.primitive, fail); if (buffer.isError(len)) return len; - var res; + let res; if (tag.primitive || len !== null) - res = buffer.skip(len) + res = buffer.skip(len); else res = this._skipUntilEnd(buffer, fail); @@ -44625,14 +44855,14 @@ DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { }; DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, - options) { - var result = []; + options) { + const result = []; while (!buffer.isEmpty()) { - var possibleEnd = this._peekTag(buffer, 'end'); + const possibleEnd = this._peekTag(buffer, 'end'); if (buffer.isError(possibleEnd)) return possibleEnd; - var res = decoder.decode(buffer, 'der', options); + const res = decoder.decode(buffer, 'der', options); if (buffer.isError(res) && possibleEnd) break; result.push(res); @@ -44642,22 +44872,22 @@ DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { if (tag === 'bitstr') { - var unused = buffer.readUInt8(); + const unused = buffer.readUInt8(); if (buffer.isError(unused)) return unused; return { unused: unused, data: buffer.raw() }; } else if (tag === 'bmpstr') { - var raw = buffer.raw(); + const raw = buffer.raw(); if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch'); - var str = ''; - for (var i = 0; i < raw.length / 2; i++) { + let str = ''; + for (let i = 0; i < raw.length / 2; i++) { str += String.fromCharCode(raw.readUInt16BE(i * 2)); } return str; } else if (tag === 'numstr') { - var numstr = buffer.raw().toString('ascii'); + const numstr = buffer.raw().toString('ascii'); if (!this._isNumstr(numstr)) { return buffer.error('Decoding of string type: ' + 'numstr unsupported characters'); @@ -44668,7 +44898,7 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { } else if (tag === 'objDesc') { return buffer.raw(); } else if (tag === 'printstr') { - var printstr = buffer.raw().toString('ascii'); + const printstr = buffer.raw().toString('ascii'); if (!this._isPrintstr(printstr)) { return buffer.error('Decoding of string type: ' + 'printstr unsupported characters'); @@ -44682,11 +44912,12 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { }; DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { - var result; - var identifiers = []; - var ident = 0; + let result; + const identifiers = []; + let ident = 0; + let subident = 0; while (!buffer.isEmpty()) { - var subident = buffer.readUInt8(); + subident = buffer.readUInt8(); ident <<= 7; ident |= subident & 0x7f; if ((subident & 0x80) === 0) { @@ -44697,8 +44928,8 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) if (subident & 0x80) identifiers.push(ident); - var first = (identifiers[0] / 40) | 0; - var second = identifiers[0] % 40; + const first = (identifiers[0] / 40) | 0; + const second = identifiers[0] % 40; if (relative) result = identifiers; @@ -44706,7 +44937,7 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) result = [first, second].concat(identifiers.slice(1)); if (values) { - var tmp = values[result.join(' ')]; + let tmp = values[result.join(' ')]; if (tmp === undefined) tmp = values[result.join('.')]; if (tmp !== undefined) @@ -44717,21 +44948,28 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) }; DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { - var str = buffer.raw().toString(); + const str = buffer.raw().toString(); + + let year; + let mon; + let day; + let hour; + let min; + let sec; if (tag === 'gentime') { - var year = str.slice(0, 4) | 0; - var mon = str.slice(4, 6) | 0; - var day = str.slice(6, 8) | 0; - var hour = str.slice(8, 10) | 0; - var min = str.slice(10, 12) | 0; - var sec = str.slice(12, 14) | 0; + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; } else if (tag === 'utctime') { - var year = str.slice(0, 2) | 0; - var mon = str.slice(2, 4) | 0; - var day = str.slice(4, 6) | 0; - var hour = str.slice(6, 8) | 0; - var min = str.slice(8, 10) | 0; - var sec = str.slice(10, 12) | 0; + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; if (year < 70) year = 2000 + year; else @@ -44743,12 +44981,12 @@ DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { return Date.UTC(year, mon - 1, day, hour, min, sec, 0); }; -DERNode.prototype._decodeNull = function decodeNull(buffer) { +DERNode.prototype._decodeNull = function decodeNull() { return null; }; DERNode.prototype._decodeBool = function decodeBool(buffer) { - var res = buffer.readUInt8(); + const res = buffer.readUInt8(); if (buffer.isError(res)) return res; else @@ -44757,8 +44995,8 @@ DERNode.prototype._decodeBool = function decodeBool(buffer) { DERNode.prototype._decodeInt = function decodeInt(buffer, values) { // Bigint, return as it is (assume big endian) - var raw = buffer.raw(); - var res = new bignum(raw); + const raw = buffer.raw(); + let res = new bignum(raw); if (values) res = values[res.toString(10)] || res; @@ -44775,16 +45013,16 @@ DERNode.prototype._use = function use(entity, obj) { // Utility methods function derDecodeTag(buf, fail) { - var tag = buf.readUInt8(fail); + let tag = buf.readUInt8(fail); if (buf.isError(tag)) return tag; - var cls = der.tagClass[tag >> 6]; - var primitive = (tag & 0x20) === 0; + const cls = der.tagClass[tag >> 6]; + const primitive = (tag & 0x20) === 0; // Multi-octet tag - load if ((tag & 0x1f) === 0x1f) { - var oct = tag; + let oct = tag; tag = 0; while ((oct & 0x80) === 0x80) { oct = buf.readUInt8(fail); @@ -44797,7 +45035,7 @@ function derDecodeTag(buf, fail) { } else { tag &= 0x1f; } - var tagStr = der.tag[tag]; + const tagStr = der.tag[tag]; return { cls: cls, @@ -44808,7 +45046,7 @@ function derDecodeTag(buf, fail) { } function derDecodeLen(buf, primitive, fail) { - var len = buf.readUInt8(fail); + let len = buf.readUInt8(fail); if (buf.isError(len)) return len; @@ -44823,14 +45061,14 @@ function derDecodeLen(buf, primitive, fail) { } // Long form - var num = len & 0x7f; + const num = len & 0x7f; if (num > 4) return buf.error('length octect is too long'); len = 0; - for (var i = 0; i < num; i++) { + for (let i = 0; i < num; i++) { len <<= 8; - var j = buf.readUInt8(fail); + const j = buf.readUInt8(fail); if (buf.isError(j)) return j; len |= j; @@ -44839,35 +45077,39 @@ function derDecodeLen(buf, primitive, fail) { return len; } -},{"../../asn1":144,"inherits":259}],153:[function(require,module,exports){ -var decoders = exports; +},{"../base/buffer":145,"../base/node":147,"../constants/der":149,"bn.js":157,"inherits":279}],152:[function(require,module,exports){ +'use strict'; + +const decoders = exports; decoders.der = require('./der'); decoders.pem = require('./pem'); -},{"./der":152,"./pem":154}],154:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":151,"./pem":153}],153:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; -var DERDecoder = require('./der'); +const DERDecoder = require('./der'); function PEMDecoder(entity) { DERDecoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMDecoder, DERDecoder); module.exports = PEMDecoder; PEMDecoder.prototype.decode = function decode(data, options) { - var lines = data.toString().split(/[\r\n]+/g); + const lines = data.toString().split(/[\r\n]+/g); - var label = options.label.toUpperCase(); + const label = options.label.toUpperCase(); - var re = /^-----(BEGIN|END) ([^-]+)-----$/; - var start = -1; - var end = -1; - for (var i = 0; i < lines.length; i++) { - var match = lines[i].match(re); + const re = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(re); if (match === null) continue; @@ -44888,23 +45130,23 @@ PEMDecoder.prototype.decode = function decode(data, options) { if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label); - var base64 = lines.slice(start + 1, end).join(''); + const base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols - base64.replace(/[^a-z0-9\+\/=]+/gi, ''); + base64.replace(/[^a-z0-9+/=]+/gi, ''); - var input = new Buffer(base64, 'base64'); + const input = Buffer.from(base64, 'base64'); return DERDecoder.prototype.decode.call(this, input, options); }; -},{"./der":152,"buffer":131,"inherits":259}],155:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":151,"inherits":279,"safer-buffer":346}],154:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DEREncoder(entity) { this.enc = 'der'; @@ -44914,7 +45156,7 @@ function DEREncoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DEREncoder; DEREncoder.prototype.encode = function encode(data, reporter) { @@ -44924,19 +45166,19 @@ DEREncoder.prototype.encode = function encode(data, reporter) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._encodeComposite = function encodeComposite(tag, - primitive, - cls, - content) { - var encodedTag = encodeTag(tag, primitive, cls, this.reporter); + primitive, + cls, + content) { + const encodedTag = encodeTag(tag, primitive, cls, this.reporter); // Short form if (content.length < 0x80) { - var header = new Buffer(2); + const header = Buffer.alloc(2); header[0] = encodedTag; header[1] = content.length; return this._createEncoderBuffer([ header, content ]); @@ -44944,15 +45186,15 @@ DERNode.prototype._encodeComposite = function encodeComposite(tag, // Long form // Count octets required to store length - var lenOctets = 1; - for (var i = content.length; i >= 0x100; i >>= 8) + let lenOctets = 1; + for (let i = content.length; i >= 0x100; i >>= 8) lenOctets++; - var header = new Buffer(1 + 1 + lenOctets); + const header = Buffer.alloc(1 + 1 + lenOctets); header[0] = encodedTag; header[1] = 0x80 | lenOctets; - for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) + for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) header[i] = j & 0xff; return this._createEncoderBuffer([ header, content ]); @@ -44962,8 +45204,8 @@ DERNode.prototype._encodeStr = function encodeStr(str, tag) { if (tag === 'bitstr') { return this._createEncoderBuffer([ str.unused | 0, str.data ]); } else if (tag === 'bmpstr') { - var buf = new Buffer(str.length * 2); - for (var i = 0; i < str.length; i++) { + const buf = Buffer.alloc(str.length * 2); + for (let i = 0; i < str.length; i++) { buf.writeUInt16BE(str.charCodeAt(i), i * 2); } return this._createEncoderBuffer(buf); @@ -44999,12 +45241,12 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { return this.reporter.error('string objid given, but no values map found'); if (!values.hasOwnProperty(id)) return this.reporter.error('objid not found in values map'); - id = values[id].split(/[\s\.]+/g); - for (var i = 0; i < id.length; i++) + id = values[id].split(/[\s.]+/g); + for (let i = 0; i < id.length; i++) id[i] |= 0; } else if (Array.isArray(id)) { id = id.slice(); - for (var i = 0; i < id.length; i++) + for (let i = 0; i < id.length; i++) id[i] |= 0; } @@ -45020,17 +45262,17 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { } // Count number of octets - var size = 0; - for (var i = 0; i < id.length; i++) { - var ident = id[i]; + let size = 0; + for (let i = 0; i < id.length; i++) { + let ident = id[i]; for (size++; ident >= 0x80; ident >>= 7) size++; } - var objid = new Buffer(size); - var offset = objid.length - 1; - for (var i = id.length - 1; i >= 0; i--) { - var ident = id[i]; + const objid = Buffer.alloc(size); + let offset = objid.length - 1; + for (let i = id.length - 1; i >= 0; i--) { + let ident = id[i]; objid[offset--] = ident & 0x7f; while ((ident >>= 7) > 0) objid[offset--] = 0x80 | (ident & 0x7f); @@ -45047,12 +45289,12 @@ function two(num) { } DERNode.prototype._encodeTime = function encodeTime(time, tag) { - var str; - var date = new Date(time); + let str; + const date = new Date(time); if (tag === 'gentime') { str = [ - two(date.getFullYear()), + two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -45062,7 +45304,7 @@ DERNode.prototype._encodeTime = function encodeTime(time, tag) { ].join(''); } else if (tag === 'utctime') { str = [ - two(date.getFullYear() % 100), + two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -45094,22 +45336,22 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { // Bignum, assume big endian if (typeof num !== 'number' && !Buffer.isBuffer(num)) { - var numArray = num.toArray(); + const numArray = num.toArray(); if (!num.sign && numArray[0] & 0x80) { numArray.unshift(0); } - num = new Buffer(numArray); + num = Buffer.from(numArray); } if (Buffer.isBuffer(num)) { - var size = num.length; + let size = num.length; if (num.length === 0) size++; - var out = new Buffer(size); + const out = Buffer.alloc(size); num.copy(out); if (num.length === 0) - out[0] = 0 + out[0] = 0; return this._createEncoderBuffer(out); } @@ -45119,12 +45361,12 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { if (num < 0x100) return this._createEncoderBuffer([0, num]); - var size = 1; - for (var i = num; i >= 0x100; i >>= 8) + let size = 1; + for (let i = num; i >= 0x100; i >>= 8) size++; - var out = new Array(size); - for (var i = out.length - 1; i >= 0; i--) { + const out = new Array(size); + for (let i = out.length - 1; i >= 0; i--) { out[i] = num & 0xff; num >>= 8; } @@ -45132,7 +45374,7 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { out.unshift(0); } - return this._createEncoderBuffer(new Buffer(out)); + return this._createEncoderBuffer(Buffer.from(out)); }; DERNode.prototype._encodeBool = function encodeBool(value) { @@ -45146,12 +45388,12 @@ DERNode.prototype._use = function use(entity, obj) { }; DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { - var state = this._baseState; - var i; + const state = this._baseState; + let i; if (state['default'] === null) return false; - var data = dataBuffer.join(); + const data = dataBuffer.join(); if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); @@ -45168,7 +45410,7 @@ DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, pare // Utility methods function encodeTag(tag, primitive, cls, reporter) { - var res; + let res; if (tag === 'seqof') tag = 'seq'; @@ -45193,1910 +45435,5458 @@ function encodeTag(tag, primitive, cls, reporter) { return res; } -},{"../../asn1":144,"buffer":131,"inherits":259}],156:[function(require,module,exports){ -var encoders = exports; +},{"../base/node":147,"../constants/der":149,"inherits":279,"safer-buffer":346}],155:[function(require,module,exports){ +'use strict'; + +const encoders = exports; encoders.der = require('./der'); encoders.pem = require('./pem'); -},{"./der":155,"./pem":157}],157:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":154,"./pem":156}],156:[function(require,module,exports){ +'use strict'; -var DEREncoder = require('./der'); +const inherits = require('inherits'); + +const DEREncoder = require('./der'); function PEMEncoder(entity) { DEREncoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMEncoder, DEREncoder); module.exports = PEMEncoder; PEMEncoder.prototype.encode = function encode(data, options) { - var buf = DEREncoder.prototype.encode.call(this, data); + const buf = DEREncoder.prototype.encode.call(this, data); - var p = buf.toString('base64'); - var out = [ '-----BEGIN ' + options.label + '-----' ]; - for (var i = 0; i < p.length; i += 64) + const p = buf.toString('base64'); + const out = [ '-----BEGIN ' + options.label + '-----' ]; + for (let i = 0; i < p.length; i += 64) out.push(p.slice(i, i + 64)); out.push('-----END ' + options.label + '-----'); return out.join('\n'); }; -},{"./der":155,"inherits":259}],158:[function(require,module,exports){ -(function (Buffer){ -var bn = require('bn.js'); -var randomBytes = require('randombytes'); -module.exports = crt; -function blind(priv) { - var r = getr(priv); - var blinder = r.toRed(bn.mont(priv.modulus)) - .redPow(new bn(priv.publicExponent)).fromRed(); - return { - blinder: blinder, - unblinder:r.invm(priv.modulus) - }; -} -function crt(msg, priv) { - var blinds = blind(priv); - var len = priv.modulus.byteLength(); - var mod = bn.mont(priv.modulus); - var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus); - var c1 = blinded.toRed(bn.mont(priv.prime1)); - var c2 = blinded.toRed(bn.mont(priv.prime2)); - var qinv = priv.coefficient; - var p = priv.prime1; - var q = priv.prime2; - var m1 = c1.redPow(priv.exponent1); - var m2 = c2.redPow(priv.exponent2); - m1 = m1.fromRed(); - m2 = m2.fromRed(); - var h = m1.isub(m2).imul(qinv).umod(p); - h.imul(q); - m2.iadd(h); - return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len)); -} -crt.getr = getr; -function getr(priv) { - var len = priv.modulus.byteLength(); - var r = new bn(randomBytes(len)); - while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) { - r = new bn(randomBytes(len)); - } - return r; -} +},{"./der":154,"inherits":279}],157:[function(require,module,exports){ +arguments[4][90][0].apply(exports,arguments) +},{"buffer":239,"dup":90}],158:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; -}).call(this,require("buffer").Buffer) -},{"bn.js":90,"buffer":131,"randombytes":306}],159:[function(require,module,exports){ -module.exports = require('./browser/algorithms.json') + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } -},{"./browser/algorithms.json":160}],160:[function(require,module,exports){ -module.exports={ - "sha224WithRSAEncryption": { - "sign": "rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "RSA-SHA224": { - "sign": "ecdsa/rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "sha256WithRSAEncryption": { - "sign": "rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "RSA-SHA256": { - "sign": "ecdsa/rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "sha384WithRSAEncryption": { - "sign": "rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "RSA-SHA384": { - "sign": "ecdsa/rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "sha512WithRSAEncryption": { - "sign": "rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA512": { - "sign": "ecdsa/rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA1": { - "sign": "rsa", - "hash": "sha1", - "id": "3021300906052b0e03021a05000414" - }, - "ecdsa-with-SHA1": { - "sign": "ecdsa", - "hash": "sha1", - "id": "" - }, - "sha256": { - "sign": "ecdsa", - "hash": "sha256", - "id": "" - }, - "sha224": { - "sign": "ecdsa", - "hash": "sha224", - "id": "" - }, - "sha384": { - "sign": "ecdsa", - "hash": "sha384", - "id": "" - }, - "sha512": { - "sign": "ecdsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-SHA1": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-WITH-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-WITH-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-WITH-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-WITH-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-RIPEMD160": { - "sign": "dsa", - "hash": "rmd160", - "id": "" - }, - "ripemd160WithRSA": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "RSA-RIPEMD160": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "md5WithRSAEncryption": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" - }, - "RSA-MD5": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; } -} -},{}],161:[function(require,module,exports){ -module.exports={ - "1.3.132.0.10": "secp256k1", - "1.3.132.0.33": "p224", - "1.2.840.10045.3.1.1": "p192", - "1.2.840.10045.3.1.7": "p256", - "1.3.132.0.34": "p384", - "1.3.132.0.35": "p521" -} + // BN -},{}],162:[function(require,module,exports){ -(function (Buffer){ -var createHash = require('create-hash') -var stream = require('stream') -var inherits = require('inherits') -var sign = require('./sign') -var verify = require('./verify') + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } -var algorithms = require('./algorithms.json') -Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = new Buffer(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] -}) + this.negative = 0; + this.words = null; + this.length = 0; -function Sign (algorithm) { - stream.Writable.call(this) + // Reduction context + this.red = null; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Sign, stream.Writable) + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + BN.BN = BN; + BN.wordSize = 26; -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } - this._hash.update(data) - return this -} + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; - return enc ? sig.toString(enc) : sig -} + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; -function Verify (algorithm) { - stream.Writable.call(this) + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Verify, stream.Writable) + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } - this._hash.update(data) - return this -} + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = new Buffer(sig, enc) + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) -} + if (endian !== 'le') return; -function createSign (algorithm) { - return new Sign(algorithm) -} + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; -function createVerify (algorithm) { - return new Verify(algorithm) -} + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } -module.exports = { - Sign: createSign, - Verify: createVerify, - createSign: createSign, - createVerify: createVerify -} + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } -}).call(this,require("buffer").Buffer) -},{"./algorithms.json":160,"./sign":163,"./verify":164,"buffer":131,"create-hash":139,"inherits":259,"stream":338}],163:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var createHmac = require('create-hmac') -var crt = require('browserify-rsa') -var EC = require('elliptic').ec -var BN = require('bn.js') -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; -function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) - if (priv.curve) { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) - } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [ 0, 1 ] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) - - var out = crt(pad, priv) - return out -} - -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) - return new Buffer(out.toDER()) -} - -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) - while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) - if (s.cmpn(0) === 0) { - s = false - r = new BN(0) + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } + return r; } - return toDER(r, s) -} -function toDER (r, s) { - r = r.toArray() - s = s.toArray() + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } - // Pad values - if (r[0] & 0x80) r = [ 0 ].concat(r) - if (s[0] & 0x80) s = [ 0 ].concat(s) + // 24-bits chunks + var off = 0; + var j = 0; - var total = r.length + s.length + 4 - var res = [ 0x30, total, 0x02, r.length ] - res = res.concat(r, [ 0x02, s.length ], s) - return new Buffer(res) -} + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } -function getKey (x, q, hash, algo) { - x = new Buffer(x.toArray()) - if (x.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - x.length) - zeros.fill(0) - x = Buffer.concat([ zeros, x ]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = new Buffer(hlen) - v.fill(1) - var k = new Buffer(hlen) - k.fill(0) - k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } -} + this._strip(); + }; -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits -} + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = new Buffer(bits.toArray()) - if (out.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - out.length) - zeros.fill(0) - out = Buffer.concat([ zeros, out ]) - } - return out -} + r *= mul; -function makeKey (q, kv, algo) { - var t - var k + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; - do { - t = new Buffer(0) + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; - while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([ t, kv.v ]) + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; } + return r; + } - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; - return k -} + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) -} + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); -}).call(this,require("buffer").Buffer) -},{"./curves.json":161,"bn.js":90,"browserify-rsa":158,"buffer":131,"create-hmac":141,"elliptic":221,"parse-asn1":169}],164:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var BN = require('bn.js') -var EC = require('elliptic').ec -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) - if (pub.type === 'ec') { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) - } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [ 1 ] - var padNum = 0 - while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - pad = new Buffer(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - sig = sig.redPow(new BN(pub.publicExponent)) - sig = new Buffer(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 + for (i = 0; i < mod; i++) { + pow *= base; + } - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 -} + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + this._strip(); + }; - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; - return curve.verify(hash, sig, pubkey) -} + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) - var v = g.toRed(montp) - .redPow(new BN(hash).mul(w).mod(q)) - .fromRed() - .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) - .mod(p) - .mod(q) - return v.cmp(r) === 0 -} + BN.prototype._move = function _move (dest) { + move(dest, this); + }; -function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') -} + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; -module.exports = verify + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; -}).call(this,require("buffer").Buffer) -},{"./curves.json":161,"bn.js":90,"buffer":131,"elliptic":221,"parse-asn1":169}],165:[function(require,module,exports){ -module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", -"2.16.840.1.101.3.4.1.2": "aes-128-cbc", -"2.16.840.1.101.3.4.1.3": "aes-128-ofb", -"2.16.840.1.101.3.4.1.4": "aes-128-cfb", -"2.16.840.1.101.3.4.1.21": "aes-192-ecb", -"2.16.840.1.101.3.4.1.22": "aes-192-cbc", -"2.16.840.1.101.3.4.1.23": "aes-192-ofb", -"2.16.840.1.101.3.4.1.24": "aes-192-cfb", -"2.16.840.1.101.3.4.1.41": "aes-256-ecb", -"2.16.840.1.101.3.4.1.42": "aes-256-cbc", -"2.16.840.1.101.3.4.1.43": "aes-256-ofb", -"2.16.840.1.101.3.4.1.44": "aes-256-cfb" -} -},{}],166:[function(require,module,exports){ -// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js -// Fedor, you are amazing. -'use strict' + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; -var asn1 = require('asn1.js') + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; -exports.certificate = require('./certificate') + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } -var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('modulus').int(), - this.key('publicExponent').int(), - this.key('privateExponent').int(), - this.key('prime1').int(), - this.key('prime2').int(), - this.key('exponent1').int(), - this.key('exponent2').int(), - this.key('coefficient').int() - ) -}) -exports.RSAPrivateKey = RSAPrivateKey + function inspect () { + return (this.red ? ''; + } -var RSAPublicKey = asn1.define('RSAPublicKey', function () { - this.seq().obj( - this.key('modulus').int(), - this.key('publicExponent').int() - ) -}) -exports.RSAPublicKey = RSAPublicKey + /* -var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) -exports.PublicKey = PublicKey + var zeros = []; + var groupSizes = []; + var groupBases = []; -var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('none').null_().optional(), - this.key('curve').objid().optional(), - this.key('params').seq().obj( - this.key('p').int(), - this.key('q').int(), - this.key('g').int() - ).optional() - ) -}) + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } -var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { - this.seq().obj( - this.key('version').int(), - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPrivateKey').octstr() - ) -}) -exports.PrivateKey = PrivateKeyInfo -var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { - this.seq().obj( - this.key('algorithm').seq().obj( - this.key('id').objid(), - this.key('decrypt').seq().obj( - this.key('kde').seq().obj( - this.key('id').objid(), - this.key('kdeparams').seq().obj( - this.key('salt').octstr(), - this.key('iters').int() - ) - ), - this.key('cipher').seq().obj( - this.key('algo').objid(), - this.key('iv').octstr() - ) - ) - ), - this.key('subjectPrivateKey').octstr() - ) -}) + */ -exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + var zeros = [ + '', + '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' + ]; -var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('p').int(), - this.key('q').int(), - this.key('g').int(), - this.key('pub_key').int(), - this.key('priv_key').int() - ) -}) -exports.DSAPrivateKey = DSAPrivateKey + var groupSizes = [ + 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 + ]; -exports.DSAparam = asn1.define('DSAparam', function () { - this.int() -}) + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; -var ECPrivateKey = asn1.define('ECPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('privateKey').octstr(), - this.key('parameters').optional().explicit(0).use(ECParameters), - this.key('publicKey').optional().explicit(1).bitstr() - ) -}) -exports.ECPrivateKey = ECPrivateKey + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; -var ECParameters = asn1.define('ECParameters', function () { - this.choice({ - namedCurve: this.objid() - }) -}) + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -exports.signature = asn1.define('signature', function () { - this.seq().obj( - this.key('r').int(), - this.key('s').int() - ) -}) + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); -},{"./certificate":167,"asn1.js":144}],167:[function(require,module,exports){ -// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js -// thanks to @Rantanen + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -'use strict' + assert(false, 'Base should be between 2 and 36'); + }; -var asn = require('asn1.js') + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; -var Time = asn.define('Time', function () { - this.choice({ - utcTime: this.utctime(), - generalTime: this.gentime() - }) -}) + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; -var AttributeTypeValue = asn.define('AttributeTypeValue', function () { - this.seq().obj( - this.key('type').objid(), - this.key('value').any() - ) -}) + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } -var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('parameters').optional() - ) -}) + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; -var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; -var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { - this.setof(AttributeTypeValue) -}) + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); -var RDNSequence = asn.define('RDNSequence', function () { - this.seqof(RelativeDistinguishedName) -}) + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); -var Name = asn.define('Name', function () { - this.choice({ - rdnSequence: this.use(RDNSequence) - }) -}) + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; -var Validity = asn.define('Validity', function () { - this.seq().obj( - this.key('notBefore').use(Time), - this.key('notAfter').use(Time) - ) -}) + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; -var Extension = asn.define('Extension', function () { - this.seq().obj( - this.key('extnID').objid(), - this.key('critical').bool().def(false), - this.key('extnValue').octstr() - ) -}) + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; -var TBSCertificate = asn.define('TBSCertificate', function () { - this.seq().obj( - this.key('version').explicit(0).int(), - this.key('serialNumber').int(), - this.key('signature').use(AlgorithmIdentifier), - this.key('issuer').use(Name), - this.key('validity').use(Validity), - this.key('subject').use(Name), - this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), - this.key('issuerUniqueID').implicit(1).bitstr().optional(), - this.key('subjectUniqueID').implicit(2).bitstr().optional(), - this.key('extensions').explicit(3).seqof(Extension).optional() - ) -}) + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } -var X509Certificate = asn.define('X509Certificate', function () { - this.seq().obj( - this.key('tbsCertificate').use(TBSCertificate), - this.key('signatureAlgorithm').use(AlgorithmIdentifier), - this.key('signatureValue').bitstr() - ) -}) + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } -module.exports = X509Certificate + if (position < res.length) { + res[position++] = carry; -},{"asn1.js":144}],168:[function(require,module,exports){ -(function (Buffer){ -// adapted from https://github.com/apatil/pemstrip -var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m -var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m -var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m -var evp = require('evp_bytestokey') -var ciphers = require('browserify-aes') -module.exports = function (okey, password) { - var key = okey.toString() - var match = key.match(findProc) - var decrypted - if (!match) { - var match2 = key.match(fullRegex) - decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64') - } else { - var suite = 'aes' + match[1] - var iv = new Buffer(match[2], 'hex') - var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64') - var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key - var out = [] - var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - decrypted = Buffer.concat(out) - } - var tag = key.match(startRegex)[1] - return { - tag: tag, - data: decrypted - } -} + while (position < res.length) { + res[position++] = 0; + } + } + }; -}).call(this,require("buffer").Buffer) -},{"browserify-aes":107,"buffer":131,"evp_bytestokey":237}],169:[function(require,module,exports){ -(function (Buffer){ -var asn1 = require('./asn1') -var aesid = require('./aesid.json') -var fixProc = require('./fixProc') -var ciphers = require('browserify-aes') -var compat = require('pbkdf2') -module.exports = parseKeys + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; -function parseKeys (buffer) { - var password - if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { - password = buffer.passphrase - buffer = buffer.key - } - if (typeof buffer === 'string') { - buffer = new Buffer(buffer) - } + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; - var stripped = fixProc(buffer, password) + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } - var type = stripped.tag - var data = stripped.data - var subtype, ndata - switch (type) { - case 'CERTIFICATE': - ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo - // falls through - case 'PUBLIC KEY': - if (!ndata) { - ndata = asn1.PublicKey.decode(data, 'der') + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; } - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') - case '1.2.840.10045.2.1': - ndata.subjectPrivateKey = ndata.subjectPublicKey - return { - type: 'ec', - data: ndata - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') - return { - type: 'dsa', - data: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; } - throw new Error('unknown key type ' + type) - case 'ENCRYPTED PRIVATE KEY': - data = asn1.EncryptedPrivateKey.decode(data, 'der') - data = decrypt(data, password) - // falls through - case 'PRIVATE KEY': - ndata = asn1.PrivateKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') - case '1.2.840.10045.2.1': - return { - curve: ndata.algorithm.curve, - privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') - return { - type: 'dsa', - params: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; } - throw new Error('unknown key type ' + type) - case 'RSA PUBLIC KEY': - return asn1.RSAPublicKey.decode(data, 'der') - case 'RSA PRIVATE KEY': - return asn1.RSAPrivateKey.decode(data, 'der') - case 'DSA PRIVATE KEY': - return { - type: 'dsa', - params: asn1.DSAPrivateKey.decode(data, 'der') + if (t >= 0x40) { + r += 7; + t >>>= 7; } - case 'EC PRIVATE KEY': - data = asn1.ECPrivateKey.decode(data, 'der') - return { - curve: data.parameters.value, - privateKey: data.privateKey + if (t >= 0x8) { + r += 4; + t >>>= 4; } - default: throw new Error('unknown key type ' + type) + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; } -} -parseKeys.signature = asn1.signature -function decrypt (data, password) { - var salt = data.algorithm.decrypt.kde.kdeparams.salt - var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) - var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] - var iv = data.algorithm.decrypt.cipher.iv - var cipherText = data.subjectPrivateKey - var keylen = parseInt(algo.split('-')[1], 10) / 8 - var key = compat.pbkdf2Sync(password, salt, iters, keylen) - var cipher = ciphers.createDecipheriv(algo, key, iv) - var out = [] - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - return Buffer.concat(out) -} -}).call(this,require("buffer").Buffer) -},{"./aesid.json":165,"./asn1":166,"./fixProc":168,"browserify-aes":107,"buffer":131,"pbkdf2":269}],170:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; - // Lookup tables - var SBOX = []; - var INV_SBOX = []; - var SUB_MIX_0 = []; - var SUB_MIX_1 = []; - var SUB_MIX_2 = []; - var SUB_MIX_3 = []; - var INV_SUB_MIX_0 = []; - var INV_SUB_MIX_1 = []; - var INV_SUB_MIX_2 = []; - var INV_SUB_MIX_3 = []; + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; - // Compute lookup tables - (function () { - // Compute double table - var d = []; - for (var i = 0; i < 256; i++) { - if (i < 128) { - d[i] = i << 1; - } else { - d[i] = (i << 1) ^ 0x11b; - } - } + function toBitArray (num) { + var w = new Array(num.bitLength()); - // Walk GF(2^8) - var x = 0; - var xi = 0; - for (var i = 0; i < 256; i++) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; - SBOX[x] = sx; - INV_SBOX[sx] = x; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - // Compute multiplication - var x2 = d[x]; - var x4 = d[x2]; - var x8 = d[x4]; + w[bit] = (num.words[off] >>> wbit) & 0x01; + } - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100); - SUB_MIX_0[x] = (t << 24) | (t >>> 8); - SUB_MIX_1[x] = (t << 16) | (t >>> 16); - SUB_MIX_2[x] = (t << 8) | (t >>> 24); - SUB_MIX_3[x] = t; + return w; + } - // Compute inv sub bytes, inv mix columns tables - var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); - INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); - INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); - INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); - INV_SUB_MIX_3[sx] = t; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - // Compute next counter - if (!x) { - x = xi = 1; - } else { - x = x2 ^ d[d[d[x8 ^ x2]]]; - xi ^= d[d[xi]]; - } - } - }()); + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; - // Precomputed Rcon lookup - var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; - /** - * AES block cipher algorithm. - */ - var AES = C_algo.AES = BlockCipher.extend({ - _doReset: function () { - // Skip reset of nRounds has been set before and key did not change - if (this._nRounds && this._keyPriorReset === this._key) { - return; - } + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; - // Shortcuts - var key = this._keyPriorReset = this._key; - var keyWords = key.words; - var keySize = key.sigBytes / 4; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; - // Compute number of rounds - var nRounds = this._nRounds = keySize + 6; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; - // Compute number of key schedule rows - var ksRows = (nRounds + 1) * 4; + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; - // Compute key schedule - var keySchedule = this._keySchedule = []; - for (var ksRow = 0; ksRow < ksRows; ksRow++) { - if (ksRow < keySize) { - keySchedule[ksRow] = keyWords[ksRow]; - } else { - var t = keySchedule[ksRow - 1]; + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } - if (!(ksRow % keySize)) { - // Rot word - t = (t << 8) | (t >>> 24); + return this; + }; - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } - // Mix Rcon - t ^= RCON[(ksRow / keySize) | 0] << 24; - } else if (keySize > 6 && ksRow % keySize == 4) { - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - } + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } - keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; - } - } + return this._strip(); + }; - // Compute inv key schedule - var invKeySchedule = this._invKeySchedule = []; - for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { - var ksRow = ksRows - invKsRow; + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; - if (invKsRow % 4) { - var t = keySchedule[ksRow]; - } else { - var t = keySchedule[ksRow - 4]; - } + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; - if (invKsRow < 4 || ksRow <= 4) { - invKeySchedule[invKsRow] = t; - } else { - invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ - INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; - } - } - }, + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); - }, + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } - decryptBlock: function (M, offset) { - // Swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } - this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + this.length = b.length; - // Inv swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; - }, + return this._strip(); + }; - _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { - // Shortcut - var nRounds = this._nRounds; + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; - // Get input, add round key - var s0 = M[offset] ^ keySchedule[0]; - var s1 = M[offset + 1] ^ keySchedule[1]; - var s2 = M[offset + 2] ^ keySchedule[2]; - var s3 = M[offset + 3] ^ keySchedule[3]; + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; - // Key schedule row counter - var ksRow = 4; + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - // Rounds - for (var round = 1; round < nRounds; round++) { - // Shift rows, sub bytes, mix columns, add round key - var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; - var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; - var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; - var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - // Update state - s0 = t0; - s1 = t1; - s2 = t2; - s3 = t3; - } + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } - // Shift rows, sub bytes, add round key - var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; - var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; - var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; - var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - // Set output - M[offset] = t0; - M[offset + 1] = t1; - M[offset + 2] = t2; - M[offset + 3] = t3; - }, + this.length = a.length; - keySize: 256/32 - }); + return this._strip(); + }; - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); - */ - C.AES = BlockCipher._createHelper(AES); - }()); + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; - return CryptoJS.AES; + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; -})); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],171:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - /** - * Cipher core components. - */ - CryptoJS.lib.Cipher || (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var Base64 = C_enc.Base64; - var C_algo = C.algo; - var EvpKDF = C_algo.EvpKDF; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - /** - * Abstract base cipher template. - * - * @property {number} keySize This cipher's key size. Default: 4 (128 bits) - * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) - * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. - * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. - */ - var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - * - * @property {WordArray} iv The IV to use for this operation. - */ - cfg: Base.extend(), + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - /** - * Creates this cipher in encryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); - */ - createEncryptor: function (key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); - }, + if (bitsLeft > 0) { + bytesNeeded--; + } - /** - * Creates this cipher in decryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); - */ - createDecryptor: function (key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); - }, + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - /** - * Initializes a newly created cipher. - * - * @param {number} xformMode Either the encryption or decryption transormation mode constant. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @example - * - * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); - */ - init: function (xformMode, key, cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - // Store transform mode and key - this._xformMode = xformMode; - this._key = key; + // And remove leading zeroes + return this._strip(); + }; - // Set initial values - this.reset(); - }, + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; - /** - * Resets this cipher to its initial state. - * - * @example - * - * cipher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - // Perform concrete-cipher logic - this._doReset(); - }, + var off = (bit / 26) | 0; + var wbit = bit % 26; - /** - * Adds data to be encrypted or decrypted. - * - * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. - * - * @return {WordArray} The data after processing. - * - * @example - * - * var encrypted = cipher.process('data'); - * var encrypted = cipher.process(wordArray); - */ - process: function (dataUpdate) { - // Append - this._append(dataUpdate); + this._expand(off + 1); - // Process available blocks - return this._process(); - }, + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } - /** - * Finalizes the encryption or decryption process. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. - * - * @return {WordArray} The data after final processing. - * - * @example - * - * var encrypted = cipher.finalize(); - * var encrypted = cipher.finalize('data'); - * var encrypted = cipher.finalize(wordArray); - */ - finalize: function (dataUpdate) { - // Final data update - if (dataUpdate) { - this._append(dataUpdate); - } + return this._strip(); + }; - // Perform concrete-cipher logic - var finalProcessedData = this._doFinalize(); + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; - return finalProcessedData; - }, + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); - keySize: 128/32, + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } - ivSize: 128/32, + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - _ENC_XFORM_MODE: 1, + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } - _DEC_XFORM_MODE: 2, + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * Creates shortcut functions to a cipher's object interface. - * - * @param {Cipher} cipher The cipher to create a helper for. - * - * @return {Object} An object with encrypt and decrypt shortcut functions. - * - * @static - * - * @example - * - * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); - */ - _createHelper: (function () { - function selectCipherStrategy(key) { - if (typeof key == 'string') { - return PasswordBasedCipher; - } else { - return SerializableCipher; - } - } + return this; + }; - return function (cipher) { - return { - encrypt: function (message, key, cfg) { - return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); - }, + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } - decrypt: function (ciphertext, key, cfg) { - return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); - } - }; - }; - }()) - }); + if (this.length > num.length) return this.clone().iadd(num); - /** - * Abstract base stream cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) - */ - var StreamCipher = C_lib.StreamCipher = Cipher.extend({ - _doFinalize: function () { - // Process partial blocks - var finalProcessedBlocks = this._process(!!'flush'); + return num.clone().iadd(this); + }; - return finalProcessedBlocks; - }, + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); - blockSize: 1 - }); + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } - /** - * Mode namespace. - */ - var C_mode = C.mode = {}; + // At this point both numbers are positive + var cmp = this.cmp(num); - /** - * Abstract base block cipher mode template. - */ - var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ - /** - * Creates this mode for encryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); - */ - createEncryptor: function (cipher, iv) { - return this.Encryptor.create(cipher, iv); - }, + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } - /** - * Creates this mode for decryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); - */ - createDecryptor: function (cipher, iv) { - return this.Decryptor.create(cipher, iv); - }, + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * Initializes a newly created mode. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @example - * - * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); - */ - init: function (cipher, iv) { - this._cipher = cipher; - this._iv = iv; - } - }); + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } - /** - * Cipher Block Chaining mode. - */ - var CBC = C_mode.CBC = (function () { - /** - * Abstract base CBC mode. - */ - var CBC = BlockCipherMode.extend(); + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * CBC encryptor. - */ - CBC.Encryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; + this.length = Math.max(this.length, i); - // XOR and encrypt - xorBlock.call(this, words, offset, blockSize); - cipher.encryptBlock(words, offset); + if (a !== this) { + this.negative = 1; + } - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); - - /** - * CBC decryptor. - */ - CBC.Decryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); - - // Decrypt and XOR - cipher.decryptBlock(words, offset); - xorBlock.call(this, words, offset, blockSize); - - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); - - function xorBlock(words, offset, blockSize) { - // Shortcut - var iv = this._iv; - - // Choose mixing block - if (iv) { - var block = iv; - - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - var block = this._prevBlock; - } - - // XOR blocks - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= block[i]; - } - } - - return CBC; - }()); - - /** - * Padding namespace. - */ - var C_pad = C.pad = {}; - - /** - * PKCS #5/7 padding strategy. - */ - var Pkcs7 = C_pad.Pkcs7 = { - /** - * Pads data using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to pad. - * @param {number} blockSize The multiple that the data should be padded to. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.pad(wordArray, 4); - */ - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Create padding word - var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; - - // Create padding - var paddingWords = []; - for (var i = 0; i < nPaddingBytes; i += 4) { - paddingWords.push(paddingWord); - } - var padding = WordArray.create(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - - /** - * Unpads data that had been padded using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to unpad. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.unpad(wordArray); - */ - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; - - /** - * Abstract base block cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) - */ - var BlockCipher = C_lib.BlockCipher = Cipher.extend({ - /** - * Configuration options. - * - * @property {Mode} mode The block mode to use. Default: CBC - * @property {Padding} padding The padding strategy to use. Default: Pkcs7 - */ - cfg: Cipher.cfg.extend({ - mode: CBC, - padding: Pkcs7 - }), - - reset: function () { - // Reset cipher - Cipher.reset.call(this); - - // Shortcuts - var cfg = this.cfg; - var iv = cfg.iv; - var mode = cfg.mode; - - // Reset block mode - if (this._xformMode == this._ENC_XFORM_MODE) { - var modeCreator = mode.createEncryptor; - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - var modeCreator = mode.createDecryptor; - - // Keep at least one block in the buffer for unpadding - this._minBufferSize = 1; - } - this._mode = modeCreator.call(mode, this, iv && iv.words); - }, - - _doProcessBlock: function (words, offset) { - this._mode.processBlock(words, offset); - }, - - _doFinalize: function () { - // Shortcut - var padding = this.cfg.padding; - - // Finalize - if (this._xformMode == this._ENC_XFORM_MODE) { - // Pad data - padding.pad(this._data, this.blockSize); - - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - - // Unpad data - padding.unpad(finalProcessedBlocks); - } - - return finalProcessedBlocks; - }, - - blockSize: 128/32 - }); - - /** - * A collection of cipher parameters. - * - * @property {WordArray} ciphertext The raw ciphertext. - * @property {WordArray} key The key to this ciphertext. - * @property {WordArray} iv The IV used in the ciphering operation. - * @property {WordArray} salt The salt used with a key derivation function. - * @property {Cipher} algorithm The cipher algorithm. - * @property {Mode} mode The block mode used in the ciphering operation. - * @property {Padding} padding The padding scheme used in the ciphering operation. - * @property {number} blockSize The block size of the cipher. - * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. - */ - var CipherParams = C_lib.CipherParams = Base.extend({ - /** - * Initializes a newly created cipher params object. - * - * @param {Object} cipherParams An object with any of the possible cipher parameters. - * - * @example - * - * var cipherParams = CryptoJS.lib.CipherParams.create({ - * ciphertext: ciphertextWordArray, - * key: keyWordArray, - * iv: ivWordArray, - * salt: saltWordArray, - * algorithm: CryptoJS.algo.AES, - * mode: CryptoJS.mode.CBC, - * padding: CryptoJS.pad.PKCS7, - * blockSize: 4, - * formatter: CryptoJS.format.OpenSSL - * }); - */ - init: function (cipherParams) { - this.mixIn(cipherParams); - }, - - /** - * Converts this cipher params object to a string. - * - * @param {Format} formatter (Optional) The formatting strategy to use. - * - * @return {string} The stringified cipher params. - * - * @throws Error If neither the formatter nor the default formatter is set. - * - * @example - * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); - */ - toString: function (formatter) { - return (formatter || this.formatter).stringify(this); - } - }); - - /** - * Format namespace. - */ - var C_format = C.format = {}; - - /** - * OpenSSL formatting strategy. - */ - var OpenSSLFormatter = C_format.OpenSSL = { - /** - * Converts a cipher params object to an OpenSSL-compatible string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The OpenSSL-compatible string. - * - * @static - * - * @example - * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); - */ - stringify: function (cipherParams) { - // Shortcuts - var ciphertext = cipherParams.ciphertext; - var salt = cipherParams.salt; - - // Format - if (salt) { - var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); - } else { - var wordArray = ciphertext; - } - - return wordArray.toString(Base64); - }, - - /** - * Converts an OpenSSL-compatible string to a cipher params object. - * - * @param {string} openSSLStr The OpenSSL-compatible string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); - */ - parse: function (openSSLStr) { - // Parse base64 - var ciphertext = Base64.parse(openSSLStr); - - // Shortcut - var ciphertextWords = ciphertext.words; - - // Test for salt - if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { - // Extract salt - var salt = WordArray.create(ciphertextWords.slice(2, 4)); - - // Remove salt from ciphertext - ciphertextWords.splice(0, 4); - ciphertext.sigBytes -= 16; - } - - return CipherParams.create({ ciphertext: ciphertext, salt: salt }); - } - }; - - /** - * A cipher wrapper that returns ciphertext as a serializable cipher params object. - */ - var SerializableCipher = C_lib.SerializableCipher = Base.extend({ - /** - * Configuration options. - * - * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL - */ - cfg: Base.extend({ - format: OpenSSLFormatter - }), - - /** - * Encrypts a message. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + return this._strip(); + }; - // Encrypt - var encryptor = cipher.createEncryptor(key, cfg); - var ciphertext = encryptor.finalize(message); + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; - // Shortcut - var cipherCfg = encryptor.cfg; + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; - // Create and return serializable cipher params - return CipherParams.create({ - ciphertext: ciphertext, - key: key, - iv: cipherCfg.iv, - algorithm: cipher, - mode: cipherCfg.mode, - padding: cipherCfg.padding, - blockSize: cipher.blockSize, - formatter: cfg.format - }); - }, + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; - /** - * Decrypts serialized ciphertext. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } - // Decrypt - var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return out._strip(); + } - return plaintext; - }, + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; - /** - * Converts serialized ciphertext to CipherParams, - * else assumed CipherParams already and returns ciphertext unchanged. - * - * @param {CipherParams|string} ciphertext The ciphertext. - * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. - * - * @return {CipherParams} The unserialized ciphertext. - * - * @static + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out._strip(); + } + + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out._strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this._strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this._strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this._strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this._strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this._strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this._strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return isNegNum ? -acc : acc; + }; + + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + this._strip(); + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this._strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":239}],159:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js') +var randomBytes = require('randombytes') + +function blind (priv) { + var r = getr(priv) + var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() + return { blinder: blinder, unblinder: r.invm(priv.modulus) } +} + +function getr (priv) { + var len = priv.modulus.byteLength() + var r + do { + r = new BN(randomBytes(len)) + } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) + return r +} + +function crt (msg, priv) { + var blinds = blind(priv) + var len = priv.modulus.byteLength() + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) + var c1 = blinded.toRed(BN.mont(priv.prime1)) + var c2 = blinded.toRed(BN.mont(priv.prime2)) + var qinv = priv.coefficient + var p = priv.prime1 + var q = priv.prime2 + var m1 = c1.redPow(priv.exponent1).fromRed() + var m2 = c2.redPow(priv.exponent2).fromRed() + var h = m1.isub(m2).imul(qinv).umod(p).imul(q) + return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) +} +crt.getr = getr + +module.exports = crt + +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":158,"buffer":130,"randombytes":327}],160:[function(require,module,exports){ +module.exports = require('./browser/algorithms.json') + +},{"./browser/algorithms.json":161}],161:[function(require,module,exports){ +module.exports={ + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } +} + +},{}],162:[function(require,module,exports){ +module.exports={ + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" +} + +},{}],163:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var createHash = require('create-hash') +var stream = require('readable-stream') +var inherits = require('inherits') +var sign = require('./sign') +var verify = require('./verify') + +var algorithms = require('./algorithms.json') +Object.keys(algorithms).forEach(function (key) { + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') + algorithms[key.toLowerCase()] = algorithms[key] +}) + +function Sign (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hashType = data.hash + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Sign, stream.Writable) + +Sign.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Sign.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Sign.prototype.sign = function signMethod (key, enc) { + this.end() + var hash = this._hash.digest() + var sig = sign(hash, key, this._hashType, this._signType, this._tag) + + return enc ? sig.toString(enc) : sig +} + +function Verify (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Verify, stream.Writable) + +Verify.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Verify.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Verify.prototype.verify = function verifyMethod (key, sig, enc) { + if (typeof sig === 'string') sig = Buffer.from(sig, enc) + + this.end() + var hash = this._hash.digest() + return verify(sig, hash, key, this._signType, this._tag) +} + +function createSign (algorithm) { + return new Sign(algorithm) +} + +function createVerify (algorithm) { + return new Verify(algorithm) +} + +module.exports = { + Sign: createSign, + Verify: createVerify, + createSign: createSign, + createVerify: createVerify +} + +},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,"inherits":279,"readable-stream":343,"safe-buffer":345}],164:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var createHmac = require('create-hmac') +var crt = require('browserify-rsa') +var EC = require('elliptic').ec +var BN = require('bn.js') +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function sign (hash, key, hashType, signType, tag) { + var priv = parseKeys(key) + if (priv.curve) { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + return ecSign(hash, priv) + } else if (priv.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong private key type') + return dsaSign(hash, priv, hashType) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + } + hash = Buffer.concat([tag, hash]) + var len = priv.modulus.byteLength() + var pad = [0, 1] + while (hash.length + pad.length + 1 < len) pad.push(0xff) + pad.push(0x00) + var i = -1 + while (++i < hash.length) pad.push(hash[i]) + + var out = crt(pad, priv) + return out +} + +function ecSign (hash, priv) { + var curveId = curves[priv.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) + + var curve = new EC(curveId) + var key = curve.keyFromPrivate(priv.privateKey) + var out = key.sign(hash) + + return Buffer.from(out.toDER()) +} + +function dsaSign (hash, priv, algo) { + var x = priv.params.priv_key + var p = priv.params.p + var q = priv.params.q + var g = priv.params.g + var r = new BN(0) + var k + var H = bits2int(hash, q).mod(q) + var s = false + var kv = getKey(x, q, hash, algo) + while (s === false) { + k = makeKey(q, kv, algo) + r = makeR(g, k, p, q) + s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + if (s.cmpn(0) === 0) { + s = false + r = new BN(0) + } + } + return toDER(r, s) +} + +function toDER (r, s) { + r = r.toArray() + s = s.toArray() + + // Pad values + if (r[0] & 0x80) r = [0].concat(r) + if (s[0] & 0x80) s = [0].concat(s) + + var total = r.length + s.length + 4 + var res = [0x30, total, 0x02, r.length] + res = res.concat(r, [0x02, s.length], s) + return Buffer.from(res) +} + +function getKey (x, q, hash, algo) { + x = Buffer.from(x.toArray()) + if (x.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - x.length) + x = Buffer.concat([zeros, x]) + } + var hlen = hash.length + var hbits = bits2octets(hash, q) + var v = Buffer.alloc(hlen) + v.fill(1) + var k = Buffer.alloc(hlen) + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + return { k: k, v: v } +} + +function bits2int (obits, q) { + var bits = new BN(obits) + var shift = (obits.length << 3) - q.bitLength() + if (shift > 0) bits.ishrn(shift) + return bits +} + +function bits2octets (bits, q) { + bits = bits2int(bits, q) + bits = bits.mod(q) + var out = Buffer.from(bits.toArray()) + if (out.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - out.length) + out = Buffer.concat([zeros, out]) + } + return out +} + +function makeKey (q, kv, algo) { + var t + var k + + do { + t = Buffer.alloc(0) + + while (t.length * 8 < q.bitLength()) { + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + t = Buffer.concat([t, kv.v]) + } + + k = bits2int(t, q) + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + } while (k.cmp(q) !== -1) + + return k +} + +function makeR (g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +} + +module.exports = sign +module.exports.getKey = getKey +module.exports.makeKey = makeKey + +},{"./curves.json":162,"bn.js":158,"browserify-rsa":159,"create-hmac":140,"elliptic":222,"parse-asn1":170,"safe-buffer":345}],165:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var BN = require('bn.js') +var EC = require('elliptic').ec +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function verify (sig, hash, key, signType, tag) { + var pub = parseKeys(key) + if (pub.type === 'ec') { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + return ecVerify(sig, hash, pub) + } else if (pub.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong public key type') + return dsaVerify(sig, hash, pub) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + } + hash = Buffer.concat([tag, hash]) + var len = pub.modulus.byteLength() + var pad = [1] + var padNum = 0 + while (hash.length + pad.length + 2 < len) { + pad.push(0xff) + padNum++ + } + pad.push(0x00) + var i = -1 + while (++i < hash.length) { + pad.push(hash[i]) + } + pad = Buffer.from(pad) + var red = BN.mont(pub.modulus) + sig = new BN(sig).toRed(red) + + sig = sig.redPow(new BN(pub.publicExponent)) + sig = Buffer.from(sig.fromRed().toArray()) + var out = padNum < 8 ? 1 : 0 + len = Math.min(sig.length, pad.length) + if (sig.length !== pad.length) out = 1 + + i = -1 + while (++i < len) out |= sig[i] ^ pad[i] + return out === 0 +} + +function ecVerify (sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + + var curve = new EC(curveId) + var pubkey = pub.data.subjectPrivateKey.data + + return curve.verify(hash, sig, pubkey) +} + +function dsaVerify (sig, hash, pub) { + var p = pub.data.p + var q = pub.data.q + var g = pub.data.g + var y = pub.data.pub_key + var unpacked = parseKeys.signature.decode(sig, 'der') + var s = unpacked.s + var r = unpacked.r + checkValue(s, q) + checkValue(r, q) + var montp = BN.mont(p) + var w = s.invm(q) + var v = g.toRed(montp) + .redPow(new BN(hash).mul(w).mod(q)) + .fromRed() + .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) + .mod(p) + .mod(q) + return v.cmp(r) === 0 +} + +function checkValue (b, q) { + if (b.cmpn(0) <= 0) throw new Error('invalid sig') + if (b.cmp(q) >= q) throw new Error('invalid sig') +} + +module.exports = verify + +},{"./curves.json":162,"bn.js":158,"elliptic":222,"parse-asn1":170,"safe-buffer":345}],166:[function(require,module,exports){ +module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", +"2.16.840.1.101.3.4.1.2": "aes-128-cbc", +"2.16.840.1.101.3.4.1.3": "aes-128-ofb", +"2.16.840.1.101.3.4.1.4": "aes-128-cfb", +"2.16.840.1.101.3.4.1.21": "aes-192-ecb", +"2.16.840.1.101.3.4.1.22": "aes-192-cbc", +"2.16.840.1.101.3.4.1.23": "aes-192-ofb", +"2.16.840.1.101.3.4.1.24": "aes-192-cfb", +"2.16.840.1.101.3.4.1.41": "aes-256-ecb", +"2.16.840.1.101.3.4.1.42": "aes-256-cbc", +"2.16.840.1.101.3.4.1.43": "aes-256-ofb", +"2.16.840.1.101.3.4.1.44": "aes-256-cfb" +} +},{}],167:[function(require,module,exports){ +// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js +// Fedor, you are amazing. +'use strict' + +var asn1 = require('asn1.js') + +exports.certificate = require('./certificate') + +var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('modulus').int(), + this.key('publicExponent').int(), + this.key('privateExponent').int(), + this.key('prime1').int(), + this.key('prime2').int(), + this.key('exponent1').int(), + this.key('exponent2').int(), + this.key('coefficient').int() + ) +}) +exports.RSAPrivateKey = RSAPrivateKey + +var RSAPublicKey = asn1.define('RSAPublicKey', function () { + this.seq().obj( + this.key('modulus').int(), + this.key('publicExponent').int() + ) +}) +exports.RSAPublicKey = RSAPublicKey + +var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) +exports.PublicKey = PublicKey + +var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('none').null_().optional(), + this.key('curve').objid().optional(), + this.key('params').seq().obj( + this.key('p').int(), + this.key('q').int(), + this.key('g').int() + ).optional() + ) +}) + +var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { + this.seq().obj( + this.key('version').int(), + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPrivateKey').octstr() + ) +}) +exports.PrivateKey = PrivateKeyInfo +var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { + this.seq().obj( + this.key('algorithm').seq().obj( + this.key('id').objid(), + this.key('decrypt').seq().obj( + this.key('kde').seq().obj( + this.key('id').objid(), + this.key('kdeparams').seq().obj( + this.key('salt').octstr(), + this.key('iters').int() + ) + ), + this.key('cipher').seq().obj( + this.key('algo').objid(), + this.key('iv').octstr() + ) + ) + ), + this.key('subjectPrivateKey').octstr() + ) +}) + +exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + +var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('p').int(), + this.key('q').int(), + this.key('g').int(), + this.key('pub_key').int(), + this.key('priv_key').int() + ) +}) +exports.DSAPrivateKey = DSAPrivateKey + +exports.DSAparam = asn1.define('DSAparam', function () { + this.int() +}) + +var ECPrivateKey = asn1.define('ECPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('privateKey').octstr(), + this.key('parameters').optional().explicit(0).use(ECParameters), + this.key('publicKey').optional().explicit(1).bitstr() + ) +}) +exports.ECPrivateKey = ECPrivateKey + +var ECParameters = asn1.define('ECParameters', function () { + this.choice({ + namedCurve: this.objid() + }) +}) + +exports.signature = asn1.define('signature', function () { + this.seq().obj( + this.key('r').int(), + this.key('s').int() + ) +}) + +},{"./certificate":168,"asn1.js":143}],168:[function(require,module,exports){ +// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js +// thanks to @Rantanen + +'use strict' + +var asn = require('asn1.js') + +var Time = asn.define('Time', function () { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }) +}) + +var AttributeTypeValue = asn.define('AttributeTypeValue', function () { + this.seq().obj( + this.key('type').objid(), + this.key('value').any() + ) +}) + +var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('parameters').optional(), + this.key('curve').objid().optional() + ) +}) + +var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) + +var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { + this.setof(AttributeTypeValue) +}) + +var RDNSequence = asn.define('RDNSequence', function () { + this.seqof(RelativeDistinguishedName) +}) + +var Name = asn.define('Name', function () { + this.choice({ + rdnSequence: this.use(RDNSequence) + }) +}) + +var Validity = asn.define('Validity', function () { + this.seq().obj( + this.key('notBefore').use(Time), + this.key('notAfter').use(Time) + ) +}) + +var Extension = asn.define('Extension', function () { + this.seq().obj( + this.key('extnID').objid(), + this.key('critical').bool().def(false), + this.key('extnValue').octstr() + ) +}) + +var TBSCertificate = asn.define('TBSCertificate', function () { + this.seq().obj( + this.key('version').explicit(0).int().optional(), + this.key('serialNumber').int(), + this.key('signature').use(AlgorithmIdentifier), + this.key('issuer').use(Name), + this.key('validity').use(Validity), + this.key('subject').use(Name), + this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), + this.key('issuerUniqueID').implicit(1).bitstr().optional(), + this.key('subjectUniqueID').implicit(2).bitstr().optional(), + this.key('extensions').explicit(3).seqof(Extension).optional() + ) +}) + +var X509Certificate = asn.define('X509Certificate', function () { + this.seq().obj( + this.key('tbsCertificate').use(TBSCertificate), + this.key('signatureAlgorithm').use(AlgorithmIdentifier), + this.key('signatureValue').bitstr() + ) +}) + +module.exports = X509Certificate + +},{"asn1.js":143}],169:[function(require,module,exports){ +// adapted from https://github.com/apatil/pemstrip +var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m +var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m +var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m +var evp = require('evp_bytestokey') +var ciphers = require('browserify-aes') +var Buffer = require('safe-buffer').Buffer +module.exports = function (okey, password) { + var key = okey.toString() + var match = key.match(findProc) + var decrypted + if (!match) { + var match2 = key.match(fullRegex) + decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') + } else { + var suite = 'aes' + match[1] + var iv = Buffer.from(match[2], 'hex') + var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key + var out = [] + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + decrypted = Buffer.concat(out) + } + var tag = key.match(startRegex)[1] + return { + tag: tag, + data: decrypted + } +} + +},{"browserify-aes":106,"evp_bytestokey":238,"safe-buffer":345}],170:[function(require,module,exports){ +var asn1 = require('./asn1') +var aesid = require('./aesid.json') +var fixProc = require('./fixProc') +var ciphers = require('browserify-aes') +var compat = require('pbkdf2') +var Buffer = require('safe-buffer').Buffer +module.exports = parseKeys + +function parseKeys (buffer) { + var password + if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { + password = buffer.passphrase + buffer = buffer.key + } + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer) + } + + var stripped = fixProc(buffer, password) + + var type = stripped.tag + var data = stripped.data + var subtype, ndata + switch (type) { + case 'CERTIFICATE': + ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo + // falls through + case 'PUBLIC KEY': + if (!ndata) { + ndata = asn1.PublicKey.decode(data, 'der') + } + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') + case '1.2.840.10045.2.1': + ndata.subjectPrivateKey = ndata.subjectPublicKey + return { + type: 'ec', + data: ndata + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') + return { + type: 'dsa', + data: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'ENCRYPTED PRIVATE KEY': + data = asn1.EncryptedPrivateKey.decode(data, 'der') + data = decrypt(data, password) + // falls through + case 'PRIVATE KEY': + ndata = asn1.PrivateKey.decode(data, 'der') + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') + case '1.2.840.10045.2.1': + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') + return { + type: 'dsa', + params: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'RSA PUBLIC KEY': + return asn1.RSAPublicKey.decode(data, 'der') + case 'RSA PRIVATE KEY': + return asn1.RSAPrivateKey.decode(data, 'der') + case 'DSA PRIVATE KEY': + return { + type: 'dsa', + params: asn1.DSAPrivateKey.decode(data, 'der') + } + case 'EC PRIVATE KEY': + data = asn1.ECPrivateKey.decode(data, 'der') + return { + curve: data.parameters.value, + privateKey: data.privateKey + } + default: throw new Error('unknown key type ' + type) + } +} +parseKeys.signature = asn1.signature +function decrypt (data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) + var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] + var iv = data.algorithm.decrypt.cipher.iv + var cipherText = data.subjectPrivateKey + var keylen = parseInt(algo.split('-')[1], 10) / 8 + var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') + var cipher = ciphers.createDecipheriv(algo, key, iv) + var out = [] + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + return Buffer.concat(out) +} + +},{"./aesid.json":166,"./asn1":167,"./fixProc":169,"browserify-aes":106,"pbkdf2":290,"safe-buffer":345}],171:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + + // Compute lookup tables + (function () { + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } + + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); + + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; + + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; + + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + var t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; + + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + var ksRow = 4; + + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + + keySize: 256/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + C.AES = BlockCipher._createHelper(AES); + }()); + + + return CryptoJS.AES; + +})); +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./evpkdf")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./evpkdf"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Cipher core components. + */ + CryptoJS.lib.Cipher || (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + + /** + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. + */ + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function (key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function (key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function (xformMode, key, cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; + + // Set initial values + this.reset(); + }, + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-cipher logic + this._doReset(); + }, + + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function (dataUpdate) { + // Append + this._append(dataUpdate); + + // Process available blocks + return this._process(); + }, + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function (dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } + + // Perform concrete-cipher logic + var finalProcessedData = this._doFinalize(); + + return finalProcessedData; + }, + + keySize: 128/32, + + ivSize: 128/32, + + _ENC_XFORM_MODE: 1, + + _DEC_XFORM_MODE: 2, + + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: (function () { + function selectCipherStrategy(key) { + if (typeof key == 'string') { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + + return function (cipher) { + return { + encrypt: function (message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + + decrypt: function (ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + }()) + }); + + /** + * Abstract base stream cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ + var StreamCipher = C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function () { + // Process partial blocks + var finalProcessedBlocks = this._process(!!'flush'); + + return finalProcessedBlocks; + }, + + blockSize: 1 + }); + + /** + * Mode namespace. + */ + var C_mode = C.mode = {}; + + /** + * Abstract base block cipher mode template. + */ + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function (cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function (cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function (cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + + /** + * Cipher Block Chaining mode. + */ + var CBC = C_mode.CBC = (function () { + /** + * Abstract base CBC mode. + */ + var CBC = BlockCipherMode.extend(); + + /** + * CBC encryptor. + */ + CBC.Encryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + /** + * CBC decryptor. + */ + CBC.Decryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function xorBlock(words, offset, blockSize) { + // Shortcut + var iv = this._iv; + + // Choose mixing block + if (iv) { + var block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + var block = this._prevBlock; + } + + // XOR blocks + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + + return CBC; + }()); + + /** + * Padding namespace. + */ + var C_pad = C.pad = {}; + + /** + * PKCS #5/7 padding strategy. + */ + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Create padding word + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; + + // Create padding + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + /** + * Abstract base block cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + var BlockCipher = C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + + reset: function () { + // Reset cipher + Cipher.reset.call(this); + + // Shortcuts + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + + // Reset block mode + if (this._xformMode == this._ENC_XFORM_MODE) { + var modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + var modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; + } + + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + + _doProcessBlock: function (words, offset) { + this._mode.processBlock(words, offset); + }, + + _doFinalize: function () { + // Shortcut + var padding = this.cfg.padding; + + // Finalize + if (this._xformMode == this._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); + + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); + + // Unpad data + padding.unpad(finalProcessedBlocks); + } + + return finalProcessedBlocks; + }, + + blockSize: 128/32 + }); + + /** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. + */ + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function (cipherParams) { + this.mixIn(cipherParams); + }, + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function (formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + + /** + * Format namespace. + */ + var C_format = C.format = {}; + + /** + * OpenSSL formatting strategy. + */ + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function (cipherParams) { + // Shortcuts + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + + // Format + if (salt) { + var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + var wordArray = ciphertext; + } + + return wordArray.toString(Base64); + }, + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function (openSSLStr) { + // Parse base64 + var ciphertext = Base64.parse(openSSLStr); + + // Shortcut + var ciphertextWords = ciphertext.words; + + // Test for salt + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { + // Extract salt + var salt = WordArray.create(ciphertextWords.slice(2, 4)); + + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + + return CipherParams.create({ ciphertext: ciphertext, salt: salt }); + } + }; + + /** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Encrypt + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + + // Shortcut + var cipherCfg = encryptor.cfg; + + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext: ciphertext, + key: key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Decrypt + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + + return plaintext; + }, + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static * * @example * @@ -47245,7 +51035,7 @@ function decrypt (data, password) { })); -},{"./core":172}],172:[function(require,module,exports){ +},{"./core":173,"./evpkdf":176}],173:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -48006,7 +51796,7 @@ function decrypt (data, password) { return CryptoJS; })); -},{}],173:[function(require,module,exports){ +},{}],174:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -48142,7 +51932,7 @@ function decrypt (data, password) { return CryptoJS.enc.Base64; })); -},{"./core":172}],174:[function(require,module,exports){ +},{"./core":173}],175:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -48292,7 +52082,7 @@ function decrypt (data, password) { return CryptoJS.enc.Utf16; })); -},{"./core":172}],175:[function(require,module,exports){ +},{"./core":173}],176:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -48425,7 +52215,7 @@ function decrypt (data, password) { return CryptoJS.EvpKDF; })); -},{"./core":172,"./hmac":177,"./sha1":196}],176:[function(require,module,exports){ +},{"./core":173,"./hmac":178,"./sha1":197}],177:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -48492,7 +52282,7 @@ function decrypt (data, password) { return CryptoJS.format.Hex; })); -},{"./cipher-core":171,"./core":172}],177:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],178:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -48636,7 +52426,7 @@ function decrypt (data, password) { })); -},{"./core":172}],178:[function(require,module,exports){ +},{"./core":173}],179:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -48655,7 +52445,7 @@ function decrypt (data, password) { return CryptoJS; })); -},{"./aes":170,"./cipher-core":171,"./core":172,"./enc-base64":173,"./enc-utf16":174,"./evpkdf":175,"./format-hex":176,"./hmac":177,"./lib-typedarrays":179,"./md5":180,"./mode-cfb":181,"./mode-ctr":183,"./mode-ctr-gladman":182,"./mode-ecb":184,"./mode-ofb":185,"./pad-ansix923":186,"./pad-iso10126":187,"./pad-iso97971":188,"./pad-nopadding":189,"./pad-zeropadding":190,"./pbkdf2":191,"./rabbit":193,"./rabbit-legacy":192,"./rc4":194,"./ripemd160":195,"./sha1":196,"./sha224":197,"./sha256":198,"./sha3":199,"./sha384":200,"./sha512":201,"./tripledes":202,"./x64-core":203}],179:[function(require,module,exports){ +},{"./aes":171,"./cipher-core":172,"./core":173,"./enc-base64":174,"./enc-utf16":175,"./evpkdf":176,"./format-hex":177,"./hmac":178,"./lib-typedarrays":180,"./md5":181,"./mode-cfb":182,"./mode-ctr":184,"./mode-ctr-gladman":183,"./mode-ecb":185,"./mode-ofb":186,"./pad-ansix923":187,"./pad-iso10126":188,"./pad-iso97971":189,"./pad-nopadding":190,"./pad-zeropadding":191,"./pbkdf2":192,"./rabbit":194,"./rabbit-legacy":193,"./rc4":195,"./ripemd160":196,"./sha1":197,"./sha224":198,"./sha256":199,"./sha3":200,"./sha384":201,"./sha512":202,"./tripledes":203,"./x64-core":204}],180:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -48732,7 +52522,7 @@ function decrypt (data, password) { return CryptoJS.lib.WordArray; })); -},{"./core":172}],180:[function(require,module,exports){ +},{"./core":173}],181:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -49001,7 +52791,7 @@ function decrypt (data, password) { return CryptoJS.MD5; })); -},{"./core":172}],181:[function(require,module,exports){ +},{"./core":173}],182:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49080,7 +52870,7 @@ function decrypt (data, password) { return CryptoJS.mode.CFB; })); -},{"./cipher-core":171,"./core":172}],182:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],183:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49197,7 +52987,7 @@ function decrypt (data, password) { return CryptoJS.mode.CTRGladman; })); -},{"./cipher-core":171,"./core":172}],183:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],184:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49256,7 +53046,7 @@ function decrypt (data, password) { return CryptoJS.mode.CTR; })); -},{"./cipher-core":171,"./core":172}],184:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],185:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49297,7 +53087,7 @@ function decrypt (data, password) { return CryptoJS.mode.ECB; })); -},{"./cipher-core":171,"./core":172}],185:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],186:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49352,7 +53142,7 @@ function decrypt (data, password) { return CryptoJS.mode.OFB; })); -},{"./cipher-core":171,"./core":172}],186:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],187:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49402,7 +53192,7 @@ function decrypt (data, password) { return CryptoJS.pad.Ansix923; })); -},{"./cipher-core":171,"./core":172}],187:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],188:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49447,7 +53237,7 @@ function decrypt (data, password) { return CryptoJS.pad.Iso10126; })); -},{"./cipher-core":171,"./core":172}],188:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],189:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49488,7 +53278,7 @@ function decrypt (data, password) { return CryptoJS.pad.Iso97971; })); -},{"./cipher-core":171,"./core":172}],189:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],190:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49519,7 +53309,7 @@ function decrypt (data, password) { return CryptoJS.pad.NoPadding; })); -},{"./cipher-core":171,"./core":172}],190:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],191:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49565,7 +53355,7 @@ function decrypt (data, password) { return CryptoJS.pad.ZeroPadding; })); -},{"./cipher-core":171,"./core":172}],191:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],192:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49711,7 +53501,7 @@ function decrypt (data, password) { return CryptoJS.PBKDF2; })); -},{"./core":172,"./hmac":177,"./sha1":196}],192:[function(require,module,exports){ +},{"./core":173,"./hmac":178,"./sha1":197}],193:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -49902,7 +53692,7 @@ function decrypt (data, password) { return CryptoJS.RabbitLegacy; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],193:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -50095,7 +53885,7 @@ function decrypt (data, password) { return CryptoJS.Rabbit; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],194:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -50235,7 +54025,7 @@ function decrypt (data, password) { return CryptoJS.RC4; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],195:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -50503,7 +54293,7 @@ function decrypt (data, password) { return CryptoJS.RIPEMD160; })); -},{"./core":172}],196:[function(require,module,exports){ +},{"./core":173}],197:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -50654,7 +54444,7 @@ function decrypt (data, password) { return CryptoJS.SHA1; })); -},{"./core":172}],197:[function(require,module,exports){ +},{"./core":173}],198:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -50735,7 +54525,7 @@ function decrypt (data, password) { return CryptoJS.SHA224; })); -},{"./core":172,"./sha256":198}],198:[function(require,module,exports){ +},{"./core":173,"./sha256":199}],199:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -50935,7 +54725,7 @@ function decrypt (data, password) { return CryptoJS.SHA256; })); -},{"./core":172}],199:[function(require,module,exports){ +},{"./core":173}],200:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -51259,7 +55049,7 @@ function decrypt (data, password) { return CryptoJS.SHA3; })); -},{"./core":172,"./x64-core":203}],200:[function(require,module,exports){ +},{"./core":173,"./x64-core":204}],201:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -51343,7 +55133,7 @@ function decrypt (data, password) { return CryptoJS.SHA384; })); -},{"./core":172,"./sha512":201,"./x64-core":203}],201:[function(require,module,exports){ +},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -51667,7 +55457,7 @@ function decrypt (data, password) { return CryptoJS.SHA512; })); -},{"./core":172,"./x64-core":203}],202:[function(require,module,exports){ +},{"./core":173,"./x64-core":204}],203:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -52115,7325 +55905,10192 @@ function decrypt (data, password) { 0x1e80: 0x10000000, 0x1f80: 0x10002008 }, - { - 0x0: 0x100000, - 0x10: 0x2000401, - 0x20: 0x400, - 0x30: 0x100401, - 0x40: 0x2100401, - 0x50: 0x0, - 0x60: 0x1, - 0x70: 0x2100001, - 0x80: 0x2000400, - 0x90: 0x100001, - 0xa0: 0x2000001, - 0xb0: 0x2100400, - 0xc0: 0x2100000, - 0xd0: 0x401, - 0xe0: 0x100400, - 0xf0: 0x2000000, - 0x8: 0x2100001, - 0x18: 0x0, - 0x28: 0x2000401, - 0x38: 0x2100400, - 0x48: 0x100000, - 0x58: 0x2000001, - 0x68: 0x2000000, - 0x78: 0x401, - 0x88: 0x100401, - 0x98: 0x2000400, - 0xa8: 0x2100000, - 0xb8: 0x100001, - 0xc8: 0x400, - 0xd8: 0x2100401, - 0xe8: 0x1, - 0xf8: 0x100400, - 0x100: 0x2000000, - 0x110: 0x100000, - 0x120: 0x2000401, - 0x130: 0x2100001, - 0x140: 0x100001, - 0x150: 0x2000400, - 0x160: 0x2100400, - 0x170: 0x100401, - 0x180: 0x401, - 0x190: 0x2100401, - 0x1a0: 0x100400, - 0x1b0: 0x1, - 0x1c0: 0x0, - 0x1d0: 0x2100000, - 0x1e0: 0x2000001, - 0x1f0: 0x400, - 0x108: 0x100400, - 0x118: 0x2000401, - 0x128: 0x2100001, - 0x138: 0x1, - 0x148: 0x2000000, - 0x158: 0x100000, - 0x168: 0x401, - 0x178: 0x2100400, - 0x188: 0x2000001, - 0x198: 0x2100000, - 0x1a8: 0x0, - 0x1b8: 0x2100401, - 0x1c8: 0x100401, - 0x1d8: 0x400, - 0x1e8: 0x2000400, - 0x1f8: 0x100001 + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } + ]; + + // Masks that select the SBOX input + var SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f + ]; + + /** + * DES block cipher algorithm. + */ + var DES = C_algo.DES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Select 56 bits according to PC1 + var keyBits = []; + for (var i = 0; i < 56; i++) { + var keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; + } + + // Assemble 16 subkeys + var subKeys = this._subKeys = []; + for (var nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + var subKey = subKeys[nSubKey] = []; + + // Shortcut + var bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (var i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (var i = 1; i < 7; i++) { + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + var invSubKeys = this._invSubKeys = []; + for (var i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + }, + + decryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + }, + + _doCryptBlock: function (M, offset, subKeys) { + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (var round = 0; round < 16; round++) { + // Shortcuts + var subKey = subKeys[round]; + var lBlock = this._lBlock; + var rBlock = this._rBlock; + + // Feistel function + var f = 0; + for (var i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + var t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + M[offset] = this._lBlock; + M[offset + 1] = this._rBlock; + }, + + keySize: 64/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + // Swap bits across the left and right words + function exchangeLR(offset, mask) { + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; + } + + function exchangeRL(offset, mask) { + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + C.DES = BlockCipher._createHelper(DES); + + /** + * Triple-DES block cipher algorithm. + */ + var TripleDES = C_algo.TripleDES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Create DES instances + this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); + this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); + this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); + }, + + encryptBlock: function (M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + }, + + decryptBlock: function (M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + }, + + keySize: 192/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + C.TripleDES = BlockCipher._createHelper(TripleDES); + }()); + + + return CryptoJS.TripleDES; + +})); +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],204:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var X32WordArray = C_lib.WordArray; + + /** + * x64 namespace. + */ + var C_x64 = C.x64 = {}; + + /** + * A 64-bit word. + */ + var X64Word = C_x64.Word = Base.extend({ + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + init: function (high, low) { + this.high = high; + this.low = low; + } + + /** + * Bitwise NOTs this word. + * + * @return {X64Word} A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + // not: function () { + // var high = ~this.high; + // var low = ~this.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ANDs this word with the passed word. + * + * @param {X64Word} word The x64-Word to AND with this word. + * + * @return {X64Word} A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + // and: function (word) { + // var high = this.high & word.high; + // var low = this.low & word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to OR with this word. + * + * @return {X64Word} A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + // or: function (word) { + // var high = this.high | word.high; + // var low = this.low | word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise XORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to XOR with this word. + * + * @return {X64Word} A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + // xor: function (word) { + // var high = this.high ^ word.high; + // var low = this.low ^ word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the left. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + // shiftL: function (n) { + // if (n < 32) { + // var high = (this.high << n) | (this.low >>> (32 - n)); + // var low = this.low << n; + // } else { + // var high = this.low << (n - 32); + // var low = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the right. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + // shiftR: function (n) { + // if (n < 32) { + // var low = (this.low >>> n) | (this.high << (32 - n)); + // var high = this.high >>> n; + // } else { + // var low = this.high >>> (n - 32); + // var high = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Rotates this word n bits to the left. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + // rotL: function (n) { + // return this.shiftL(n).or(this.shiftR(64 - n)); + // }, + + /** + * Rotates this word n bits to the right. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + // rotR: function (n) { + // return this.shiftR(n).or(this.shiftL(64 - n)); + // }, + + /** + * Adds this word with the passed word. + * + * @param {X64Word} word The x64-Word to add with this word. + * + * @return {X64Word} A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + // add: function (word) { + // var low = (this.low + word.low) | 0; + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; + // var high = (this.high + word.high + carry) | 0; + + // return X64Word.create(high, low); + // } + }); + + /** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var X64WordArray = C_x64.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 8; + } }, - { - 0x0: 0x8000820, - 0x1: 0x20000, - 0x2: 0x8000000, - 0x3: 0x20, - 0x4: 0x20020, - 0x5: 0x8020820, - 0x6: 0x8020800, - 0x7: 0x800, - 0x8: 0x8020000, - 0x9: 0x8000800, - 0xa: 0x20800, - 0xb: 0x8020020, - 0xc: 0x820, - 0xd: 0x0, - 0xe: 0x8000020, - 0xf: 0x20820, - 0x80000000: 0x800, - 0x80000001: 0x8020820, - 0x80000002: 0x8000820, - 0x80000003: 0x8000000, - 0x80000004: 0x8020000, - 0x80000005: 0x20800, - 0x80000006: 0x20820, - 0x80000007: 0x20, - 0x80000008: 0x8000020, - 0x80000009: 0x820, - 0x8000000a: 0x20020, - 0x8000000b: 0x8020800, - 0x8000000c: 0x0, - 0x8000000d: 0x8020020, - 0x8000000e: 0x8000800, - 0x8000000f: 0x20000, - 0x10: 0x20820, - 0x11: 0x8020800, - 0x12: 0x20, - 0x13: 0x800, - 0x14: 0x8000800, - 0x15: 0x8000020, - 0x16: 0x8020020, - 0x17: 0x20000, - 0x18: 0x0, - 0x19: 0x20020, - 0x1a: 0x8020000, - 0x1b: 0x8000820, - 0x1c: 0x8020820, - 0x1d: 0x20800, - 0x1e: 0x820, - 0x1f: 0x8000000, - 0x80000010: 0x20000, - 0x80000011: 0x800, - 0x80000012: 0x8020020, - 0x80000013: 0x20820, - 0x80000014: 0x20, - 0x80000015: 0x8020000, - 0x80000016: 0x8000000, - 0x80000017: 0x8000820, - 0x80000018: 0x8020820, - 0x80000019: 0x8000020, - 0x8000001a: 0x8000800, - 0x8000001b: 0x0, - 0x8000001c: 0x20800, - 0x8000001d: 0x820, - 0x8000001e: 0x20020, - 0x8000001f: 0x8020800 + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32: function () { + // Shortcuts + var x64Words = this.words; + var x64WordsLength = x64Words.length; + + // Convert + var x32Words = []; + for (var i = 0; i < x64WordsLength; i++) { + var x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + }, + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + + // Clone "words" array + var words = clone.words = this.words.slice(0); + + // Clone each X64Word object + var wordsLength = words.length; + for (var i = 0; i < wordsLength; i++) { + words[i] = words[i].clone(); + } + + return clone; } - ]; + }); + }()); + + + return CryptoJS; + +})); +},{"./core":173}],205:[function(require,module,exports){ +(function (process){(function (){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} - // Masks that select the SBOX input - var SBOX_MASK = [ - 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, - 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f - ]; +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ - /** - * DES block cipher algorithm. - */ - var DES = C_algo.DES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; - // Select 56 bits according to PC1 - var keyBits = []; - for (var i = 0; i < 56; i++) { - var keyBitPos = PC1[i] - 1; - keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; - } - // Assemble 16 subkeys - var subKeys = this._subKeys = []; - for (var nSubKey = 0; nSubKey < 16; nSubKey++) { - // Create subkey - var subKey = subKeys[nSubKey] = []; +/** + * Colorize log arguments if enabled. + * + * @api public + */ - // Shortcut - var bitShift = BIT_SHIFTS[nSubKey]; +function formatArgs(args) { + var useColors = this.useColors; - // Select 48 bits according to PC2 - for (var i = 0; i < 24; i++) { - // Select from the left 28 key bits - subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); - // Select from the right 28 key bits - subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); - } + if (!useColors) return; - // Since each subkey is applied to an expanded 32-bit input, - // the subkey can be broken into 8 values scaled to 32-bits, - // which allows the key to be used without expansion - subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); - for (var i = 1; i < 7; i++) { - subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); - } - subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); - } + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') - // Compute inverse subkeys - var invSubKeys = this._invSubKeys = []; - for (var i = 0; i < 16; i++) { - invSubKeys[i] = subKeys[15 - i]; - } - }, + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._subKeys); - }, + args.splice(lastC, 0, c); +} - decryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._invSubKeys); - }, +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ - _doCryptBlock: function (M, offset, subKeys) { - // Get input - this._lBlock = M[offset]; - this._rBlock = M[offset + 1]; +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} - // Initial permutation - exchangeLR.call(this, 4, 0x0f0f0f0f); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeRL.call(this, 2, 0x33333333); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeLR.call(this, 1, 0x55555555); +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ - // Rounds - for (var round = 0; round < 16; round++) { - // Shortcuts - var subKey = subKeys[round]; - var lBlock = this._lBlock; - var rBlock = this._rBlock; +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} - // Feistel function - var f = 0; - for (var i = 0; i < 8; i++) { - f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; - } - this._lBlock = rBlock; - this._rBlock = lBlock ^ f; - } +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ - // Undo swap from last round - var t = this._lBlock; - this._lBlock = this._rBlock; - this._rBlock = t; +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} - // Final permutation - exchangeLR.call(this, 1, 0x55555555); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeRL.call(this, 2, 0x33333333); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeLR.call(this, 4, 0x0f0f0f0f); + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } - // Set output - M[offset] = this._lBlock; - M[offset + 1] = this._rBlock; - }, + return r; +} - keySize: 64/32, +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ - ivSize: 64/32, +exports.enable(load()); - blockSize: 64/32 - }); +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ - // Swap bits across the left and right words - function exchangeLR(offset, mask) { - var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; - this._rBlock ^= t; - this._lBlock ^= t << offset; - } +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} - function exchangeRL(offset, mask) { - var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; - this._lBlock ^= t; - this._rBlock ^= t << offset; - } +}).call(this)}).call(this,require('_process')) +},{"./debug":206,"_process":291}],206:[function(require,module,exports){ - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); - */ - C.DES = BlockCipher._createHelper(DES); +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ - /** - * Triple-DES block cipher algorithm. - */ - var TripleDES = C_algo.TripleDES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); - // Create DES instances - this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); - this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); - this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); - }, +/** + * The currently active debug mode names, and names to skip. + */ - encryptBlock: function (M, offset) { - this._des1.encryptBlock(M, offset); - this._des2.decryptBlock(M, offset); - this._des3.encryptBlock(M, offset); - }, +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":288}],207:[function(require,module,exports){ +'use strict'; + +exports.utils = require('./des/utils'); +exports.Cipher = require('./des/cipher'); +exports.DES = require('./des/des'); +exports.CBC = require('./des/cbc'); +exports.EDE = require('./des/ede'); + +},{"./des/cbc":208,"./des/cipher":209,"./des/des":210,"./des/ede":211,"./des/utils":212}],208:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var proto = {}; + +function CBCState(iv) { + assert.equal(iv.length, 8, 'Invalid IV length'); + + this.iv = new Array(8); + for (var i = 0; i < this.iv.length; i++) + this.iv[i] = iv[i]; +} + +function instantiate(Base) { + function CBC(options) { + Base.call(this, options); + this._cbcInit(); + } + inherits(CBC, Base); + + var keys = Object.keys(proto); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + CBC.prototype[key] = proto[key]; + } + + CBC.create = function create(options) { + return new CBC(options); + }; + + return CBC; +} + +exports.instantiate = instantiate; + +proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; +}; + +proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + + var iv = state.iv; + if (this.type === 'encrypt') { + for (var i = 0; i < this.blockSize; i++) + iv[i] ^= inp[inOff + i]; + + superProto._update.call(this, iv, 0, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + iv[i] = out[outOff + i]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + out[outOff + i] ^= iv[i]; + + for (var i = 0; i < this.blockSize; i++) + iv[i] = inp[inOff + i]; + } +}; - decryptBlock: function (M, offset) { - this._des3.decryptBlock(M, offset); - this._des2.encryptBlock(M, offset); - this._des1.decryptBlock(M, offset); - }, +},{"inherits":279,"minimalistic-assert":286}],209:[function(require,module,exports){ +'use strict'; - keySize: 192/32, +var assert = require('minimalistic-assert'); - ivSize: 64/32, +function Cipher(options) { + this.options = options; - blockSize: 64/32 - }); + this.type = this.options.type; + this.blockSize = 8; + this._init(); - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); - */ - C.TripleDES = BlockCipher._createHelper(TripleDES); - }()); + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; +} +module.exports = Cipher; +Cipher.prototype._init = function _init() { + // Might be overrided +}; - return CryptoJS.TripleDES; +Cipher.prototype.update = function update(data) { + if (data.length === 0) + return []; -})); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],203:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + if (this.type === 'decrypt') + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); +}; - (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var X32WordArray = C_lib.WordArray; +Cipher.prototype._buffer = function _buffer(data, off) { + // Append data to buffer + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i = 0; i < min; i++) + this.buffer[this.bufferOff + i] = data[off + i]; + this.bufferOff += min; - /** - * x64 namespace. - */ - var C_x64 = C.x64 = {}; + // Shift next + return min; +}; - /** - * A 64-bit word. - */ - var X64Word = C_x64.Word = Base.extend({ - /** - * Initializes a newly created 64-bit word. - * - * @param {number} high The high 32 bits. - * @param {number} low The low 32 bits. - * - * @example - * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); - */ - init: function (high, low) { - this.high = high; - this.low = low; - } +Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; +}; - /** - * Bitwise NOTs this word. - * - * @return {X64Word} A new x64-Word object after negating. - * - * @example - * - * var negated = x64Word.not(); - */ - // not: function () { - // var high = ~this.high; - // var low = ~this.low; +Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; - // return X64Word.create(high, low); - // }, + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; + var out = new Array(count * this.blockSize); - /** - * Bitwise ANDs this word with the passed word. - * - * @param {X64Word} word The x64-Word to AND with this word. - * - * @return {X64Word} A new x64-Word object after ANDing. - * - * @example - * - * var anded = x64Word.and(anotherX64Word); - */ - // and: function (word) { - // var high = this.high & word.high; - // var low = this.low & word.low; + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); - // return X64Word.create(high, low); - // }, + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } - /** - * Bitwise ORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to OR with this word. - * - * @return {X64Word} A new x64-Word object after ORing. - * - * @example - * - * var ored = x64Word.or(anotherX64Word); - */ - // or: function (word) { - // var high = this.high | word.high; - // var low = this.low | word.low; + // Write blocks + var max = data.length - ((data.length - inputOff) % this.blockSize); + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } - // return X64Word.create(high, low); - // }, + // Queue rest + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; - /** - * Bitwise XORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to XOR with this word. - * - * @return {X64Word} A new x64-Word object after XORing. - * - * @example - * - * var xored = x64Word.xor(anotherX64Word); - */ - // xor: function (word) { - // var high = this.high ^ word.high; - // var low = this.low ^ word.low; + return out; +}; - // return X64Word.create(high, low); - // }, +Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; - /** - * Shifts this word n bits to the left. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftL(25); - */ - // shiftL: function (n) { - // if (n < 32) { - // var high = (this.high << n) | (this.low >>> (32 - n)); - // var low = this.low << n; - // } else { - // var high = this.low << (n - 32); - // var low = 0; - // } + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); - // return X64Word.create(high, low); - // }, + // TODO(indutny): optimize it, this is far from optimal + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } - /** - * Shifts this word n bits to the right. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftR(7); - */ - // shiftR: function (n) { - // if (n < 32) { - // var low = (this.low >>> n) | (this.high << (32 - n)); - // var high = this.high >>> n; - // } else { - // var low = this.high >>> (n - 32); - // var high = 0; - // } + // Buffer rest of the input + inputOff += this._buffer(data, inputOff); - // return X64Word.create(high, low); - // }, + return out; +}; - /** - * Rotates this word n bits to the left. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotL(25); - */ - // rotL: function (n) { - // return this.shiftL(n).or(this.shiftR(64 - n)); - // }, +Cipher.prototype.final = function final(buffer) { + var first; + if (buffer) + first = this.update(buffer); - /** - * Rotates this word n bits to the right. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotR(7); - */ - // rotR: function (n) { - // return this.shiftR(n).or(this.shiftL(64 - n)); - // }, + var last; + if (this.type === 'encrypt') + last = this._finalEncrypt(); + else + last = this._finalDecrypt(); - /** - * Adds this word with the passed word. - * - * @param {X64Word} word The x64-Word to add with this word. - * - * @return {X64Word} A new x64-Word object after adding. - * - * @example - * - * var added = x64Word.add(anotherX64Word); - */ - // add: function (word) { - // var low = (this.low + word.low) | 0; - // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; - // var high = (this.high + word.high + carry) | 0; + if (first) + return first.concat(last); + else + return last; +}; - // return X64Word.create(high, low); - // } - }); +Cipher.prototype._pad = function _pad(buffer, off) { + if (off === 0) + return false; - /** - * An array of 64-bit words. - * - * @property {Array} words The array of CryptoJS.x64.Word objects. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var X64WordArray = C_x64.WordArray = Base.extend({ - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * var wordArray = CryptoJS.x64.WordArray.create(); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ]); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ], 10); - */ - init: function (words, sigBytes) { - words = this.words = words || []; + while (off < buffer.length) + buffer[off++] = 0; - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 8; - } - }, + return true; +}; - /** - * Converts this 64-bit word array to a 32-bit word array. - * - * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. - * - * @example - * - * var x32WordArray = x64WordArray.toX32(); - */ - toX32: function () { - // Shortcuts - var x64Words = this.words; - var x64WordsLength = x64Words.length; +Cipher.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; - // Convert - var x32Words = []; - for (var i = 0; i < x64WordsLength; i++) { - var x64Word = x64Words[i]; - x32Words.push(x64Word.high); - x32Words.push(x64Word.low); - } + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; +}; - return X32WordArray.create(x32Words, this.sigBytes); - }, +Cipher.prototype._unpad = function _unpad(buffer) { + return buffer; +}; - /** - * Creates a copy of this word array. - * - * @return {X64WordArray} The clone. - * - * @example - * - * var clone = x64WordArray.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); +Cipher.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); - // Clone "words" array - var words = clone.words = this.words.slice(0); + return this._unpad(out); +}; - // Clone each X64Word object - var wordsLength = words.length; - for (var i = 0; i < wordsLength; i++) { - words[i] = words[i].clone(); - } +},{"minimalistic-assert":286}],210:[function(require,module,exports){ +'use strict'; - return clone; - } - }); - }()); +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); +var utils = require('./utils'); +var Cipher = require('./cipher'); - return CryptoJS; +function DESState() { + this.tmp = new Array(2); + this.keys = null; +} -})); -},{"./core":172}],204:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ +function DES(options) { + Cipher.call(this, options); -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); + var state = new DESState(); + this._desState = state; -/** - * Colors. - */ + this.deriveKeys(state, options.key); +} +inherits(DES, Cipher); +module.exports = DES; -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' +DES.create = function create(options) { + return new DES(options); +}; + +var shiftTable = [ + 1, 1, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 1 ]; -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ +DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; + assert.equal(key.length, this.blockSize, 'Invalid key length'); + + var kL = utils.readUInt32BE(key, 0); + var kR = utils.readUInt32BE(key, 4); + + utils.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i = 0; i < state.keys.length; i += 2) { + var shift = shiftTable[i >>> 1]; + kL = utils.r28shl(kL, shift); + kR = utils.r28shl(kR, shift); + utils.pc2(kL, kR, state.keys, i); } +}; - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} +DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + var l = utils.readUInt32BE(inp, inOff); + var r = utils.readUInt32BE(inp, inOff + 4); + + // Initial Permutation + utils.ip(l, r, state.tmp, 0); + l = state.tmp[0]; + r = state.tmp[1]; + + if (this.type === 'encrypt') + this._encrypt(state, l, r, state.tmp, 0); + else + this._decrypt(state, l, r, state.tmp, 0); + + l = state.tmp[0]; + r = state.tmp[1]; -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } + utils.writeUInt32BE(out, l, outOff); + utils.writeUInt32BE(out, r, outOff + 4); }; +DES.prototype._pad = function _pad(buffer, off) { + var value = buffer.length - off; + for (var i = off; i < buffer.length; i++) + buffer[i] = value; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + return true; +}; -function formatArgs(args) { - var useColors = this.useColors; +DES.prototype._unpad = function _unpad(buffer) { + var pad = buffer[buffer.length - 1]; + for (var i = buffer.length - pad; i < buffer.length; i++) + assert.equal(buffer[i], pad); - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); + return buffer.slice(0, buffer.length - pad); +}; - if (!useColors) return; +DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l = lStart; + var r = rStart; - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') + // Apply f() x16 times + for (var i = 0; i < state.keys.length; i += 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + // f(r, k) + utils.expand(r, state.tmp, 0); - args.splice(lastC, 0, c); -} + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ + var t = r; + r = (l ^ f) >>> 0; + l = t; + } -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} + // Reverse Initial Permutation + utils.rip(r, l, out, off); +}; -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ +DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l = rStart; + var r = lStart; -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} + // Apply f() x16 times + for (var i = state.keys.length - 2; i >= 0; i -= 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ + // f(r, k) + utils.expand(l, state.tmp, 0); -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; + var t = l; + l = (r ^ f) >>> 0; + r = t; } - return r; -} + // Reverse Initial Permutation + utils.rip(l, r, out, off); +}; -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ +},{"./cipher":209,"./utils":212,"inherits":279,"minimalistic-assert":286}],211:[function(require,module,exports){ +'use strict'; -exports.enable(load()); +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ +var Cipher = require('./cipher'); +var DES = require('./des'); -function localstorage() { - try { - return window.localStorage; - } catch (e) {} +function EDEState(type, key) { + assert.equal(key.length, 24, 'Invalid key length'); + + var k1 = key.slice(0, 8); + var k2 = key.slice(8, 16); + var k3 = key.slice(16, 24); + + if (type === 'encrypt') { + this.ciphers = [ + DES.create({ type: 'encrypt', key: k1 }), + DES.create({ type: 'decrypt', key: k2 }), + DES.create({ type: 'encrypt', key: k3 }) + ]; + } else { + this.ciphers = [ + DES.create({ type: 'decrypt', key: k3 }), + DES.create({ type: 'encrypt', key: k2 }), + DES.create({ type: 'decrypt', key: k1 }) + ]; + } } -}).call(this,require('_process')) -},{"./debug":205,"_process":271}],205:[function(require,module,exports){ +function EDE(options) { + Cipher.call(this, options); -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ + var state = new EDEState(this.type, this.options.key); + this._edeState = state; +} +inherits(EDE, Cipher); -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); +module.exports = EDE; -/** - * The currently active debug mode names, and names to skip. - */ +EDE.create = function create(options) { + return new EDE(options); +}; -exports.names = []; -exports.skips = []; +EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); +}; -exports.formatters = {}; +EDE.prototype._pad = DES.prototype._pad; +EDE.prototype._unpad = DES.prototype._unpad; -/** - * Previous log timestamp. - */ +},{"./cipher":209,"./des":210,"inherits":279,"minimalistic-assert":286}],212:[function(require,module,exports){ +'use strict'; -var prevTime; +exports.readUInt32BE = function readUInt32BE(bytes, off) { + var res = (bytes[0 + off] << 24) | + (bytes[1 + off] << 16) | + (bytes[2 + off] << 8) | + bytes[3 + off]; + return res >>> 0; +}; -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ +exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { + bytes[0 + off] = value >>> 24; + bytes[1 + off] = (value >>> 16) & 0xff; + bytes[2 + off] = (value >>> 8) & 0xff; + bytes[3 + off] = value & 0xff; +}; -function selectColor(namespace) { - var hash = 0, i; +exports.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer + for (var i = 6; i >= 0; i -= 2) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } } - return exports.colors[Math.abs(hash) % exports.colors.length]; -} + for (var i = 6; i >= 0; i -= 2) { + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + } + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; -function createDebug(namespace) { +exports.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; - function debug() { - // disabled? - if (!debug.enabled) return; + for (var i = 0; i < 4; i++) { + for (var j = 24; j >= 0; j -= 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + for (var i = 4; i < 8; i++) { + for (var j = 24; j >= 0; j -= 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } - var self = debug; + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; +exports.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; + // 7, 15, 23, 31, 39, 47, 55, 63 + // 6, 14, 22, 30, 39, 47, 55, 63 + // 5, 13, 21, 29, 39, 47, 55, 63 + // 4, 12, 20, 28 + for (var i = 7; i >= 5; i--) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); + // 1, 9, 17, 25, 33, 41, 49, 57 + // 2, 10, 18, 26, 34, 42, 50, 58 + // 3, 11, 19, 27, 35, 43, 51, 59 + // 36, 44, 52, 60 + for (var i = 1; i <= 3; i++) { + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inR >> (j + i)) & 1; } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); +exports.r28shl = function r28shl(num, shift) { + return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); +}; - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); +var pc2table = [ + // inL => outL + 14, 11, 17, 4, 27, 23, 25, 0, + 13, 22, 7, 18, 5, 9, 16, 24, + 2, 20, 12, 21, 1, 8, 15, 26, - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); + // inR => outR + 15, 4, 25, 19, 9, 1, 26, 16, + 5, 11, 23, 8, 12, 7, 17, 0, + 22, 3, 10, 14, 6, 20, 27, 24 +]; + +exports.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + var len = pc2table.length >>> 1; + for (var i = 0; i < len; i++) { + outL <<= 1; + outL |= (inL >>> pc2table[i]) & 0x1; + } + for (var i = len; i < pc2table.length; i++) { + outR <<= 1; + outR |= (inR >>> pc2table[i]) & 0x1; } - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); +exports.expand = function expand(r, out, off) { + var outL = 0; + var outR = 0; + + outL = ((r & 1) << 5) | (r >>> 27); + for (var i = 23; i >= 15; i -= 4) { + outL <<= 6; + outL |= (r >>> i) & 0x3f; + } + for (var i = 11; i >= 3; i -= 4) { + outR |= (r >>> i) & 0x3f; + outR <<= 6; } + outR |= ((r & 0x1f) << 1) | (r >>> 31); - return debug; -} + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ +var sTable = [ + 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, + 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, + 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, + 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, -function enable(namespaces) { - exports.save(namespaces); + 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, + 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, + 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, + 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - exports.names = []; - exports.skips = []; + 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, + 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, + 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, + 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; + 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, + 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, + 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, + 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} + 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, + 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, + 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, + 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, -/** - * Disable debug output. - * - * @api public - */ + 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, + 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, + 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, + 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, -function disable() { - exports.enable(''); -} + 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, + 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, + 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, + 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ + 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, + 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, + 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, + 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 +]; + +exports.substitute = function substitute(inL, inR) { + var out = 0; + for (var i = 0; i < 4; i++) { + var b = (inL >>> (18 - i * 6)) & 0x3f; + var sb = sTable[i * 0x40 + b]; -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } + out <<= 4; + out |= sb; } - return false; -} + for (var i = 0; i < 4; i++) { + var b = (inR >>> (18 - i * 6)) & 0x3f; + var sb = sTable[4 * 0x40 + i * 0x40 + b]; -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ + out <<= 4; + out |= sb; + } + return out >>> 0; +}; -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} +var permuteTable = [ + 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, + 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 +]; -},{"ms":268}],206:[function(require,module,exports){ -'use strict'; +exports.permute = function permute(num) { + var out = 0; + for (var i = 0; i < permuteTable.length; i++) { + out <<= 1; + out |= (num >>> permuteTable[i]) & 0x1; + } + return out >>> 0; +}; -exports.utils = require('./des/utils'); -exports.Cipher = require('./des/cipher'); -exports.DES = require('./des/des'); -exports.CBC = require('./des/cbc'); -exports.EDE = require('./des/ede'); +exports.padSplit = function padSplit(num, size, group) { + var str = num.toString(2); + while (str.length < size) + str = '0' + str; -},{"./des/cbc":207,"./des/cipher":208,"./des/des":209,"./des/ede":210,"./des/utils":211}],207:[function(require,module,exports){ -'use strict'; + var out = []; + for (var i = 0; i < size; i += group) + out.push(str.slice(i, i + group)); + return out.join(' '); +}; -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); +},{}],213:[function(require,module,exports){ +(function (Buffer){(function (){ +var generatePrime = require('./lib/generatePrime') +var primes = require('./lib/primes.json') -var proto = {}; +var DH = require('./lib/dh') -function CBCState(iv) { - assert.equal(iv.length, 8, 'Invalid IV length'); +function getDiffieHellman (mod) { + var prime = new Buffer(primes[mod].prime, 'hex') + var gen = new Buffer(primes[mod].gen, 'hex') - this.iv = new Array(8); - for (var i = 0; i < this.iv.length; i++) - this.iv[i] = iv[i]; + return new DH(prime, gen) } -function instantiate(Base) { - function CBC(options) { - Base.call(this, options); - this._cbcInit(); - } - inherits(CBC, Base); +var ENCODINGS = { + 'binary': true, 'hex': true, 'base64': true +} - var keys = Object.keys(proto); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - CBC.prototype[key] = proto[key]; +function createDiffieHellman (prime, enc, generator, genc) { + if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { + return createDiffieHellman(prime, 'binary', enc, generator) } - CBC.create = function create(options) { - return new CBC(options); - }; - - return CBC; -} - -exports.instantiate = instantiate; + enc = enc || 'binary' + genc = genc || 'binary' + generator = generator || new Buffer([2]) -proto._cbcInit = function _cbcInit() { - var state = new CBCState(this.options.iv); - this._cbcState = state; -}; + if (!Buffer.isBuffer(generator)) { + generator = new Buffer(generator, genc) + } -proto._update = function _update(inp, inOff, out, outOff) { - var state = this._cbcState; - var superProto = this.constructor.super_.prototype; + if (typeof prime === 'number') { + return new DH(generatePrime(prime, generator), generator, true) + } - var iv = state.iv; - if (this.type === 'encrypt') { - for (var i = 0; i < this.blockSize; i++) - iv[i] ^= inp[inOff + i]; + if (!Buffer.isBuffer(prime)) { + prime = new Buffer(prime, enc) + } - superProto._update.call(this, iv, 0, out, outOff); + return new DH(prime, generator, true) +} - for (var i = 0; i < this.blockSize; i++) - iv[i] = out[outOff + i]; - } else { - superProto._update.call(this, inp, inOff, out, outOff); +exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman +exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman - for (var i = 0; i < this.blockSize; i++) - out[outOff + i] ^= iv[i]; +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/dh":214,"./lib/generatePrime":215,"./lib/primes.json":216,"buffer":130}],214:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js'); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var TWENTYFOUR = new BN(24); +var ELEVEN = new BN(11); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var primes = require('./generatePrime'); +var randomBytes = require('randombytes'); +module.exports = DH; - for (var i = 0; i < this.blockSize; i++) - iv[i] = inp[inOff + i]; +function setPublicKey(pub, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc); } -}; + this._pub = new BN(pub); + return this; +} -},{"inherits":259,"minimalistic-assert":266}],208:[function(require,module,exports){ -'use strict'; +function setPrivateKey(priv, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc); + } + this._priv = new BN(priv); + return this; +} -var assert = require('minimalistic-assert'); +var primeCache = {}; +function checkPrime(prime, generator) { + var gen = generator.toString('hex'); + var hex = [gen, prime.toString(16)].join('_'); + if (hex in primeCache) { + return primeCache[hex]; + } + var error = 0; -function Cipher(options) { - this.options = options; + if (prime.isEven() || + !primes.simpleSieve || + !primes.fermatTest(prime) || + !millerRabin.test(prime)) { + //not a prime so +1 + error += 1; - this.type = this.options.type; - this.blockSize = 8; - this._init(); + if (gen === '02' || gen === '05') { + // we'd be able to check the generator + // it would fail so +8 + error += 8; + } else { + //we wouldn't be able to test the generator + // so +4 + error += 4; + } + primeCache[hex] = error; + return error; + } + if (!millerRabin.test(prime.shrn(1))) { + //not a safe prime + error += 2; + } + var rem; + switch (gen) { + case '02': + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + // unsuidable generator + error += 8; + } + break; + case '05': + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + // prime mod 10 needs to equal 3 or 7 + error += 8; + } + break; + default: + error += 4; + } + primeCache[hex] = error; + return error; +} - this.buffer = new Array(this.blockSize); - this.bufferOff = 0; +function DH(prime, generator, malleable) { + this.setGenerator(generator); + this.__prime = new BN(prime); + this._prime = BN.mont(this.__prime); + this._primeLen = prime.length; + this._pub = undefined; + this._priv = undefined; + this._primeCode = undefined; + if (malleable) { + this.setPublicKey = setPublicKey; + this.setPrivateKey = setPrivateKey; + } else { + this._primeCode = 8; + } } -module.exports = Cipher; +Object.defineProperty(DH.prototype, 'verifyError', { + enumerable: true, + get: function () { + if (typeof this._primeCode !== 'number') { + this._primeCode = checkPrime(this.__prime, this.__gen); + } + return this._primeCode; + } +}); +DH.prototype.generateKeys = function () { + if (!this._priv) { + this._priv = new BN(randomBytes(this._primeLen)); + } + this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); + return this.getPublicKey(); +}; -Cipher.prototype._init = function _init() { - // Might be overrided +DH.prototype.computeSecret = function (other) { + other = new BN(other); + other = other.toRed(this._prime); + var secret = other.redPow(this._priv).fromRed(); + var out = new Buffer(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer(prime.length - out.length); + front.fill(0); + out = Buffer.concat([front, out]); + } + return out; }; -Cipher.prototype.update = function update(data) { - if (data.length === 0) - return []; +DH.prototype.getPublicKey = function getPublicKey(enc) { + return formatReturnValue(this._pub, enc); +}; - if (this.type === 'decrypt') - return this._updateDecrypt(data); - else - return this._updateEncrypt(data); +DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue(this._priv, enc); }; -Cipher.prototype._buffer = function _buffer(data, off) { - // Append data to buffer - var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); - for (var i = 0; i < min; i++) - this.buffer[this.bufferOff + i] = data[off + i]; - this.bufferOff += min; +DH.prototype.getPrime = function (enc) { + return formatReturnValue(this.__prime, enc); +}; - // Shift next - return min; +DH.prototype.getGenerator = function (enc) { + return formatReturnValue(this._gen, enc); }; -Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { - this._update(this.buffer, 0, out, off); - this.bufferOff = 0; - return this.blockSize; +DH.prototype.setGenerator = function (gen, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(gen)) { + gen = new Buffer(gen, enc); + } + this.__gen = gen; + this._gen = new BN(gen); + return this; }; -Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { - var inputOff = 0; - var outputOff = 0; +function formatReturnValue(bn, enc) { + var buf = new Buffer(bn.toArray()); + if (!enc) { + return buf; + } else { + return buf.toString(enc); + } +} - var count = ((this.bufferOff + data.length) / this.blockSize) | 0; - var out = new Array(count * this.blockSize); +}).call(this)}).call(this,require("buffer").Buffer) +},{"./generatePrime":215,"bn.js":90,"buffer":130,"miller-rabin":285,"randombytes":327}],215:[function(require,module,exports){ +var randomBytes = require('randombytes'); +module.exports = findPrime; +findPrime.simpleSieve = simpleSieve; +findPrime.fermatTest = fermatTest; +var BN = require('bn.js'); +var TWENTYFOUR = new BN(24); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var ONE = new BN(1); +var TWO = new BN(2); +var FIVE = new BN(5); +var SIXTEEN = new BN(16); +var EIGHT = new BN(8); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var ELEVEN = new BN(11); +var FOUR = new BN(4); +var TWELVE = new BN(12); +var primes = null; - if (this.bufferOff !== 0) { - inputOff += this._buffer(data, inputOff); +function _getPrimes() { + if (primes !== null) + return primes; - if (this.bufferOff === this.buffer.length) - outputOff += this._flushBuffer(out, outputOff); - } + var limit = 0x100000; + var res = []; + res[0] = 2; + for (var i = 1, k = 3; k < limit; k += 2) { + var sqrt = Math.ceil(Math.sqrt(k)); + for (var j = 0; j < i && res[j] <= sqrt; j++) + if (k % res[j] === 0) + break; - // Write blocks - var max = data.length - ((data.length - inputOff) % this.blockSize); - for (; inputOff < max; inputOff += this.blockSize) { - this._update(data, inputOff, out, outputOff); - outputOff += this.blockSize; + if (i !== j && res[j] <= sqrt) + continue; + + res[i++] = k; } + primes = res; + return res; +} - // Queue rest - for (; inputOff < data.length; inputOff++, this.bufferOff++) - this.buffer[this.bufferOff] = data[inputOff]; +function simpleSieve(p) { + var primes = _getPrimes(); - return out; -}; + for (var i = 0; i < primes.length; i++) + if (p.modn(primes[i]) === 0) { + if (p.cmpn(primes[i]) === 0) { + return true; + } else { + return false; + } + } -Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { - var inputOff = 0; - var outputOff = 0; + return true; +} - var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; - var out = new Array(count * this.blockSize); +function fermatTest(p) { + var red = BN.mont(p); + return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; +} - // TODO(indutny): optimize it, this is far from optimal - for (; count > 0; count--) { - inputOff += this._buffer(data, inputOff); - outputOff += this._flushBuffer(out, outputOff); +function findPrime(bits, gen) { + if (bits < 16) { + // this is what openssl does + if (gen === 2 || gen === 5) { + return new BN([0x8c, 0x7b]); + } else { + return new BN([0x8c, 0x27]); + } } + gen = new BN(gen); - // Buffer rest of the input - inputOff += this._buffer(data, inputOff); + var num, n2; - return out; -}; + while (true) { + num = new BN(randomBytes(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n2 = num.shrn(1); + if (simpleSieve(n2) && simpleSieve(num) && + fermatTest(n2) && fermatTest(num) && + millerRabin.test(n2) && millerRabin.test(num)) { + return num; + } + } -Cipher.prototype.final = function final(buffer) { - var first; - if (buffer) - first = this.update(buffer); +} - var last; - if (this.type === 'encrypt') - last = this._finalEncrypt(); - else - last = this._finalDecrypt(); +},{"bn.js":90,"miller-rabin":285,"randombytes":327}],216:[function(require,module,exports){ +module.exports={ + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } +} +},{}],217:[function(require,module,exports){ +var assert = require('assert') +var BigInteger = require('bigi') - if (first) - return first.concat(last); - else - return last; -}; +var Point = require('./point') -Cipher.prototype._pad = function _pad(buffer, off) { - if (off === 0) - return false; +function Curve (p, a, b, Gx, Gy, n, h) { + this.p = p + this.a = a + this.b = b + this.G = Point.fromAffine(this, Gx, Gy) + this.n = n + this.h = h - while (off < buffer.length) - buffer[off++] = 0; + this.infinity = new Point(this, null, null, BigInteger.ZERO) - return true; -}; + // result caching + this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) + + // determine size of p in bytes + this.pLength = Math.floor((this.p.bitLength() + 7) / 8) +} -Cipher.prototype._finalEncrypt = function _finalEncrypt() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; +Curve.prototype.pointFromX = function (isOdd, x) { + var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) + var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves - var out = new Array(this.blockSize); - this._update(this.buffer, 0, out, 0); - return out; -}; + var y = beta + if (beta.isEven() ^ !isOdd) { + y = this.p.subtract(y) // -y % p + } -Cipher.prototype._unpad = function _unpad(buffer) { - return buffer; -}; + return Point.fromAffine(this, x, y) +} -Cipher.prototype._finalDecrypt = function _finalDecrypt() { - assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); - var out = new Array(this.blockSize); - this._flushBuffer(out, 0); +Curve.prototype.isInfinity = function (Q) { + if (Q === this.infinity) return true - return this._unpad(out); -}; + return Q.z.signum() === 0 && Q.y.signum() !== 0 +} -},{"minimalistic-assert":266}],209:[function(require,module,exports){ -'use strict'; +Curve.prototype.isOnCurve = function (Q) { + if (this.isInfinity(Q)) return true -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); + var x = Q.affineX + var y = Q.affineY + var a = this.a + var b = this.b + var p = this.p -var des = require('../des'); -var utils = des.utils; -var Cipher = des.Cipher; + // Check that xQ and yQ are integers in the interval [0, p - 1] + if (x.signum() < 0 || x.compareTo(p) >= 0) return false + if (y.signum() < 0 || y.compareTo(p) >= 0) return false -function DESState() { - this.tmp = new Array(2); - this.keys = null; + // and check that y^2 = x^3 + ax + b (mod p) + var lhs = y.square().mod(p) + var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) + return lhs.equals(rhs) } -function DES(options) { - Cipher.call(this, options); +/** + * Validate an elliptic curve point. + * + * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive + */ +Curve.prototype.validate = function (Q) { + // Check Q != O + assert(!this.isInfinity(Q), 'Point is at infinity') + assert(this.isOnCurve(Q), 'Point is not on the curve') - var state = new DESState(); - this._desState = state; + // Check nQ = O (where Q is a scalar multiple of G) + var nQ = Q.multiply(this.n) + assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') - this.deriveKeys(state, options.key); + return true } -inherits(DES, Cipher); -module.exports = DES; -DES.create = function create(options) { - return new DES(options); -}; - -var shiftTable = [ - 1, 1, 2, 2, 2, 2, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 1 -]; +module.exports = Curve -DES.prototype.deriveKeys = function deriveKeys(state, key) { - state.keys = new Array(16 * 2); +},{"./point":221,"assert":24,"bigi":34}],218:[function(require,module,exports){ +module.exports={ + "secp128r1": { + "p": "fffffffdffffffffffffffffffffffff", + "a": "fffffffdfffffffffffffffffffffffc", + "b": "e87579c11079f43dd824993c2cee5ed3", + "n": "fffffffe0000000075a30d1b9038a115", + "h": "01", + "Gx": "161ff7528b899b2d0c28607ca52c5b86", + "Gy": "cf5ac8395bafeb13c02da292dded7a83" + }, + "secp160k1": { + "p": "fffffffffffffffffffffffffffffffeffffac73", + "a": "00", + "b": "07", + "n": "0100000000000000000001b8fa16dfab9aca16b6b3", + "h": "01", + "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", + "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" + }, + "secp160r1": { + "p": "ffffffffffffffffffffffffffffffff7fffffff", + "a": "ffffffffffffffffffffffffffffffff7ffffffc", + "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", + "n": "0100000000000000000001f4c8f927aed3ca752257", + "h": "01", + "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", + "Gy": "23a628553168947d59dcc912042351377ac5fb32" + }, + "secp192k1": { + "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", + "a": "00", + "b": "03", + "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", + "h": "01", + "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", + "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" + }, + "secp192r1": { + "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", + "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", + "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", + "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", + "h": "01", + "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", + "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" + }, + "secp256k1": { + "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", + "a": "00", + "b": "07", + "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", + "h": "01", + "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" + }, + "secp256r1": { + "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", + "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", + "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", + "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", + "h": "01", + "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", + "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" + } +} - assert.equal(key.length, this.blockSize, 'Invalid key length'); +},{}],219:[function(require,module,exports){ +var Point = require('./point') +var Curve = require('./curve') - var kL = utils.readUInt32BE(key, 0); - var kR = utils.readUInt32BE(key, 4); +var getCurveByName = require('./names') - utils.pc1(kL, kR, state.tmp, 0); - kL = state.tmp[0]; - kR = state.tmp[1]; - for (var i = 0; i < state.keys.length; i += 2) { - var shift = shiftTable[i >>> 1]; - kL = utils.r28shl(kL, shift); - kR = utils.r28shl(kR, shift); - utils.pc2(kL, kR, state.keys, i); - } -}; +module.exports = { + Curve: Curve, + Point: Point, + getCurveByName: getCurveByName +} -DES.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._desState; +},{"./curve":217,"./names":220,"./point":221}],220:[function(require,module,exports){ +var BigInteger = require('bigi') - var l = utils.readUInt32BE(inp, inOff); - var r = utils.readUInt32BE(inp, inOff + 4); +var curves = require('./curves.json') +var Curve = require('./curve') - // Initial Permutation - utils.ip(l, r, state.tmp, 0); - l = state.tmp[0]; - r = state.tmp[1]; +function getCurveByName (name) { + var curve = curves[name] + if (!curve) return null - if (this.type === 'encrypt') - this._encrypt(state, l, r, state.tmp, 0); - else - this._decrypt(state, l, r, state.tmp, 0); + var p = new BigInteger(curve.p, 16) + var a = new BigInteger(curve.a, 16) + var b = new BigInteger(curve.b, 16) + var n = new BigInteger(curve.n, 16) + var h = new BigInteger(curve.h, 16) + var Gx = new BigInteger(curve.Gx, 16) + var Gy = new BigInteger(curve.Gy, 16) - l = state.tmp[0]; - r = state.tmp[1]; + return new Curve(p, a, b, Gx, Gy, n, h) +} - utils.writeUInt32BE(out, l, outOff); - utils.writeUInt32BE(out, r, outOff + 4); -}; +module.exports = getCurveByName -DES.prototype._pad = function _pad(buffer, off) { - var value = buffer.length - off; - for (var i = off; i < buffer.length; i++) - buffer[i] = value; +},{"./curve":217,"./curves.json":218,"bigi":34}],221:[function(require,module,exports){ +var assert = require('assert') +var Buffer = require('safe-buffer').Buffer +var BigInteger = require('bigi') - return true; -}; +var THREE = BigInteger.valueOf(3) -DES.prototype._unpad = function _unpad(buffer) { - var pad = buffer[buffer.length - 1]; - for (var i = buffer.length - pad; i < buffer.length; i++) - assert.equal(buffer[i], pad); +function Point (curve, x, y, z) { + assert.notStrictEqual(z, undefined, 'Missing Z coordinate') - return buffer.slice(0, buffer.length - pad); -}; + this.curve = curve + this.x = x + this.y = y + this.z = z + this._zInv = null -DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { - var l = lStart; - var r = rStart; + this.compressed = true +} - // Apply f() x16 times - for (var i = 0; i < state.keys.length; i += 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; +Object.defineProperty(Point.prototype, 'zInv', { + get: function () { + if (this._zInv === null) { + this._zInv = this.z.modInverse(this.curve.p) + } - // f(r, k) - utils.expand(r, state.tmp, 0); + return this._zInv + } +}) - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); +Object.defineProperty(Point.prototype, 'affineX', { + get: function () { + return this.x.multiply(this.zInv).mod(this.curve.p) + } +}) - var t = r; - r = (l ^ f) >>> 0; - l = t; +Object.defineProperty(Point.prototype, 'affineY', { + get: function () { + return this.y.multiply(this.zInv).mod(this.curve.p) } +}) - // Reverse Initial Permutation - utils.rip(r, l, out, off); -}; +Point.fromAffine = function (curve, x, y) { + return new Point(curve, x, y, BigInteger.ONE) +} -DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { - var l = rStart; - var r = lStart; +Point.prototype.equals = function (other) { + if (other === this) return true + if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) + if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) - // Apply f() x16 times - for (var i = state.keys.length - 2; i >= 0; i -= 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; + // u = Y2 * Z1 - Y1 * Z2 + var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) - // f(r, k) - utils.expand(l, state.tmp, 0); + if (u.signum() !== 0) return false - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); + // v = X2 * Z1 - X1 * Z2 + var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) - var t = l; - l = (r ^ f) >>> 0; - r = t; - } + return v.signum() === 0 +} - // Reverse Initial Permutation - utils.rip(l, r, out, off); -}; +Point.prototype.negate = function () { + var y = this.curve.p.subtract(this.y) -},{"../des":206,"inherits":259,"minimalistic-assert":266}],210:[function(require,module,exports){ -'use strict'; + return new Point(this.curve, this.x, y, this.z) +} -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); +Point.prototype.add = function (b) { + if (this.curve.isInfinity(this)) return b + if (this.curve.isInfinity(b)) return this -var des = require('../des'); -var Cipher = des.Cipher; -var DES = des.DES; + var x1 = this.x + var y1 = this.y + var x2 = b.x + var y2 = b.y -function EDEState(type, key) { - assert.equal(key.length, 24, 'Invalid key length'); + // u = Y2 * Z1 - Y1 * Z2 + var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) + // v = X2 * Z1 - X1 * Z2 + var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) - var k1 = key.slice(0, 8); - var k2 = key.slice(8, 16); - var k3 = key.slice(16, 24); + if (v.signum() === 0) { + if (u.signum() === 0) { + return this.twice() // this == b, so double + } - if (type === 'encrypt') { - this.ciphers = [ - DES.create({ type: 'encrypt', key: k1 }), - DES.create({ type: 'decrypt', key: k2 }), - DES.create({ type: 'encrypt', key: k3 }) - ]; - } else { - this.ciphers = [ - DES.create({ type: 'decrypt', key: k3 }), - DES.create({ type: 'encrypt', key: k2 }), - DES.create({ type: 'decrypt', key: k1 }) - ]; + return this.curve.infinity // this = -b, so infinity } -} -function EDE(options) { - Cipher.call(this, options); + var v2 = v.square() + var v3 = v2.multiply(v) + var x1v2 = x1.multiply(v2) + var zu2 = u.square().multiply(this.z) - var state = new EDEState(this.type, this.options.key); - this._edeState = state; -} -inherits(EDE, Cipher); + // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) + var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) + // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 + var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) + // z3 = v^3 * z1 * z2 + var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) -module.exports = EDE; + return new Point(this.curve, x3, y3, z3) +} -EDE.create = function create(options) { - return new EDE(options); -}; +Point.prototype.twice = function () { + if (this.curve.isInfinity(this)) return this + if (this.y.signum() === 0) return this.curve.infinity -EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; + var x1 = this.x + var y1 = this.y - state.ciphers[0]._update(inp, inOff, out, outOff); - state.ciphers[1]._update(out, outOff, out, outOff); - state.ciphers[2]._update(out, outOff, out, outOff); -}; + var y1z1 = y1.multiply(this.z).mod(this.curve.p) + var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) + var a = this.curve.a -EDE.prototype._pad = DES.prototype._pad; -EDE.prototype._unpad = DES.prototype._unpad; + // w = 3 * x1^2 + a * z1^2 + var w = x1.square().multiply(THREE) -},{"../des":206,"inherits":259,"minimalistic-assert":266}],211:[function(require,module,exports){ -'use strict'; + if (a.signum() !== 0) { + w = w.add(this.z.square().multiply(a)) + } -exports.readUInt32BE = function readUInt32BE(bytes, off) { - var res = (bytes[0 + off] << 24) | - (bytes[1 + off] << 16) | - (bytes[2 + off] << 8) | - bytes[3 + off]; - return res >>> 0; -}; + w = w.mod(this.curve.p) + // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) + var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) + // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 + var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) + // z3 = 8 * (y1 * z1)^3 + var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) -exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { - bytes[0 + off] = value >>> 24; - bytes[1 + off] = (value >>> 16) & 0xff; - bytes[2 + off] = (value >>> 8) & 0xff; - bytes[3 + off] = value & 0xff; -}; + return new Point(this.curve, x3, y3, z3) +} -exports.ip = function ip(inL, inR, out, off) { - var outL = 0; - var outR = 0; +// Simple NAF (Non-Adjacent Form) multiplication algorithm +// TODO: modularize the multiplication algorithm +Point.prototype.multiply = function (k) { + if (this.curve.isInfinity(this)) return this + if (k.signum() === 0) return this.curve.infinity - for (var i = 6; i >= 0; i -= 2) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } + var e = k + var h = e.multiply(THREE) - for (var i = 6; i >= 0; i -= 2) { - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - } - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } + var neg = this.negate() + var R = this - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + for (var i = h.bitLength() - 2; i > 0; --i) { + var hBit = h.testBit(i) + var eBit = e.testBit(i) -exports.rip = function rip(inL, inR, out, off) { - var outL = 0; - var outR = 0; + R = R.twice() - for (var i = 0; i < 4; i++) { - for (var j = 24; j >= 0; j -= 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - for (var i = 4; i < 8; i++) { - for (var j = 24; j >= 0; j -= 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; + if (hBit !== eBit) { + R = R.add(hBit ? this : neg) } } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + return R +} -exports.pc1 = function pc1(inL, inR, out, off) { - var outL = 0; - var outR = 0; +// Compute this*j + x*k (simultaneous multiplication) +Point.prototype.multiplyTwo = function (j, x, k) { + var i = Math.max(j.bitLength(), k.bitLength()) - 1 + var R = this.curve.infinity + var both = this.add(x) - // 7, 15, 23, 31, 39, 47, 55, 63 - // 6, 14, 22, 30, 39, 47, 55, 63 - // 5, 13, 21, 29, 39, 47, 55, 63 - // 4, 12, 20, 28 - for (var i = 7; i >= 5; i--) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } + while (i >= 0) { + var jBit = j.testBit(i) + var kBit = k.testBit(i) - // 1, 9, 17, 25, 33, 41, 49, 57 - // 2, 10, 18, 26, 34, 42, 50, 58 - // 3, 11, 19, 27, 35, 43, 51, 59 - // 36, 44, 52, 60 - for (var i = 1; i <= 3; i++) { - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; + R = R.twice() + + if (jBit) { + if (kBit) { + R = R.add(both) + } else { + R = R.add(this) + } + } else if (kBit) { + R = R.add(x) } - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; + --i } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + return R +} -exports.r28shl = function r28shl(num, shift) { - return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); -}; +Point.prototype.getEncoded = function (compressed) { + if (compressed == null) compressed = this.compressed + if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' -var pc2table = [ - // inL => outL - 14, 11, 17, 4, 27, 23, 25, 0, - 13, 22, 7, 18, 5, 9, 16, 24, - 2, 20, 12, 21, 1, 8, 15, 26, + var x = this.affineX + var y = this.affineY + var byteLength = this.curve.pLength + var buffer - // inR => outR - 15, 4, 25, 19, 9, 1, 26, 16, - 5, 11, 23, 8, 12, 7, 17, 0, - 22, 3, 10, 14, 6, 20, 27, 24 -]; + // 0x02/0x03 | X + if (compressed) { + buffer = Buffer.allocUnsafe(1 + byteLength) + buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) -exports.pc2 = function pc2(inL, inR, out, off) { - var outL = 0; - var outR = 0; + // 0x04 | X | Y + } else { + buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) + buffer.writeUInt8(0x04, 0) - var len = pc2table.length >>> 1; - for (var i = 0; i < len; i++) { - outL <<= 1; - outL |= (inL >>> pc2table[i]) & 0x1; - } - for (var i = len; i < pc2table.length; i++) { - outR <<= 1; - outR |= (inR >>> pc2table[i]) & 0x1; + y.toBuffer(byteLength).copy(buffer, 1 + byteLength) } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + x.toBuffer(byteLength).copy(buffer, 1) -exports.expand = function expand(r, out, off) { - var outL = 0; - var outR = 0; + return buffer +} - outL = ((r & 1) << 5) | (r >>> 27); - for (var i = 23; i >= 15; i -= 4) { - outL <<= 6; - outL |= (r >>> i) & 0x3f; - } - for (var i = 11; i >= 3; i -= 4) { - outR |= (r >>> i) & 0x3f; - outR <<= 6; - } - outR |= ((r & 0x1f) << 1) | (r >>> 31); +Point.decodeFrom = function (curve, buffer) { + var type = buffer.readUInt8(0) + var compressed = (type !== 4) - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) + var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) -var sTable = [ - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, + var Q + if (compressed) { + assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') + assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, + var isOdd = (type === 0x03) + Q = curve.pointFromX(isOdd, x) + } else { + assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, + var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) + Q = Point.fromAffine(curve, x, y) + } - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, + Q.compressed = compressed + return Q +} - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, +Point.prototype.toString = function () { + if (this.curve.isInfinity(this)) return '(INFINITY)' - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, + return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' +} - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, +module.exports = Point - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 -]; +},{"assert":24,"bigi":34,"safe-buffer":345}],222:[function(require,module,exports){ +'use strict'; -exports.substitute = function substitute(inL, inR) { - var out = 0; - for (var i = 0; i < 4; i++) { - var b = (inL >>> (18 - i * 6)) & 0x3f; - var sb = sTable[i * 0x40 + b]; +var elliptic = exports; - out <<= 4; - out |= sb; - } - for (var i = 0; i < 4; i++) { - var b = (inR >>> (18 - i * 6)) & 0x3f; - var sb = sTable[4 * 0x40 + i * 0x40 + b]; +elliptic.version = require('../package.json').version; +elliptic.utils = require('./elliptic/utils'); +elliptic.rand = require('brorand'); +elliptic.curve = require('./elliptic/curve'); +elliptic.curves = require('./elliptic/curves'); - out <<= 4; - out |= sb; - } - return out >>> 0; -}; +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); -var permuteTable = [ - 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, - 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 -]; +},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,"brorand":103}],223:[function(require,module,exports){ +'use strict'; -exports.permute = function permute(num) { - var out = 0; - for (var i = 0; i < permuteTable.length; i++) { - out <<= 1; - out |= (num >>> permuteTable[i]) & 0x1; - } - return out >>> 0; -}; +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; -exports.padSplit = function padSplit(num, size, group) { - var str = num.toString(2); - while (str.length < size) - str = '0' + str; +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - var out = []; - for (var i = 0; i < size; i += group) - out.push(str.slice(i, i + group)); - return out.join(' '); -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -},{}],212:[function(require,module,exports){ -(function (Buffer){ -var generatePrime = require('./lib/generatePrime') -var primes = require('./lib/primes.json') + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); -var DH = require('./lib/dh') + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); -function getDiffieHellman (mod) { - var prime = new Buffer(primes[mod].prime, 'hex') - var gen = new Buffer(primes[mod].gen, 'hex') + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); - return new DH(prime, gen) -} + this._bitLength = this.n ? this.n.bitLength() : 0; -var ENCODINGS = { - 'binary': true, 'hex': true, 'base64': true + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } } +module.exports = BaseCurve; -function createDiffieHellman (prime, enc, generator, genc) { - if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { - return createDiffieHellman(prime, 'binary', enc, generator) - } +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; - enc = enc || 'binary' - genc = genc || 'binary' - generator = generator || new Buffer([2]) +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; - if (!Buffer.isBuffer(generator)) { - generator = new Buffer(generator, genc) - } +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); - if (typeof prime === 'number') { - return new DH(generatePrime(prime, generator), generator, true) + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + var j; + var nafW; + for (j = 0; j < naf.length; j += doubles.step) { + nafW = 0; + for (var l = j + doubles.step - 1; l >= j; l--) + nafW = (nafW << 1) + naf[l]; + repr.push(nafW); } - if (!Buffer.isBuffer(prime)) { - prime = new Buffer(prime, enc) + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (j = 0; j < repr.length; j++) { + nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); } + return a.toP(); +}; - return new DH(prime, generator, true) -} +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; -exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman -exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; -}).call(this,require("buffer").Buffer) -},{"./lib/dh":213,"./lib/generatePrime":214,"./lib/primes.json":215,"buffer":131}],213:[function(require,module,exports){ -(function (Buffer){ -var BN = require('bn.js'); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var TWENTYFOUR = new BN(24); -var ELEVEN = new BN(11); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var primes = require('./generatePrime'); -var randomBytes = require('randombytes'); -module.exports = DH; + // Get NAF form + var naf = getNAF(k, w, this._bitLength); -function setPublicKey(pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this._pub = new BN(pub); - return this; -} + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var l = 0; i >= 0 && naf[i] === 0; i--) + l++; + if (i >= 0) + l++; + acc = acc.dblp(l); -function setPrivateKey(priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } } - this._priv = new BN(priv); - return this; -} + return p.type === 'affine' ? acc.toP() : acc; +}; -var primeCache = {}; -function checkPrime(prime, generator) { - var gen = generator.toString('hex'); - var hex = [gen, prime.toString(16)].join('_'); - if (hex in primeCache) { - return primeCache[hex]; +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + var i; + var j; + var p; + for (i = 0; i < len; i++) { + p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; } - var error = 0; - if (prime.isEven() || - !primes.simpleSieve || - !primes.fermatTest(prime) || - !millerRabin.test(prime)) { - //not a prime so +1 - error += 1; + // Comb small window NAFs + for (i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); + naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } - if (gen === '02' || gen === '05') { - // we'd be able to check the generator - // it would fail so +8 - error += 8; + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); } else { - //we wouldn't be able to test the generator - // so +4 - error += 4; + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3, /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; } - primeCache[hex] = error; - return error; - } - if (!millerRabin.test(prime.shrn(1))) { - //not a safe prime - error += 2; } - var rem; - switch (gen) { - case '02': - if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { - // unsuidable generator - error += 8; - } - break; - case '05': - rem = prime.mod(TEN); - if (rem.cmp(THREE) && rem.cmp(SEVEN)) { - // prime mod 10 needs to equal 3 or 7 - error += 8; + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) break; - default: - error += 4; - } - primeCache[hex] = error; - return error; -} -function DH(prime, generator, malleable) { - this.setGenerator(generator); - this.__prime = new BN(prime); - this._prime = BN.mont(this.__prime); - this._primeLen = prime.length; - this._pub = undefined; - this._priv = undefined; - this._primeCode = undefined; - if (malleable) { - this.setPublicKey = setPublicKey; - this.setPrivateKey = setPrivateKey; - } else { - this._primeCode = 8; - } -} -Object.defineProperty(DH.prototype, 'verifyError', { - enumerable: true, - get: function () { - if (typeof this._primeCode !== 'number') { - this._primeCode = checkPrime(this.__prime, this.__gen); + for (j = 0; j < len; j++) { + var z = tmp[j]; + p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); } - return this._primeCode; } -}); -DH.prototype.generateKeys = function () { - if (!this._priv) { - this._priv = new BN(randomBytes(this._primeLen)); + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); } - this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); - return this.getPublicKey(); + throw new Error('Unknown point format'); }; -DH.prototype.computeSecret = function (other) { - other = new BN(other); - other = other.toRed(this._prime); - var secret = other.redPow(this._priv).fromRed(); - var out = new Buffer(secret.toArray()); - var prime = this.getPrime(); - if (out.length < prime.length) { - var front = new Buffer(prime.length - out.length); - front.fill(0); - out = Buffer.concat([front, out]); - } - return out; +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); }; -DH.prototype.getPublicKey = function getPublicKey(enc) { - return formatReturnValue(this._pub, enc); +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); }; -DH.prototype.getPrivateKey = function getPrivateKey(enc) { - return formatReturnValue(this._priv, enc); +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); }; -DH.prototype.getPrime = function (enc) { - return formatReturnValue(this.__prime, enc); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null, + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; }; -DH.prototype.getGenerator = function (enc) { - return formatReturnValue(this._gen, enc); +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -DH.prototype.setGenerator = function (gen, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(gen)) { - gen = new Buffer(gen, enc); +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); } - this.__gen = gen; - this._gen = new BN(gen); - return this; + return { + step: step, + points: doubles, + }; }; -function formatReturnValue(bn, enc) { - var buf = new Buffer(bn.toArray()); - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } -} +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -}).call(this,require("buffer").Buffer) -},{"./generatePrime":214,"bn.js":90,"buffer":131,"miller-rabin":265,"randombytes":306}],214:[function(require,module,exports){ -var randomBytes = require('randombytes'); -module.exports = findPrime; -findPrime.simpleSieve = simpleSieve; -findPrime.fermatTest = fermatTest; + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res, + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +},{"../utils":236,"bn.js":90}],224:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); var BN = require('bn.js'); -var TWENTYFOUR = new BN(24); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var ONE = new BN(1); -var TWO = new BN(2); -var FIVE = new BN(5); -var SIXTEEN = new BN(16); -var EIGHT = new BN(8); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var ELEVEN = new BN(11); -var FOUR = new BN(4); -var TWELVE = new BN(12); -var primes = null; +var inherits = require('inherits'); +var Base = require('./base'); -function _getPrimes() { - if (primes !== null) - return primes; +var assert = utils.assert; - var limit = 0x100000; - var res = []; - res[0] = 2; - for (var i = 1, k = 3; k < limit; k += 2) { - var sqrt = Math.ceil(Math.sqrt(k)); - for (var j = 0; j < i && res[j] <= sqrt; j++) - if (k % res[j] === 0) - break; +function EdwardsCurve(conf) { + // NOTE: Important as we are creating point in Base.call() + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; - if (i !== j && res[j] <= sqrt) - continue; + Base.call(this, 'edwards', conf); - res[i++] = k; - } - primes = res; - return res; + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; } +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; -function simpleSieve(p) { - var primes = _getPrimes(); +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); +}; - for (var i = 0; i < primes.length; i++) - if (p.modn(primes[i]) === 0) { - if (p.cmpn(primes[i]) === 0) { - return true; - } else { - return false; - } - } +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); +}; - return true; -} +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); +}; -function fermatTest(p) { - var red = BN.mont(p); - return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; -} +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -function findPrime(bits, gen) { - if (bits < 16) { - // this is what openssl does - if (gen === 2 || gen === 5) { - return new BN([0x8c, 0x7b]); - } else { - return new BN([0x8c, 0x27]); - } - } - gen = new BN(gen); + var x2 = x.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x2)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - var num, n2; + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - while (true) { - num = new BN(randomBytes(Math.ceil(bits / 8))); - while (num.bitLength() > bits) { - num.ishrn(1); - } - if (num.isEven()) { - num.iadd(ONE); - } - if (!num.testn(1)) { - num.iadd(TWO); - } - if (!gen.cmp(TWO)) { - while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { - num.iadd(FOUR); - } - } else if (!gen.cmp(FIVE)) { - while (num.mod(TEN).cmp(THREE)) { - num.iadd(FOUR); - } - } - n2 = num.shrn(1); - if (simpleSieve(n2) && simpleSieve(num) && - fermatTest(n2) && fermatTest(num) && - millerRabin.test(n2) && millerRabin.test(num)) { - return num; - } + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); + + // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) + var y2 = y.redSqr(); + var lhs = y2.redSub(this.c2); + var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); + var x2 = lhs.redMul(rhs.redInvm()); + + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); } -} + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -},{"bn.js":90,"miller-rabin":265,"randombytes":306}],215:[function(require,module,exports){ -module.exports={ - "modp1": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" - }, - "modp2": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" - }, - "modp5": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" - }, - "modp14": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" - }, - "modp15": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" - }, - "modp16": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" - }, - "modp17": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" - }, - "modp18": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; + + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); + + var x2 = point.x.redSqr(); + var y2 = point.y.redSqr(); + var lhs = x2.redMul(this.a).redAdd(y2); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); + + return lhs.cmp(rhs) === 0; +}; + +function Point(curve, x, y, z, t) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && y === null && z === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = z ? new BN(z, 16) : this.curve.one; + this.t = t && new BN(t, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + + // Use extended coordinates + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); } + } } -},{}],216:[function(require,module,exports){ -var assert = require('assert') -var BigInteger = require('bigi') +inherits(Point, Base.BasePoint); -var Point = require('./point') +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; -function Curve (p, a, b, Gx, Gy, n, h) { - this.p = p - this.a = a - this.b = b - this.G = Point.fromAffine(this, Gx, Gy) - this.n = n - this.h = h +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; - this.infinity = new Point(this, null, null, BigInteger.ZERO) +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; - // result caching - this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // determine size of p in bytes - this.pLength = Math.floor((this.p.bitLength() + 7) / 8) -} +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.x.cmpn(0) === 0 && + (this.y.cmp(this.z) === 0 || + (this.zOne && this.y.cmp(this.curve.c) === 0)); +}; -Curve.prototype.pointFromX = function (isOdd, x) { - var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) - var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - var y = beta - if (beta.isEven() ^ !isOdd) { - y = this.p.subtract(y) // -y % p + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = 2 * Z1^2 + var c = this.z.redSqr(); + c = c.redIAdd(c); + // D = a * A + var d = this.curve._mulA(a); + // E = (X1 + Y1)^2 - A - B + var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); + // G = D + B + var g = d.redAdd(b); + // F = G - C + var f = g.redSub(c); + // H = D - B + var h = d.redSub(b); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projDbl = function _projDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #doubling-dbl-2008-bbjlp + // #doubling-dbl-2007-bl + // and others + // Generally 3M + 4S or 2M + 4S + + // B = (X1 + Y1)^2 + var b = this.x.redAdd(this.y).redSqr(); + // C = X1^2 + var c = this.x.redSqr(); + // D = Y1^2 + var d = this.y.redSqr(); + + var nx; + var ny; + var nz; + var e; + var h; + var j; + if (this.curve.twisted) { + // E = a * C + e = this.curve._mulA(c); + // F = E + D + var f = e.redAdd(d); + if (this.zOne) { + // X3 = (B - C - D) * (F - 2) + nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F^2 - 2 * F + nz = f.redSqr().redSub(f).redSub(f); + } else { + // H = Z1^2 + h = this.z.redSqr(); + // J = F - 2 * H + j = f.redSub(h).redISub(h); + // X3 = (B-C-D)*J + nx = b.redSub(c).redISub(d).redMul(j); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F * J + nz = f.redMul(j); + } + } else { + // E = C + D + e = c.redAdd(d); + // H = (c * Z1)^2 + h = this.curve._mulC(this.z).redSqr(); + // J = E - 2 * H + j = e.redSub(h).redSub(h); + // X3 = c * (B - E) * J + nx = this.curve._mulC(b.redISub(e)).redMul(j); + // Y3 = c * E * (C - D) + ny = this.curve._mulC(e).redMul(c.redISub(d)); + // Z3 = E * J + nz = e.redMul(j); } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); +}; + +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return Point.fromAffine(this, x, y) -} + // A = (Y1 - X1) * (Y2 - X2) + var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); + // B = (Y1 + X1) * (Y2 + X2) + var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); + // C = T1 * k * T2 + var c = this.t.redMul(this.curve.dd).redMul(p.t); + // D = Z1 * 2 * Z2 + var d = this.z.redMul(p.z.redAdd(p.z)); + // E = B - A + var e = b.redSub(a); + // F = D - C + var f = d.redSub(c); + // G = D + C + var g = d.redAdd(c); + // H = B + A + var h = b.redAdd(a); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; -Curve.prototype.isInfinity = function (Q) { - if (Q === this.infinity) return true +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S - return Q.z.signum() === 0 && Q.y.signum() !== 0 -} + // A = Z1 * Z2 + var a = this.z.redMul(p.z); + // B = A^2 + var b = a.redSqr(); + // C = X1 * X2 + var c = this.x.redMul(p.x); + // D = Y1 * Y2 + var d = this.y.redMul(p.y); + // E = d * C * D + var e = this.curve.d.redMul(c).redMul(d); + // F = B - E + var f = b.redSub(e); + // G = B + E + var g = b.redAdd(e); + // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) + var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); + var nx = a.redMul(f).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + // Y3 = A * G * (D - a * C) + ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); + // Z3 = F * G + nz = f.redMul(g); + } else { + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); + } + return this.curve.point(nx, ny, nz); +}; -Curve.prototype.isOnCurve = function (Q) { - if (this.isInfinity(Q)) return true +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; - var x = Q.affineX - var y = Q.affineY - var a = this.a - var b = this.b - var p = this.p + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); +}; - // Check that xQ and yQ are integers in the interval [0, p - 1] - if (x.signum() < 0 || x.compareTo(p) >= 0) return false - if (y.signum() < 0 || y.compareTo(p) >= 0) return false +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; - // and check that y^2 = x^3 + ax + b (mod p) - var lhs = y.square().mod(p) - var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) - return lhs.equals(rhs) -} +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; -/** - * Validate an elliptic curve point. - * - * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive - */ -Curve.prototype.validate = function (Q) { - // Check Q != O - assert(!this.isInfinity(Q), 'Point is at infinity') - assert(this.isOnCurve(Q), 'Point is not on the curve') +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); +}; - // Check nQ = O (where Q is a scalar multiple of G) - var nQ = Q.multiply(this.n) - assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; - return true -} + // Normalize coordinates + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; +}; -module.exports = Curve +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; -},{"./point":220,"assert":24,"bigi":34}],217:[function(require,module,exports){ -module.exports={ - "secp128r1": { - "p": "fffffffdffffffffffffffffffffffff", - "a": "fffffffdfffffffffffffffffffffffc", - "b": "e87579c11079f43dd824993c2cee5ed3", - "n": "fffffffe0000000075a30d1b9038a115", - "h": "01", - "Gx": "161ff7528b899b2d0c28607ca52c5b86", - "Gy": "cf5ac8395bafeb13c02da292dded7a83" - }, - "secp160k1": { - "p": "fffffffffffffffffffffffffffffffeffffac73", - "a": "00", - "b": "07", - "n": "0100000000000000000001b8fa16dfab9aca16b6b3", - "h": "01", - "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", - "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" - }, - "secp160r1": { - "p": "ffffffffffffffffffffffffffffffff7fffffff", - "a": "ffffffffffffffffffffffffffffffff7ffffffc", - "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", - "n": "0100000000000000000001f4c8f927aed3ca752257", - "h": "01", - "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", - "Gy": "23a628553168947d59dcc912042351377ac5fb32" - }, - "secp192k1": { - "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", - "a": "00", - "b": "03", - "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", - "h": "01", - "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", - "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" - }, - "secp192r1": { - "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", - "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", - "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", - "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", - "h": "01", - "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", - "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" - }, - "secp256k1": { - "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - "a": "00", - "b": "07", - "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", - "h": "01", - "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" - }, - "secp256r1": { - "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", - "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", - "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", - "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", - "h": "01", - "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", - "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" - } -} +Point.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); +}; -},{}],218:[function(require,module,exports){ -var Point = require('./point') -var Curve = require('./curve') +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); +}; -var getCurveByName = require('./names') +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; +}; -module.exports = { - Curve: Curve, - Point: Point, - getCurveByName: getCurveByName -} +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; -},{"./curve":216,"./names":219,"./point":220}],219:[function(require,module,exports){ -var BigInteger = require('bigi') + var xc = x.clone(); + var t = this.curve.redN.redMul(this.z); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; -var curves = require('./curves.json') -var Curve = require('./curve') + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; -function getCurveByName (name) { - var curve = curves[name] - if (!curve) return null +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - var p = new BigInteger(curve.p, 16) - var a = new BigInteger(curve.a, 16) - var b = new BigInteger(curve.b, 16) - var n = new BigInteger(curve.n, 16) - var h = new BigInteger(curve.h, 16) - var Gx = new BigInteger(curve.Gx, 16) - var Gy = new BigInteger(curve.Gy, 16) +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],225:[function(require,module,exports){ +'use strict'; - return new Curve(p, a, b, Gx, Gy, n, h) -} +var curve = exports; -module.exports = getCurveByName +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); -},{"./curve":216,"./curves.json":217,"bigi":34}],220:[function(require,module,exports){ -var assert = require('assert') -var Buffer = require('safe-buffer').Buffer -var BigInteger = require('bigi') +},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(require,module,exports){ +'use strict'; -var THREE = BigInteger.valueOf(3) +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -function Point (curve, x, y, z) { - assert.notStrictEqual(z, undefined, 'Missing Z coordinate') +var utils = require('../utils'); - this.curve = curve - this.x = x - this.y = y - this.z = z - this._zInv = null +function MontCurve(conf) { + Base.call(this, 'mont', conf); - this.compressed = true + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); } +inherits(MontCurve, Base); +module.exports = MontCurve; -Object.defineProperty(Point.prototype, 'zInv', { - get: function () { - if (this._zInv === null) { - this._zInv = this.z.modInverse(this.curve.p) - } - - return this._zInv - } -}) +MontCurve.prototype.validate = function validate(point) { + var x = point.normalize().x; + var x2 = x.redSqr(); + var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); + var y = rhs.redSqrt(); -Object.defineProperty(Point.prototype, 'affineX', { - get: function () { - return this.x.multiply(this.zInv).mod(this.curve.p) - } -}) + return y.redSqr().cmp(rhs) === 0; +}; -Object.defineProperty(Point.prototype, 'affineY', { - get: function () { - return this.y.multiply(this.zInv).mod(this.curve.p) +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x, 16); + this.z = new BN(z, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); } -}) - -Point.fromAffine = function (curve, x, y) { - return new Point(curve, x, y, BigInteger.ONE) } +inherits(Point, Base.BasePoint); -Point.prototype.equals = function (other) { - if (other === this) return true - if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) - if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) - - // u = Y2 * Z1 - Y1 * Z2 - var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) - - if (u.signum() !== 0) return false +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); +}; - // v = X2 * Z1 - X1 * Z2 - var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); +}; - return v.signum() === 0 -} +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; -Point.prototype.negate = function () { - var y = this.curve.p.subtract(this.y) +Point.prototype.precompute = function precompute() { + // No-op +}; - return new Point(this.curve, this.x, y, this.z) -} +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; -Point.prototype.add = function (b) { - if (this.curve.isInfinity(this)) return b - if (this.curve.isInfinity(b)) return this +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); +}; - var x1 = this.x - var y1 = this.y - var x2 = b.x - var y2 = b.y +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // u = Y2 * Z1 - Y1 * Z2 - var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) - // v = X2 * Z1 - X1 * Z2 - var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; - if (v.signum() === 0) { - if (u.signum() === 0) { - return this.twice() // this == b, so double - } +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - return this.curve.infinity // this = -b, so infinity - } + // A = X1 + Z1 + var a = this.x.redAdd(this.z); + // AA = A^2 + var aa = a.redSqr(); + // B = X1 - Z1 + var b = this.x.redSub(this.z); + // BB = B^2 + var bb = b.redSqr(); + // C = AA - BB + var c = aa.redSub(bb); + // X3 = AA * BB + var nx = aa.redMul(bb); + // Z3 = C * (BB + A24 * C) + var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); + return this.curve.point(nx, nz); +}; - var v2 = v.square() - var v3 = v2.multiply(v) - var x1v2 = x1.multiply(v2) - var zu2 = u.square().multiply(this.z) +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) - var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) - // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 - var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) - // z3 = v^3 * z1 * z2 - var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A - return new Point(this.curve, x3, y3, z3) -} + // A = X2 + Z2 + var a = this.x.redAdd(this.z); + // B = X2 - Z2 + var b = this.x.redSub(this.z); + // C = X3 + Z3 + var c = p.x.redAdd(p.z); + // D = X3 - Z3 + var d = p.x.redSub(p.z); + // DA = D * A + var da = d.redMul(a); + // CB = C * B + var cb = c.redMul(b); + // X5 = Z1 * (DA + CB)^2 + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + // Z5 = X1 * (DA - CB)^2 + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); +}; -Point.prototype.twice = function () { - if (this.curve.isInfinity(this)) return this - if (this.y.signum() === 0) return this.curve.infinity +Point.prototype.mul = function mul(k) { + var t = k.clone(); + var a = this; // (N / 2) * Q + Q + var b = this.curve.point(null, null); // (N / 2) * Q + var c = this; // Q - var x1 = this.x - var y1 = this.y + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); - var y1z1 = y1.multiply(this.z).mod(this.curve.p) - var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) - var a = this.curve.a + for (var i = bits.length - 1; i >= 0; i--) { + if (bits[i] === 0) { + // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q + a = a.diffAdd(b, c); + // N * Q = 2 * ((N / 2) * Q + Q)) + b = b.dbl(); + } else { + // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) + b = a.diffAdd(b, c); + // N * Q + Q = 2 * ((N / 2) * Q + Q) + a = a.dbl(); + } + } + return b; +}; - // w = 3 * x1^2 + a * z1^2 - var w = x1.square().multiply(THREE) +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - if (a.signum() !== 0) { - w = w.add(this.z.square().multiply(a)) - } +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - w = w.mod(this.curve.p) - // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) - var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) - // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 - var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) - // z3 = 8 * (y1 * z1)^3 - var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - return new Point(this.curve, x3, y3, z3) -} +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; -// Simple NAF (Non-Adjacent Form) multiplication algorithm -// TODO: modularize the multiplication algorithm -Point.prototype.multiply = function (k) { - if (this.curve.isInfinity(this)) return this - if (k.signum() === 0) return this.curve.infinity +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - var e = k - var h = e.multiply(THREE) + return this.x.fromRed(); +}; - var neg = this.negate() - var R = this +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],227:[function(require,module,exports){ +'use strict'; - for (var i = h.bitLength() - 2; i > 0; --i) { - var hBit = h.testBit(i) - var eBit = e.testBit(i) +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - R = R.twice() +var assert = utils.assert; - if (hBit !== eBit) { - R = R.add(hBit ? this : neg) - } - } +function ShortCurve(conf) { + Base.call(this, 'short', conf); - return R -} + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); -// Compute this*j + x*k (simultaneous multiplication) -Point.prototype.multiplyTwo = function (j, x, k) { - var i = Math.max(j.bitLength(), k.bitLength()) - 1 - var R = this.curve.infinity - var both = this.add(x) + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - while (i >= 0) { - var jBit = j.testBit(i) - var kBit = k.testBit(i) + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits(ShortCurve, Base); +module.exports = ShortCurve; - R = R.twice() +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - if (jBit) { - if (kBit) { - R = R.add(both) - } else { - R = R.add(this) - } - } else if (kBit) { - R = R.add(x) + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); } - --i } - return R -} + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16), + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } -Point.prototype.getEncoded = function (compressed) { - if (compressed == null) compressed = this.compressed - if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' + return { + beta: beta, + lambda: lambda, + basis: basis, + }; +}; - var x = this.affineX - var y = this.affineY - var byteLength = this.curve.pLength - var buffer +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); - // 0x02/0x03 | X - if (compressed) { - buffer = Buffer.allocUnsafe(1 + byteLength) - buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - // 0x04 | X | Y - } else { - buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) - buffer.writeUInt8(0x04, 0) + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; - y.toBuffer(byteLength).copy(buffer, 1 + byteLength) - } +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - x.toBuffer(byteLength).copy(buffer, 1) + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); - return buffer -} + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; -Point.decodeFrom = function (curve, buffer) { - var type = buffer.readUInt8(0) - var compressed = (type !== 4) + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); - var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) - var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - var Q - if (compressed) { - assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') - assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; - var isOdd = (type === 0x03) - Q = curve.pointFromX(isOdd, x) - } else { - assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } - var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) - Q = Point.fromAffine(curve, x, y) + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); } - Q.compressed = compressed - return Q -} + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; -Point.prototype.toString = function () { - if (this.curve.isInfinity(this)) return '(INFINITY)' +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' -} + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); -module.exports = Point + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); -},{"assert":24,"bigi":34,"safe-buffer":322}],221:[function(require,module,exports){ -'use strict'; + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; -var elliptic = exports; +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -elliptic.version = require('../package.json').version; -elliptic.utils = require('./elliptic/utils'); -elliptic.rand = require('brorand'); -elliptic.curve = require('./elliptic/curve'); -elliptic.curves = require('./elliptic/curves'); + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); -},{"../package.json":236,"./elliptic/curve":224,"./elliptic/curves":227,"./elliptic/ec":228,"./elliptic/eddsa":231,"./elliptic/utils":235,"brorand":103}],222:[function(require,module,exports){ -'use strict'; + return this.point(x, y); +}; -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); + var x = point.x; + var y = point.y; - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + +function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; } } -module.exports = BaseCurve; +inherits(Point, Base.BasePoint); -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); }; -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); }; -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; - var naf = getNAF(k, 1); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; - // Translate into more windowed form - var repr = []; - for (var j = 0; j < naf.length; j += doubles.step) { - var nafW = 0; - for (var k = j + doubles.step - 1; k >= j; k--) - nafW = (nafW << 1) + naf[k]; - repr.push(nafW); + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul), + }, + }; } + return beta; +}; - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (var j = 0; j < repr.length; j++) { - var nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1), + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1), + }, + } ]; }; -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } - // Get NAF form - var naf = getNAF(k, w); + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), + }, + }; + return res; +}; - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var k = 0; i >= 0 && naf[i] === 0; i--) - k++; - if (i >= 0) - k++; - acc = acc.dblp(k); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; +Point.prototype.isInfinity = function isInfinity() { + return this.inf; }; -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; - // Fill all arrays - var max = 0; - for (var i = 0; i < len; i++) { - var p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } + // P + O = P + if (p.inf) + return this; - // Comb small window NAFs - for (var i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a]); - naf[b] = getNAF(coeffs[b], wndWidth[b]); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } + // P + P = 2P + if (this.eq(p)) + return this.dbl(); - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b] /* 7 */ - ]; + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3 /* 1 1 */ - ]; + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (var j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (var i = max; i >= 0; i--) { - var k = 0; + var a = this.curve.a; - while (i >= 0) { - var zero = true; - for (var j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - for (var j = 0; j < len; j++) { - var z = tmp[j]; - var p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (var i = 0; i < len; i++) - wnd[i] = null; +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; - if (jacobianResult) - return acc; +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); else - return acc.toP(); + return this.curve._wnafMul(this, k); }; -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; -} -BaseCurve.BasePoint = BasePoint; +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; - var len = this.p.byteLength(); + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate), + }, + }; + } + return res; +}; - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); +function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); } - throw new Error('Unknown point format'); -}; + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); + +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); }; -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); - return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; + return this.curve.point(ax, ay); }; -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) return this; - var precomputed = { - doubles: null, - naf: null, - beta: null - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); - return this; -}; + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); + return this.curve.jpoint(nx, ny, nz); }; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); } - return { - step: step, - points: doubles - }; -}; -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res - }; -}; + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); -BasePoint.prototype._getBeta = function _getBeta() { - return null; + return this.curve.jpoint(nx, ny, nz); }; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); -},{"../../elliptic":221,"bn.js":90}],223:[function(require,module,exports){ -'use strict'; + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; + } -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; -var assert = elliptic.utils.assert; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -function EdwardsCurve(conf) { - // NOTE: Important as we are creating point in Base.call() - this.twisted = (conf.a | 0) !== 1; - this.mOneA = this.twisted && (conf.a | 0) === -1; - this.extended = this.mOneA; + // Reuse results + var jyd = jy.redAdd(jy); + for (i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - Base.call(this, 'edwards', conf); + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); - this.a = new BN(conf.a, 16).umod(this.red.m); - this.a = this.a.toRed(this.red); - this.c = new BN(conf.c, 16).toRed(this.red); - this.c2 = this.c.redSqr(); - this.d = new BN(conf.d, 16).toRed(this.red); - this.dd = this.d.redAdd(this.d); + jx = nx; + jz = nz; + jyd = dny; + } - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); else - return this.a.redMul(num); + return this._dbl(); }; -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); }; -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var x2 = x.redSqr(); - var rhs = this.c2.redSub(this.a.redMul(x2)); - var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); -}; +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) - var y2 = y.redSqr(); - var lhs = y2.redSub(this.c2); - var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); - var x2 = lhs.redMul(rhs.redInvm()); + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); - return this.point(x, y); + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; - - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); - - var x2 = point.x.redSqr(); - var y2 = point.y.redSqr(); - var lhs = x2.redMul(this.a).redAdd(y2); - var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - - return lhs.cmp(rhs) === 0; -}; +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); -function Point(curve, x, y, z, t) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && y === null && z === null) { - this.x = this.curve.zero; - this.y = this.curve.one; - this.z = this.curve.one; - this.t = this.curve.zero; - this.zOne = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = z ? new BN(z, 16) : this.curve.one; - this.t = t && new BN(t, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - if (this.t && !this.t.red) - this.t = this.t.toRed(this.curve.red); - this.zOne = this.z === this.curve.one; + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - // Use extended coordinates - if (this.curve.extended && !this.t) { - this.t = this.x.redMul(this.y); - if (!this.zOne) - this.t = this.t.redMul(this.z.redInvm()); - } - } -} -inherits(Point, Base.BasePoint); + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); -}; +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); + return this.curve._wnafMul(this, k); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.x.cmpn(0) === 0 && - (this.y.cmp(this.z) === 0 || - (this.zOne && this.y.cmp(this.curve.c) === 0)); -}; + if (this === p) + return true; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = 2 * Z1^2 - var c = this.z.redSqr(); - c = c.redIAdd(c); - // D = a * A - var d = this.curve._mulA(a); - // E = (X1 + Y1)^2 - A - B - var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); - // G = D + B - var g = d.redAdd(b); - // F = G - C - var f = g.redSub(c); - // H = D - B - var h = d.redSub(b); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; }; -Point.prototype._projDbl = function _projDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #doubling-dbl-2008-bbjlp - // #doubling-dbl-2007-bl - // and others - // Generally 3M + 4S or 2M + 4S +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; - // B = (X1 + Y1)^2 - var b = this.x.redAdd(this.y).redSqr(); - // C = X1^2 - var c = this.x.redSqr(); - // D = Y1^2 - var d = this.y.redSqr(); + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; - var nx; - var ny; - var nz; - if (this.curve.twisted) { - // E = a * C - var e = this.curve._mulA(c); - // F = E + D - var f = e.redAdd(d); - if (this.zOne) { - // X3 = (B - C - D) * (F - 2) - nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F^2 - 2 * F - nz = f.redSqr().redSub(f).redSub(f); - } else { - // H = Z1^2 - var h = this.z.redSqr(); - // J = F - 2 * H - var j = f.redSub(h).redISub(h); - // X3 = (B-C-D)*J - nx = b.redSub(c).redISub(d).redMul(j); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F * J - nz = f.redMul(j); - } - } else { - // E = C + D - var e = c.redAdd(d); - // H = (c * Z1)^2 - var h = this.curve._mulC(this.z).redSqr(); - // J = E - 2 * H - var j = e.redSub(h).redSub(h); - // X3 = c * (B - E) * J - nx = this.curve._mulC(b.redISub(e)).redMul(j); - // Y3 = c * E * (C - D) - ny = this.curve._mulC(e).redMul(c.redISub(d)); - // Z3 = E * J - nz = e.redMul(j); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - return this.curve.point(nx, ny, nz); }; -Point.prototype.dbl = function dbl() { +JPoint.prototype.inspect = function inspect() { if (this.isInfinity()) - return this; - - // Double in extended coordinates - if (this.curve.extended) - return this._extDbl(); - else - return this._projDbl(); + return ''; + return ''; }; -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M - - // A = (Y1 - X1) * (Y2 - X2) - var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); - // B = (Y1 + X1) * (Y2 + X2) - var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); - // C = T1 * k * T2 - var c = this.t.redMul(this.curve.dd).redMul(p.t); - // D = Z1 * 2 * Z2 - var d = this.z.redMul(p.z.redAdd(p.z)); - // E = B - A - var e = b.redSub(a); - // F = D - C - var f = d.redSub(c); - // G = D + C - var g = d.redAdd(c); - // H = B + A - var h = b.redAdd(a); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],228:[function(require,module,exports){ +'use strict'; - // A = Z1 * Z2 - var a = this.z.redMul(p.z); - // B = A^2 - var b = a.redSqr(); - // C = X1 * X2 - var c = this.x.redMul(p.x); - // D = Y1 * Y2 - var d = this.y.redMul(p.y); - // E = d * C * D - var e = this.curve.d.redMul(c).redMul(d); - // F = B - E - var f = b.redSub(e); - // G = B + E - var g = b.redAdd(e); - // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) - var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); - var nx = a.redMul(f).redMul(tmp); - var ny; - var nz; - if (this.curve.twisted) { - // Y3 = A * G * (D - a * C) - ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); - // Z3 = F * G - nz = f.redMul(g); - } else { - // Y3 = A * G * (D - C) - ny = a.redMul(g).redMul(d.redSub(c)); - // Z3 = c * F * G - nz = this.curve._mulC(f).redMul(g); - } - return this.curve.point(nx, ny, nz); -}; +var curves = exports; -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; +var assert = utils.assert; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve.short(options); + else if (options.type === 'edwards') + this.curve = new curve.edwards(options); else - return this.curve._wnafMul(this, k); -}; - -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; - -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; - // Normalize coordinates - var zi = this.z.redInvm(); - this.x = this.x.redMul(zi); - this.y = this.y.redMul(zi); - if (this.t) - this.t = this.t.redMul(zi); - this.z = this.curve.one; - this.zOne = true; - return this; -}; +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve, + }); + return curve; + }, + }); +} -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; +defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811', + ], +}); -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; +defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34', + ], +}); -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; +defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5', + ], +}); -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; -}; +defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f', + ], +}); -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; +defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650', + ], +}); - var xc = x.clone(); - var t = this.curve.redN.redMul(this.z); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; +defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '9', + ], +}); - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } -}; +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],224:[function(require,module,exports){ -'use strict'; +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} -var curve = exports; +defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash.sha256, -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -},{"./base":222,"./edwards":223,"./mont":225,"./short":226}],225:[function(require,module,exports){ +},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(require,module,exports){ 'use strict'; -var curve = require('../curve'); var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; - -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; - -function MontCurve(conf) { - Base.call(this, 'mont', conf); +var HmacDRBG = require('hmac-drbg'); +var utils = require('../utils'); +var curves = require('../curves'); +var rand = require('brorand'); +var assert = utils.assert; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.i4 = new BN(4).toRed(this.red).redInvm(); - this.two = new BN(2).toRed(this.red); - this.a24 = this.i4.redMul(this.a.redAdd(this.two)); -} -inherits(MontCurve, Base); -module.exports = MontCurve; +var KeyPair = require('./key'); +var Signature = require('./signature'); -MontCurve.prototype.validate = function validate(point) { - var x = point.normalize().x; - var x2 = x.redSqr(); - var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); - var y = rhs.redSqrt(); +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); - return y.redSqr().cmp(rhs) === 0; -}; + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); -function Point(curve, x, z) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && z === null) { - this.x = this.curve.one; - this.z = this.curve.zero; - } else { - this.x = new BN(x, 16); - this.z = new BN(z, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); + options = curves[options]; } -} -inherits(Point, Base.BasePoint); - -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; - -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; - -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; -Point.prototype.precompute = function precompute() { - // No-op -}; + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); -}; + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); }; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A - - // A = X1 + Z1 - var a = this.x.redAdd(this.z); - // AA = A^2 - var aa = a.redSqr(); - // B = X1 - Z1 - var b = this.x.redSub(this.z); - // BB = B^2 - var bb = b.redSqr(); - // C = AA - BB - var c = aa.redSub(bb); - // X3 = AA * BB - var nx = aa.redMul(bb); - // Z3 = C * (BB + A24 * C) - var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); - return this.curve.point(nx, nz); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); }; -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); }; -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A - - // A = X2 + Z2 - var a = this.x.redAdd(this.z); - // B = X2 - Z2 - var b = this.x.redSub(this.z); - // C = X3 + Z3 - var c = p.x.redAdd(p.z); - // D = X3 - Z3 - var d = p.x.redSub(p.z); - // DA = D * A - var da = d.redMul(a); - // CB = C * B - var cb = c.redMul(b); - // X5 = Z1 * (DA + CB)^2 - var nx = diff.z.redMul(da.redAdd(cb).redSqr()); - // Z5 = X1 * (DA - CB)^2 - var nz = diff.x.redMul(da.redISub(cb).redSqr()); - return this.curve.point(nx, nz); -}; +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -Point.prototype.mul = function mul(k) { - var t = k.clone(); - var a = this; // (N / 2) * Q + Q - var b = this.curve.point(null, null); // (N / 2) * Q - var c = this; // Q + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray(), + }); - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (;;) { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; - for (var i = bits.length - 1; i >= 0; i--) { - if (bits[i] === 0) { - // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q - a = a.diffAdd(b, c); - // N * Q = 2 * ((N / 2) * Q + Q)) - b = b.dbl(); - } else { - // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) - b = a.diffAdd(b, c); - // N * Q + Q = 2 * ((N / 2) * Q + Q) - a = a.dbl(); - } + priv.iaddn(1); + return this.keyFromPrivate(priv); } - return b; -}; - -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); }; -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; - -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; +EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; }; -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; -}; +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); - return this.x.fromRed(); -}; + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],226:[function(require,module,exports){ -'use strict'; + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); -var assert = elliptic.utils.assert; + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); -function ShortCurve(conf) { - Base.call(this, 'short', conf); + for (var iter = 0; ; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); -} -inherits(ShortCurve, Base); -module.exports = ShortCurve; + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; } - } - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16) - }; - }); - } else { - basis = this._getEndoBasis(lambda); + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } - - return { - beta: beta, - lambda: lambda, - basis: basis - }; -}; - -ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); - - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; }; -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); - - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; - - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); - - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; - - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; +EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + var p; - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 } - ]; -}; + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; + return p.getX().umod(this.n).cmp(r) === 0; + } - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); }; -ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; - return this.point(x, y); -}; + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); -ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); - var x = point.x; - var y = point.y; + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); }; -ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; + if (Qprime.eq(Q)) + return i; } - return res; + throw new Error('Unable to find valid recovery factor'); }; -function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } -} -inherits(Point, Base.BasePoint); +},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,"brorand":103,"hmac-drbg":277}],230:[function(require,module,exports){ +'use strict'; -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); -}; +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); -}; +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; -Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +module.exports = KeyPair; - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul) - } - }; - } - return beta; + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - } ]; + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); }; -Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)) - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)) - } - }; - return res; + return { result: true, reason: null }; }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - // P + O = P - if (p.inf) - return this; + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; - // P + P = 2P - if (this.eq(p)) - return this.dbl(); +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); }; -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); +},{"../utils":236,"bn.js":90}],231:[function(require,module,exports){ +'use strict'; - var a = this.curve.a; +var BN = require('bn.js'); - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); +var utils = require('../utils'); +var assert = utils.assert; - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; +function Signature(options, enc) { + if (options instanceof Signature) + return options; -Point.prototype.getX = function getX() { - return this.x.fromRed(); -}; + if (this._importDER(options, enc)) + return; -Point.prototype.getY = function getY() { - return this.y.fromRed(); -}; + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +module.exports = Signature; -Point.prototype.mul = function mul(k) { - k = new BN(k, 16); +function Position() { + this.place = 0; +} - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); -}; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; -Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); -}; + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } -Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); -}; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } -Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); -}; + // Leading zeroes + if (val <= 0x7f) { + return false; + } -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; + p.place = off; + return val; +} - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate) - } - }; +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; } - return res; -}; + if (i === 0) { + return buf; + } + return buf.slice(i); +} -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if (len === false) { + return false; + } + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + if (rlen === false) { + return false; + } + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (slen === false) { + return false; + } + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0) { + if (r[1] & 0x80) { + r = r.slice(1); + } else { + // Leading zeroes + return false; + } + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; }; -function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); } -inherits(JPoint, Base.BasePoint); -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); -}; +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); + r = rmPadding(r); + s = rmPadding(s); - return this.curve.point(ax, ay); + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; +},{"../utils":236,"bn.js":90}],232:[function(require,module,exports){ +'use strict'; -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; +var hash = require('hash.js'); +var curves = require('../curves'); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var KeyPair = require('./key'); +var Signature = require('./signature'); - // P + O = P - if (p.isInfinity()) - return this; +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); +module.exports = EDDSA; - return this.curve.jpoint(nx, ny, nz); +/** +* @param {Array|String} message - message bytes +* @param {Array|String|KeyPair} secret - secret bytes or a keypair +* @returns {Signature} - signature +*/ +EDDSA.prototype.sign = function sign(message, secret) { + message = parseBytes(message); + var key = this.keyFromSecret(secret); + var r = this.hashInt(key.messagePrefix(), message); + var R = this.g.mul(r); + var Rencoded = this.encodePoint(R); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message) + .mul(key.priv()); + var S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); - - // P + O = P - if (p.isInfinity()) - return this; - - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } +/** +* @param {Array} message - message bytes +* @param {Array|String|Signature} sig - sig bytes +* @param {Array|String|Point|KeyPair} pub - public key +* @returns {Boolean} - true if public key matches sig of message +*/ +EDDSA.prototype.verify = function verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); +}; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +EDDSA.prototype.hashInt = function hashInt() { + var hash = this.hash(); + for (var i = 0; i < arguments.length; i++) + hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); +}; - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - return this.curve.jpoint(nx, ny, nz); +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); }; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (var i = 0; i < pow; i++) - r = r.dbl(); - return r; - } +/** +* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 +* +* EDDSA defines methods for encoding and decoding points and integers. These are +* helper convenience methods, that pass along to utility functions implied +* parameters. +* +*/ +EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray('le', this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; +}; - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - // Reuse results - var jyd = jy.redAdd(jy); - for (var i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - jx = nx; - jz = nz; - jyd = dny; - } +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +},{"../curves":228,"../utils":236,"./key":233,"./signature":234,"hash.js":265}],233:[function(require,module,exports){ +'use strict'; - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; + +/** +* @param {EDDSA} eddsa - instance +* @param {Object} params - public/private key parameters +* +* @param {Array} [params.secret] - secret seed bytes +* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) +* @param {Array} [params.pub] - public key point encoded as bytes +* +*/ +function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; else - return this._dbl(); + this._pubBytes = parseBytes(params.pub); +} + +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); }; -JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } + return a; +}); - return this.curve.jpoint(nx, ny, nz); -}; +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); -JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; - return this.curve.jpoint(nx, ny, nz); +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); }; -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); +module.exports = KeyPair; - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); +},{"../utils":236}],234:[function(require,module,exports){ +'use strict'; - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); +/** +* @param {EDDSA} eddsa - eddsa instance +* @param {Array|Object} sig - +* @param {Array|Point} [sig.R] - R point as Point or bytes +* @param {Array|bn} [sig.S] - S scalar as bn or bytes +* @param {Array} [sig.Rencoded] - R point encoded +* @param {Array} [sig.Sencoded] - S scalar encoded +*/ +function Signature(eddsa, sig) { + this.eddsa = eddsa; - return this.curve.jpoint(nx, ny, nz); -}; + if (typeof sig !== 'object') + sig = parseBytes(sig); -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... + assert(sig.R && sig.S, 'Signature without R or S'); - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - return this.curve.jpoint(nx, ny, nz); + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} + +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); + +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); + +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); + +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); + +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); }; -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; - return this.curve._wnafMul(this, k); +module.exports = Signature; + +},{"../utils":236,"bn.js":90}],235:[function(require,module,exports){ +module.exports = { + doubles: { + step: 4, + points: [ + [ + 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', + 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', + ], + [ + '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', + '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', + ], + [ + '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', + 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', + ], + [ + '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', + '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', + ], + [ + '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', + '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', + ], + [ + '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', + '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', + ], + [ + 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', + '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', + ], + [ + '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', + 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', + ], + [ + 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', + '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', + ], + [ + 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', + 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', + ], + [ + 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', + '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', + ], + [ + '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', + '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', + ], + [ + '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', + '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', + ], + [ + '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', + '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', + ], + [ + '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', + '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', + ], + [ + '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', + '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', + ], + [ + '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', + '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', + ], + [ + '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', + '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', + ], + [ + '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', + 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', + ], + [ + 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', + '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', + ], + [ + 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', + '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', + ], + [ + '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', + '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', + ], + [ + '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', + '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', + ], + [ + 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', + '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', + ], + [ + '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', + 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', + ], + [ + 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', + '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', + ], + [ + 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', + 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', + ], + [ + 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', + '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', + ], + [ + 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', + 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', + ], + [ + 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', + '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', + ], + [ + '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', + 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', + ], + [ + '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', + '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', + ], + [ + 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', + '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', + ], + [ + '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', + 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', + ], + [ + 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', + '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', + ], + [ + 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', + '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', + ], + [ + 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', + 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', + ], + [ + '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', + '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', + ], + [ + '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', + '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', + ], + [ + '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', + 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', + ], + [ + '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', + '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', + ], + [ + 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', + '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', + ], + [ + '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', + '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', + ], + [ + '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', + 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', + ], + [ + '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', + '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', + ], + [ + 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', + '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', + ], + [ + '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', + 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', + ], + [ + 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', + 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', + ], + [ + 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', + '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', + ], + [ + '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', + 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', + ], + [ + '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', + 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', + ], + [ + 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', + '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', + ], + [ + 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', + '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', + ], + [ + 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', + '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', + ], + [ + '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', + 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', + ], + [ + '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', + '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', + ], + [ + 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', + 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', + ], + [ + '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', + 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', + ], + [ + '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', + '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', + ], + [ + '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', + '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', + ], + [ + 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', + 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', + ], + [ + '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', + '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', + ], + [ + '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', + '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', + ], + [ + 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', + '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', + ], + [ + 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', + 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', + ], + ], + }, + naf: { + wnd: 7, + points: [ + [ + 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', + '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', + ], + [ + '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', + 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', + ], + [ + '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', + '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', + ], + [ + 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', + 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', + ], + [ + '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', + 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', + ], + [ + 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', + 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', + ], + [ + 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', + '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', + ], + [ + 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', + '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', + ], + [ + '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', + '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', + ], + [ + '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', + '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', + ], + [ + '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', + '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', + ], + [ + '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', + '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', + ], + [ + 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', + 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', + ], + [ + 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', + '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', + ], + [ + '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', + 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', + ], + [ + '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', + 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', + ], + [ + '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', + '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', + ], + [ + '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', + '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', + ], + [ + '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', + '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', + ], + [ + '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', + 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', + ], + [ + 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', + 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', + ], + [ + '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', + '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', + ], + [ + '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', + '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', + ], + [ + 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', + 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', + ], + [ + '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', + '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', + ], + [ + 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', + 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', + ], + [ + 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', + 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', + ], + [ + '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', + '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', + ], + [ + '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', + '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', + ], + [ + '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', + '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', + ], + [ + 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', + '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', + ], + [ + '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', + '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', + ], + [ + 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', + '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', + ], + [ + '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', + 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', + ], + [ + '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', + 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', + ], + [ + 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', + 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', + ], + [ + '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', + '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', + ], + [ + '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', + 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', + ], + [ + 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', + 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', + ], + [ + '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', + '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', + ], + [ + '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', + 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', + ], + [ + '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', + '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', + ], + [ + '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', + 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', + ], + [ + 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', + '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', + ], + [ + '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', + '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', + ], + [ + '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', + 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', + ], + [ + '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', + 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', + ], + [ + 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', + 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', + ], + [ + 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', + 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', + ], + [ + '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', + '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', + ], + [ + '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', + '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', + ], + [ + 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', + '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', + ], + [ + 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', + 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', + ], + [ + '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', + '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', + ], + [ + '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', + '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', + ], + [ + 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', + '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', + ], + [ + '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', + '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', + ], + [ + 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', + 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', + ], + [ + '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', + 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', + ], + [ + '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', + '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', + ], + [ + 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', + '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', + ], + [ + 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', + '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', + ], + [ + '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', + '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', + ], + [ + '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', + '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', + ], + [ + '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', + 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', + ], + [ + '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', + 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', + ], + [ + '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', + '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', + ], + [ + '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', + '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', + ], + [ + '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', + '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', + ], + [ + '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', + 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', + ], + [ + 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', + 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', + ], + [ + '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', + 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', + ], + [ + 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', + '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', + ], + [ + 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', + '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', + ], + [ + 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', + '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', + ], + [ + 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', + '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', + ], + [ + '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', + 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', + ], + [ + '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', + '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', + ], + [ + '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', + 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', + ], + [ + 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', + 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', + ], + [ + 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', + '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', + ], + [ + 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', + 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', + ], + [ + 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', + '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', + ], + [ + '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', + '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', + ], + [ + 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', + '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', + ], + [ + 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', + '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', + ], + [ + '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', + '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', + ], + [ + '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', + 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', + ], + [ + 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', + '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', + ], + [ + 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', + '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', + ], + [ + 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', + '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', + ], + [ + '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', + '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', + ], + [ + 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', + 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', + ], + [ + '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', + 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', + ], + [ + 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', + 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', + ], + [ + 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', + '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', + ], + [ + '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', + 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', + ], + [ + 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', + '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', + ], + [ + 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', + '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', + ], + [ + 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', + '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', + ], + [ + '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', + 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', + ], + [ + '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', + 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', + ], + [ + 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', + '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', + ], + [ + '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', + 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', + ], + [ + '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', + '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', + ], + [ + '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', + 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', + ], + [ + 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', + 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', + ], + [ + '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', + 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', + ], + [ + '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', + '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', + ], + [ + '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', + 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', + ], + [ + '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', + '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', + ], + [ + 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', + 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', + ], + [ + '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', + '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', + ], + [ + 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', + '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', + ], + [ + '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', + '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', + ], + [ + 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', + 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', + ], + [ + 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', + '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', + ], + [ + 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', + 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', + ], + [ + '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', + 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', + ], + [ + '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', + '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', + ], + [ + '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', + 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', + ], + [ + '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', + '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', + ], + [ + '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', + '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', + ], + [ + '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', + 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', + ], + [ + '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', + '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', + ], + [ + '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', + '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', + ], + [ + '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', + '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', + ], + ], + }, }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); +},{}],236:[function(require,module,exports){ +'use strict'; - if (this === p) - return true; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; -}; +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); -JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; + var ws = 1 << (w + 1); + var k = num.clone(); - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; + for (var i = 0; i < naf.length; i++) { + var z; + var mod = k.andln(ws - 1); + if (k.isOdd()) { + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; + naf[i] = z; + k.iushrn(1); } -}; - -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],227:[function(require,module,exports){ -'use strict'; + return naf; +} +utils.getNAF = getNAF; -var curves = exports; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; -var hash = require('hash.js'); -var elliptic = require('../elliptic'); + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); -var assert = elliptic.utils.assert; + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); -function PresetCurve(options) { - if (options.type === 'short') - this.curve = new elliptic.curve.short(options); - else if (options.type === 'edwards') - this.curve = new elliptic.curve.edwards(options); - else - this.curve = new elliptic.curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); + return jsf; } -curves.PresetCurve = PresetCurve; +utils.getJSF = getJSF; -function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve - }); - return curve; - } - }); +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; } +utils.cachedProperty = cachedProperty; -defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' - ] -}); - -defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' - ] -}); - -defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' - ] -}); - -defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' - ] -}); - -defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650' - ] -}); - -defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '1', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9' - ] -}); - -defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658' - ] -}); +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); } +utils.intFromLE = intFromLE; -defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3' - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15' - } +},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "elliptic@6.5.4", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] ], + "_from": "elliptic@6.5.4", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.5.4", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.5.4", + "saveSpec": null, + "fetchSpec": "6.5.4" + }, + "_requiredBy": [ + "/create-ecdh", + "/crypto-browserify/browserify-sign", + "/secp256k1" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_spec": "6.5.4", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" +} - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre - ] -}); - -},{"../elliptic":221,"./precomputed/secp256k1":234,"hash.js":244}],228:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var HmacDRBG = require('hmac-drbg'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -var KeyPair = require('./key'); -var Signature = require('./signature'); +},{}],238:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var MD5 = require('md5.js') -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); +/* eslint-disable camelcase */ +function EVP_BytesToKey (password, salt, keyBits, ivLen) { + if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') + if (salt) { + if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') + if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + } - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); + var keyLen = keyBits / 8 + var key = Buffer.alloc(keyLen) + var iv = Buffer.alloc(ivLen || 0) + var tmp = Buffer.alloc(0) - options = elliptic.curves[options]; - } + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5() + hash.update(tmp) + hash.update(password) + if (salt) hash.update(salt) + tmp = hash.digest() - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof elliptic.curves.PresetCurve) - options = { curve: options }; + var used = 0 - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; + if (keyLen > 0) { + var keyStart = key.length - keyLen + used = Math.min(keyLen, tmp.length) + tmp.copy(key, keyStart, 0, used) + keyLen -= used + } - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen + var length = Math.min(ivLen, tmp.length - used) + tmp.copy(iv, ivStart, used, used + length) + ivLen -= length + } + } - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; + tmp.fill(0) + return { key: key, iv: iv } } -module.exports = EC; -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; +module.exports = EVP_BytesToKey -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); -}; +},{"md5.js":283,"safe-buffer":345}],239:[function(require,module,exports){ -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); -}; +},{}],240:[function(require,module,exports){ +arguments[4][239][0].apply(exports,arguments) +},{"dup":239}],241:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), - entropyEnc: options.entropy && options.entropyEnc || 'utf8', - nonce: this.n.toArray() - }); +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - do { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; - priv.iaddn(1); - return this.keyFromPrivate(priv); - } while (true); -}; +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; -EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; }; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); + if (!this._events) + this._events = {}; - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + handler = this._events[type]; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8' - }); + if (isUndefined(handler)) + return false; - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } - for (var iter = 0; true; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; + return true; +}; - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; +EventEmitter.prototype.addListener = function(type, listener) { + var m; - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; + if (!this._events) + this._events = {}; - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; } - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } } + + return this; }; -EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); +EventEmitter.prototype.on = EventEmitter.prototype.addListener; - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); + var fired = false; - if (!this.curve._maxwellTrick) { - var p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + function g() { + this.removeListener(type, g); - return p.getX().umod(this.n).cmp(r) === 0; + if (!fired) { + fired = true; + listener.apply(this, arguments); + } } - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - var p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + g.listener = listener; + this.on(type, g); - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); + return this; }; -EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); + if (!this._events || !this._events[type]) + return this; - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); + list = this._events[type]; + length = list.length; + position = -1; - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; + if (position < 0) + return this; - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); } - if (Qprime.eq(Q)) - return i; + if (this._events.removeListener) + this.emit('removeListener', type, listener); } - throw new Error('Unable to find valid recovery factor'); -}; - -},{"../../elliptic":221,"./key":229,"./signature":230,"bn.js":90,"hmac-drbg":256}],229:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); -} -module.exports = KeyPair; - -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc - }); -}; - -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - return new KeyPair(ec, { - priv: priv, - privEnc: enc - }); + return this; }; -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; + if (!this._events) + return this; - return { result: true, reason: null }; -}; + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; } - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); + listeners = this._events[type]; - if (!enc) - return this.pub; + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; - return this.pub.encode(enc, compact); + return this; }; -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; else - return this.priv; + ret = this._events[type].slice(); + return ret; }; -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); -}; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; -KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - // Montgomery points only have an `x` coordinate. - // Weierstrass/Edwards points on the other hand have both `x` and - // `y` coordinates. - if (this.ec.curve.type === 'mont') { - assert(key.x, 'Need x coordinate'); - } else if (this.ec.curve.type === 'short' || - this.ec.curve.type === 'edwards') { - assert(key.x && key.y, 'Need both x and y coordinate'); - } - this.pub = this.ec.curve.point(key.x, key.y); - return; + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; } - this.pub = this.ec.curve.decodePoint(key, enc); + return 0; }; -// ECDH -KeyPair.prototype.derive = function derive(pub) { - return pub.mul(this.priv).getX(); +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); }; -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; +function isFunction(arg) { + return typeof arg === 'function'; +} -KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); -}; +function isNumber(arg) { + return typeof arg === 'number'; +} -KeyPair.prototype.inspect = function inspect() { - return ''; -}; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} -},{"../../elliptic":221,"bn.js":90}],230:[function(require,module,exports){ -'use strict'; +function isUndefined(arg) { + return arg === void 0; +} -var BN = require('bn.js'); +},{}],242:[function(require,module,exports){ +(function (global){(function (){ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { + + /** Detect free variables */ + var freeExports = typeof exports == 'object' && exports && + !exports.nodeType && exports; + var freeModule = typeof module == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, -function Signature(options, enc) { - if (options instanceof Signature) - return options; + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - if (this._importDER(options, enc)) - return; + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; -} -module.exports = Signature; + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators -function Position() { - this.place = 0; -} + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - } - p.place = off; - return val; -} + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, -function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); -} + /** Temporary variable */ + key; -Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0 && (r[1] & 0x80)) { - r = r.slice(1); - } - if (s[0] === 0 && (s[1] & 0x80)) { - s = s.slice(1); - } + /*--------------------------------------------------------------------------*/ - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } - return true; -}; + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } -function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); -} + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } - r = rmPadding(r); - s = rmPadding(s); + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); -}; + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } -},{"../../elliptic":221,"bn.js":90}],231:[function(require,module,exports){ -'use strict'; + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } -var hash = require('hash.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var KeyPair = require('./key'); -var Signature = require('./signature'); + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. - if (!(this instanceof EDDSA)) - return new EDDSA(curve); + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } - var curve = elliptic.curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; -} + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. -module.exports = EDDSA; + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { -/** -* @param {Array|String} message - message bytes -* @param {Array|String|KeyPair} secret - secret bytes or a keypair -* @returns {Signature} - signature -*/ -EDDSA.prototype.sign = function sign(message, secret) { - message = parseBytes(message); - var key = this.keyFromSecret(secret); - var r = this.hashInt(key.messagePrefix(), message); - var R = this.g.mul(r); - var Rencoded = this.encodePoint(R); - var s_ = this.hashInt(Rencoded, key.pubBytes(), message) - .mul(key.priv()); - var S = r.add(s_).umod(this.curve.n); - return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); -}; + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { -/** -* @param {Array} message - message bytes -* @param {Array|String|Signature} sig - sig bytes -* @param {Array|String|Point|KeyPair} pub - public key -* @returns {Boolean} - true if public key matches sig of message -*/ -EDDSA.prototype.verify = function verify(message, sig, pub) { - message = parseBytes(message); - sig = this.makeSignature(sig); - var key = this.keyFromPublic(pub); - var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); - var SG = this.g.mul(sig.S()); - var RplusAh = sig.R().add(key.pub().mul(h)); - return RplusAh.eq(SG); -}; + if (index >= inputLength) { + error('invalid-input'); + } -EDDSA.prototype.hashInt = function hashInt() { - var hash = this.hash(); - for (var i = 0; i < arguments.length; i++) - hash.update(arguments[i]); - return utils.intFromLE(hash.digest()).umod(this.curve.n); -}; + digit = basicToDigit(input.charCodeAt(index++)); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; + if (digit < t) { + break; + } -/** -* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 -* -* EDDSA defines methods for encoding and decoding points and integers. These are -* helper convenience methods, that pass along to utility functions implied -* parameters. -* -*/ -EDDSA.prototype.encodePoint = function encodePoint(point) { - var enc = point.getY().toArray('le', this.encodingLength); - enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; - return enc; -}; + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); + w *= baseMinusT; - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + } - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; + n += floor(i / out); + i %= out; -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); -},{"../../elliptic":221,"./key":232,"./signature":233,"hash.js":244}],232:[function(require,module,exports){ -'use strict'; + } -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var cachedProperty = utils.cachedProperty; + return ucs2encode(output); + } -/** -* @param {EDDSA} eddsa - instance -* @param {Object} params - public/private key parameters -* -* @param {Array} [params.secret] - secret seed bytes -* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) -* @param {Array} [params.pub] - public key point encoded as bytes -* -*/ -function KeyPair(eddsa, params) { - this.eddsa = eddsa; - this._secret = parseBytes(params.secret); - if (eddsa.isPoint(params.pub)) - this._pub = params.pub; - else - this._pubBytes = parseBytes(params.pub); -} + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; + // Cache the length + inputLength = input.length; -KeyPair.prototype.secret = function secret() { - return this._secret; -}; + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + handledCPCount = basicLength = output.length; -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } - return a; -}); + // Main encoding loop: + while (handledCPCount < inputLength) { -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); + delta += (m - n) * handledCPCountPlusOne; + n = m; -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } -module.exports = KeyPair; + ++delta; + ++n; -},{"../../elliptic":221}],233:[function(require,module,exports){ -'use strict'; + } + return output.join(''); + } -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } -/** -* @param {EDDSA} eddsa - eddsa instance -* @param {Array|Object} sig - -* @param {Array|Point} [sig.R] - R point as Point or bytes -* @param {Array|bn} [sig.S] - S scalar as bn or bytes -* @param {Array} [sig.Rencoded] - R point encoded -* @param {Array} [sig.Sencoded] - S scalar encoded -*/ -function Signature(eddsa, sig) { - this.eddsa = eddsa; + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } - if (typeof sig !== 'object') - sig = parseBytes(sig); + /*--------------------------------------------------------------------------*/ - if (Array.isArray(sig)) { - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength) - }; - } + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; - assert(sig.R && sig.S, 'Signature without R or S'); + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { + // in Node.js, io.js, or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { + // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { + // in Rhino or a web browser + root.punycode = punycode; + } - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; +}(this)); - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],243:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); +},{"./lib/_stream_duplex.js":244}],244:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); +'use strict'; -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); +/**/ -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); -}; +var pna = require('process-nextick-args'); +/**/ -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; }; - -module.exports = Signature; - -},{"../../elliptic":221,"bn.js":90}],234:[function(require,module,exports){ -module.exports = { - doubles: { - step: 4, - points: [ - [ - 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', - 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821' - ], - [ - '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', - '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf' - ], - [ - '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', - 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695' - ], - [ - '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', - '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9' - ], - [ - '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', - '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36' - ], - [ - '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', - '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f' - ], - [ - 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', - '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999' - ], - [ - '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', - 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09' - ], - [ - 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', - '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d' - ], - [ - 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', - 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088' - ], - [ - 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', - '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d' - ], - [ - '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', - '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8' - ], - [ - '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', - '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a' - ], - [ - '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', - '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453' - ], - [ - '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', - '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160' - ], - [ - '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', - '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0' - ], - [ - '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', - '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6' - ], - [ - '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', - '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589' - ], - [ - '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', - 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17' - ], - [ - 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', - '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda' - ], - [ - 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', - '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd' - ], - [ - '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', - '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2' - ], - [ - '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', - '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6' - ], - [ - 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', - '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f' - ], - [ - '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', - 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01' - ], - [ - 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', - '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3' - ], - [ - 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', - 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f' - ], - [ - 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', - '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7' - ], - [ - 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', - 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78' - ], - [ - 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', - '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1' - ], - [ - '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', - 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150' - ], - [ - '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', - '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82' - ], - [ - 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', - '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc' - ], - [ - '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', - 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b' - ], - [ - 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', - '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51' - ], - [ - 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', - '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45' - ], - [ - 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', - 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120' - ], - [ - '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', - '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84' - ], - [ - '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', - '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d' - ], - [ - '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', - 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d' - ], - [ - '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', - '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8' - ], - [ - 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', - '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8' - ], - [ - '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', - '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac' - ], - [ - '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', - 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f' - ], - [ - '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', - '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962' - ], - [ - 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', - '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907' - ], - [ - '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', - 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec' - ], - [ - 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', - 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d' - ], - [ - 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', - '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414' - ], - [ - '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', - 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd' - ], - [ - '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', - 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0' - ], - [ - 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', - '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811' - ], - [ - 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', - '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1' - ], - [ - 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', - '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c' - ], - [ - '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', - 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73' - ], - [ - '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', - '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd' - ], - [ - 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', - 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405' - ], - [ - '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', - 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589' - ], - [ - '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', - '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e' - ], - [ - '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', - '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27' - ], - [ - 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', - 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1' - ], - [ - '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', - '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482' - ], - [ - '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', - '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945' - ], - [ - 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', - '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573' - ], - [ - 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', - 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82' - ] - ] +/**/ + +module.exports = Duplex; + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; }, - naf: { - wnd: 7, - points: [ - [ - 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', - '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672' - ], - [ - '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', - 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6' - ], - [ - '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', - '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da' - ], - [ - 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', - 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37' - ], - [ - '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', - 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b' - ], - [ - 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', - 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81' - ], - [ - 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', - '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58' - ], - [ - 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', - '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77' - ], - [ - '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', - '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a' - ], - [ - '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', - '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c' - ], - [ - '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', - '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67' - ], - [ - '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', - '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402' - ], - [ - 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', - 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55' - ], - [ - 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', - '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482' - ], - [ - '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', - 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82' - ], - [ - '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', - 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396' - ], - [ - '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', - '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49' - ], - [ - '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', - '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf' - ], - [ - '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', - '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a' - ], - [ - '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', - 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7' - ], - [ - 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', - 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933' - ], - [ - '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', - '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a' - ], - [ - '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', - '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6' - ], - [ - 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', - 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37' - ], - [ - '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', - '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e' - ], - [ - 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', - 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6' - ], - [ - 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', - 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476' - ], - [ - '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', - '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40' - ], - [ - '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', - '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61' - ], - [ - '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', - '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683' - ], - [ - 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', - '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5' - ], - [ - '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', - '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b' - ], - [ - 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', - '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417' - ], - [ - '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', - 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868' - ], - [ - '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', - 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a' - ], - [ - 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', - 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6' - ], - [ - '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', - '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996' - ], - [ - '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', - 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e' - ], - [ - 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', - 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d' - ], - [ - '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', - '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2' - ], - [ - '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', - 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e' - ], - [ - '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', - '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437' - ], - [ - '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', - 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311' - ], - [ - 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', - '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4' - ], - [ - '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', - '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575' - ], - [ - '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', - 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d' - ], - [ - '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', - 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d' - ], - [ - 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', - 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629' - ], - [ - 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', - 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06' - ], - [ - '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', - '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374' - ], - [ - '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', - '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee' - ], - [ - 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', - '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1' - ], - [ - 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', - 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b' - ], - [ - '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', - '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661' - ], - [ - '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', - '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6' - ], - [ - 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', - '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e' - ], - [ - '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', - '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d' - ], - [ - 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', - 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc' - ], - [ - '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', - 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4' - ], - [ - '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', - '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c' - ], - [ - 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', - '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b' - ], - [ - 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', - '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913' - ], - [ - '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', - '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154' - ], - [ - '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', - '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865' - ], - [ - '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', - 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc' - ], - [ - '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', - 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224' - ], - [ - '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', - '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e' - ], - [ - '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', - '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6' - ], - [ - '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', - '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511' - ], - [ - '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', - 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b' - ], - [ - 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', - 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2' - ], - [ - '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', - 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c' - ], - [ - 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', - '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3' - ], - [ - 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', - '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d' - ], - [ - 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', - '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700' - ], - [ - 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', - '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4' - ], - [ - '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', - 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196' - ], - [ - '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', - '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4' - ], - [ - '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', - 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257' - ], - [ - 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', - 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13' - ], - [ - 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', - '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096' - ], - [ - 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', - 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38' - ], - [ - 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', - '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f' - ], - [ - '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', - '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448' - ], - [ - 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', - '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a' - ], - [ - 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', - '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4' - ], - [ - '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', - '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437' - ], - [ - '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', - 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7' - ], - [ - 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', - '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d' - ], - [ - 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', - '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a' - ], - [ - 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', - '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54' - ], - [ - '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', - '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77' - ], - [ - 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', - 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517' - ], - [ - '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', - 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10' - ], - [ - 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', - 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125' - ], - [ - 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', - '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e' - ], - [ - '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', - 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1' - ], - [ - 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', - '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2' - ], - [ - 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', - '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423' - ], - [ - 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', - '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8' - ], - [ - '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', - 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758' - ], - [ - '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', - 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375' - ], - [ - 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', - '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d' - ], - [ - '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', - 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec' - ], - [ - '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', - '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0' - ], - [ - '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', - 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c' - ], - [ - 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', - 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4' - ], - [ - '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', - 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f' - ], - [ - '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', - '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649' - ], - [ - '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', - 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826' - ], - [ - '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', - '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5' - ], - [ - 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', - 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87' - ], - [ - '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', - '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b' - ], - [ - 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', - '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc' - ], - [ - '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', - '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c' - ], - [ - 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', - 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f' - ], - [ - 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', - '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a' - ], - [ - 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', - 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46' - ], - [ - '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', - 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f' - ], - [ - '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', - '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03' - ], - [ - '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', - 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08' - ], - [ - '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', - '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8' - ], - [ - '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', - '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373' - ], - [ - '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', - 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3' - ], - [ - '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', - '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8' - ], - [ - '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', - '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1' - ], - [ - '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', - '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9' - ] - ] + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; +},{"./_stream_readable":246,"./_stream_writable":248,"core-util-is":136,"inherits":279,"process-nextick-args":252}],245:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":247,"core-util-is":136,"inherits":279}],246:[function(require,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":244,"./internal/streams/BufferList":249,"./internal/streams/destroy":250,"./internal/streams/stream":251,"_process":291,"core-util-is":136,"events":241,"inherits":279,"isarray":281,"process-nextick-args":252,"safe-buffer":258,"string_decoder/":253,"util":239}],247:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} +},{"./_stream_duplex":244,"core-util-is":136,"inherits":279}],248:[function(require,module,exports){ +(function (process,global,setImmediate){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = require('./internal/streams/destroy'); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } + + return ret; }; -},{}],235:[function(require,module,exports){ -'use strict'; +Writable.prototype.cork = function () { + var state = this._writableState; -var utils = exports; -var BN = require('bn.js'); -var minAssert = require('minimalistic-assert'); -var minUtils = require('minimalistic-crypto-utils'); + state.corked++; +}; -utils.assert = minAssert; -utils.toArray = minUtils.toArray; -utils.zero2 = minUtils.zero2; -utils.toHex = minUtils.toHex; -utils.encode = minUtils.encode; +Writable.prototype.uncork = function () { + var state = this._writableState; -// Represent num in a w-NAF form -function getNAF(num, w) { - var naf = []; - var ws = 1 << (w + 1); - var k = num.clone(); - while (k.cmpn(1) >= 0) { - var z; - if (k.isOdd()) { - var mod = k.andln(ws - 1); - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); - } else { - z = 0; - } - naf.push(z); + if (state.corked) { + state.corked--; - // Optimization, shift by word if possible - var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; - for (var i = 1; i < shift; i++) - naf.push(0); - k.iushrn(shift); + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } +}; - return naf; -} -utils.getNAF = getNAF; +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; -// Represent k1, k2 in a Joint Sparse Form -function getJSF(k1, k2) { - var jsf = [ - [], - [] - ]; +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; - } else { - var m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; } - jsf[0].push(u1); + } + var len = state.objectMode ? 1 : chunk.length; - var u2; - if ((m24 & 1) === 0) { - u2 = 0; + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; } else { - var m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; + state.bufferedRequest = state.lastBufferedRequest; } - jsf[1].push(u2); - - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); } - return jsf; + return ret; } -utils.getJSF = getJSF; -function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); - }; +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; } -utils.cachedProperty = cachedProperty; -function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; -} -utils.parseBytes = parseBytes; +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; -function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } } -utils.intFromLE = intFromLE; - -},{"bn.js":90,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],236:[function(require,module,exports){ -module.exports={ - "_from": "elliptic@^6.2.3", - "_id": "elliptic@6.4.1", - "_inBundle": false, - "_integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", - "_location": "/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "elliptic@^6.2.3", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "^6.2.3", - "saveSpec": null, - "fetchSpec": "^6.2.3" - }, - "_requiredBy": [ - "/create-ecdh", - "/crypto-browserify/browserify-sign", - "/secp256k1" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "_shasum": "c2d0b7776911b86722c632c3c06c60f2f819939a", - "_spec": "elliptic@^6.2.3", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/secp256k1", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "bundleDependencies": false, - "dependencies": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - }, - "deprecated": false, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^1.4.3", - "coveralls": "^2.11.3", - "grunt": "^0.4.5", - "grunt-browserify": "^5.0.0", - "grunt-cli": "^1.2.0", - "grunt-contrib-connect": "^1.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-mocha-istanbul": "^3.0.1", - "grunt-saucelabs": "^8.6.2", - "istanbul": "^0.4.2", - "jscs": "^2.9.0", - "jshint": "^2.6.0", - "mocha": "^2.1.0" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "lint": "npm run jscs && npm run jshint", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.4.1" +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; } -},{}],237:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var MD5 = require('md5.js') - -/* eslint-disable camelcase */ -function EVP_BytesToKey (password, salt, keyBits, ivLen) { - if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') - if (salt) { - if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') - if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') - } - - var keyLen = keyBits / 8 - var key = Buffer.alloc(keyLen) - var iv = Buffer.alloc(ivLen || 0) - var tmp = Buffer.alloc(0) +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; - while (keyLen > 0 || ivLen > 0) { - var hash = new MD5() - hash.update(tmp) - hash.update(password) - if (salt) hash.update(salt) - tmp = hash.digest() + onwriteStateUpdate(state); - var used = 0 + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); - if (keyLen > 0) { - var keyStart = key.length - keyLen - used = Math.min(keyLen, tmp.length) - tmp.copy(key, keyStart, 0, used) - keyLen -= used + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); } - if (used < tmp.length && ivLen > 0) { - var ivStart = iv.length - ivLen - var length = Math.min(ivLen, tmp.length - used) - tmp.copy(iv, ivStart, used, used + length) - ivLen -= length + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); } } +} - tmp.fill(0) - return { key: key, iv: iv } +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); } -module.exports = EVP_BytesToKey +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} -},{"md5.js":263,"safe-buffer":322}],238:[function(require,module,exports){ -arguments[4][104][0].apply(exports,arguments) -},{"dup":104}],239:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); }; -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; +Writable.prototype._writev = null; - if (!this._events) - this._events = {}; +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; } - handler = this._events[type]; + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - if (isUndefined(handler)) - return false; + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); } +} - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; } +}); - return this; +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); }; +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,"_process":291,"core-util-is":136,"inherits":279,"process-nextick-args":252,"safe-buffer":258,"timers":372,"util-deprecate":381}],249:[function(require,module,exports){ +'use strict'; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); - var fired = false; +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} - function g() { - this.removeListener(type, g); +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); - if (!fired) { - fired = true; - listener.apply(this, arguments); - } + this.head = null; + this.tail = null; + this.length = 0; } - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; - if (!this._events || !this._events[type]) - return this; + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; - list = this._events[type]; - length = list.length; - position = -1; + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; } + return ret; + }; - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } + return BufferList; +}(); - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} +},{"safe-buffer":258,"util":239}],250:[function(require,module,exports){ +'use strict'; - return this; -}; +/**/ -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; +var pna = require('process-nextick-args'); +/**/ - if (!this._events) - return this; +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); } - this.removeAllListeners('removeListener'); - this._events = {}; return this; } - listeners = this._events[type]; + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); + if (this._readableState) { + this._readableState.destroyed = true; } - delete this._events[type]; - return this; -}; + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; + return this; +} - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; -function isFunction(arg) { - return typeof arg === 'function'; + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } } -function isNumber(arg) { - return typeof arg === 'number'; +function emitErrorNT(self, err) { + self.emit('error', err); } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":252}],251:[function(require,module,exports){ +module.exports = require('events').EventEmitter; + +},{"events":241}],252:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +if (typeof process === 'undefined' || + !process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process } -function isUndefined(arg) { - return arg === void 0; +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } } -},{}],240:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } +}).call(this)}).call(this,require('_process')) +},{"_process":291}],253:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, +'use strict'; - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 +/**/ - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' +var Buffer = require('safe-buffer').Buffer; +/**/ - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, +StringDecoder.prototype.end = utf8End; - /** Temporary variable */ - key; +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; - /*--------------------------------------------------------------------------*/ +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":258}],254:[function(require,module,exports){ +module.exports = require('./readable').PassThrough - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. +},{"./readable":255}],255:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { +},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(require,module,exports){ +module.exports = require('./readable').Transform - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { +},{"./readable":255}],257:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); - if (index >= inputLength) { - error('invalid-input'); - } +},{"./lib/_stream_writable.js":248}],258:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer - digit = basicToDigit(input.charCodeAt(index++)); +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) - if (digit < t) { - break; - } +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} - w *= baseMinusT; +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} - } +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); +},{"buffer":130}],259:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } +module.exports = Stream; - n += floor(i / out); - i %= out; +var EE = require('events').EventEmitter; +var inherits = require('inherits'); - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); - } +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; - return ucs2encode(output); - } - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. - // Cache the length - inputLength = input.length; +function Stream() { + EE.call(this); +} - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; +Stream.prototype.pipe = function(dest, options) { + var source = this; - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } - handledCPCount = basicLength = output.length; + source.on('data', ondata); - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } + dest.on('drain', ondrain); - // Main encoding loop: - while (handledCPCount < inputLength) { + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } + dest.end(); + } - delta += (m - n) * handledCPCountPlusOne; - n = m; - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; + function onclose() { + if (didOnEnd) return; + didOnEnd = true; - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } + if (typeof dest.destroy === 'function') dest.destroy(); + } - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } + source.on('error', onerror); + dest.on('error', onerror); - ++delta; - ++n; + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); - } - return output.join(''); - } + source.removeListener('end', onend); + source.removeListener('close', onclose); - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } + source.removeListener('error', onerror); + dest.removeListener('error', onerror); - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); - /*--------------------------------------------------------------------------*/ + dest.removeListener('close', cleanup); + } - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; + source.on('end', cleanup); + source.on('close', cleanup); - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } + dest.on('close', cleanup); -}(this)); + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],241:[function(require,module,exports){ +},{"events":241,"inherits":279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -59706,150 +66363,16 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":322}],242:[function(require,module,exports){ -var indexOf = require('indexof'); - -var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var defineProp = (function() { - try { - Object.defineProperty({}, '_', {}); - return function(obj, name, value) { - Object.defineProperty(obj, name, { - writable: true, - enumerable: false, - configurable: true, - value: value - }) - }; - } catch(e) { - return function(obj, name, value) { - obj[name] = value; - }; - } -}()); - -var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function', -'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError', -'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError', -'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', -'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; - -function Context() {} -Context.prototype = {}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -Script.prototype.runInContext = function (context) { - if (!(context instanceof Context)) { - throw new TypeError("needs a 'context' argument."); - } - - var iframe = document.createElement('iframe'); - if (!iframe.style) iframe.style = {}; - iframe.style.display = 'none'; - - document.body.appendChild(iframe); - - var win = iframe.contentWindow; - var wEval = win.eval, wExecScript = win.execScript; - - if (!wEval && wExecScript) { - // win.eval() magically appears when this is called in IE: - wExecScript.call(win, 'null'); - wEval = win.eval; - } - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - }); - forEach(globals, function (key) { - if (context[key]) { - win[key] = context[key]; - } - }); - - var winKeys = Object_keys(win); - - var res = wEval.call(win, this.code); - - forEach(Object_keys(win), function (key) { - // Avoid copying circular objects like `top` and `window` by only - // updating existing context properties or new properties in the `win` - // that was only introduced after the eval. - if (key in context || indexOf(winKeys, key) === -1) { - context[key] = win[key]; - } - }); - - forEach(globals, function (key) { - if (!(key in context)) { - defineProp(context, key, win[key]); - } - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInNewContext = function (context) { - var ctx = Script.createContext(context); - var res = this.runInContext(ctx); - - forEach(Object_keys(ctx), function (key) { - context[key] = ctx[key]; - }); - - return res; -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - var copy = new Context(); - if(typeof context === 'object') { - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - } - return copy; -}; - -},{"indexof":258}],243:[function(require,module,exports){ +},{"safe-buffer":258}],261:[function(require,module,exports){ +arguments[4][25][0].apply(exports,arguments) +},{"dup":25}],262:[function(require,module,exports){ +arguments[4][26][0].apply(exports,arguments) +},{"dup":26}],263:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./support/isBuffer":262,"_process":291,"dup":27,"inherits":261}],264:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer -var Transform = require('stream').Transform +var Transform = require('readable-stream').Transform var inherits = require('inherits') function throwIfNotStringOrBuffer (val, prefix) { @@ -59943,7 +66466,7 @@ HashBase.prototype._digest = function () { module.exports = HashBase -},{"inherits":259,"safe-buffer":322,"stream":338}],244:[function(require,module,exports){ +},{"inherits":279,"readable-stream":343,"safe-buffer":345}],265:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -59960,7 +66483,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(require,module,exports){ +},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -60054,7 +66577,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":255,"minimalistic-assert":266}],246:[function(require,module,exports){ +},{"./utils":276,"minimalistic-assert":286}],267:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -60103,7 +66626,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":255,"minimalistic-assert":266}],247:[function(require,module,exports){ +},{"./utils":276,"minimalistic-assert":286}],268:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -60251,7 +66774,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":245,"./utils":255}],248:[function(require,module,exports){ +},{"./common":266,"./utils":276}],269:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -60260,7 +66783,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":249,"./sha/224":250,"./sha/256":251,"./sha/384":252,"./sha/512":253}],249:[function(require,module,exports){ +},{"./sha/1":270,"./sha/224":271,"./sha/256":272,"./sha/384":273,"./sha/512":274}],270:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60336,7 +66859,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":245,"../utils":255,"./common":254}],250:[function(require,module,exports){ +},{"../common":266,"../utils":276,"./common":275}],271:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60368,7 +66891,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":255,"./256":251}],251:[function(require,module,exports){ +},{"../utils":276,"./256":272}],272:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60475,7 +66998,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":245,"../utils":255,"./common":254,"minimalistic-assert":266}],252:[function(require,module,exports){ +},{"../common":266,"../utils":276,"./common":275,"minimalistic-assert":286}],273:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60512,7 +67035,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":255,"./512":253}],253:[function(require,module,exports){ +},{"../utils":276,"./512":274}],274:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60844,7 +67367,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":245,"../utils":255,"minimalistic-assert":266}],254:[function(require,module,exports){ +},{"../common":266,"../utils":276,"minimalistic-assert":286}],275:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -60895,7 +67418,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":255}],255:[function(require,module,exports){ +},{"../utils":276}],276:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -61175,7 +67698,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":259,"minimalistic-assert":266}],256:[function(require,module,exports){ +},{"inherits":279,"minimalistic-assert":286}],277:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -61290,7 +67813,8 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":244,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],257:[function(require,module,exports){ +},{"hash.js":265,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],278:[function(require,module,exports){ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -61376,20 +67900,36 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],258:[function(require,module,exports){ - -var indexOf = [].indexOf; - -module.exports = function(arr, obj){ - if (indexOf) return arr.indexOf(obj); - for (var i = 0; i < arr.length; ++i) { - if (arr[i] === obj) return i; +},{}],279:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } - return -1; -}; -},{}],259:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],260:[function(require,module,exports){ +} + +},{}],280:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -61412,19 +67952,19 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],261:[function(require,module,exports){ +},{}],281:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],262:[function(require,module,exports){ -(function (global){ +},{}],282:[function(require,module,exports){ +(function (global){(function (){ /** * @license * Lodash - * Copyright JS Foundation and other contributors + * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -61435,14 +67975,15 @@ module.exports = Array.isArray || function (arr) { var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.11'; + var VERSION = '4.17.21'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** Error message constants. */ var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', - FUNC_ERROR_TEXT = 'Expected a function'; + FUNC_ERROR_TEXT = 'Expected a function', + INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; @@ -61575,10 +68116,11 @@ module.exports = Array.isArray || function (arr) { var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g, - reTrimStart = /^\s+/, - reTrimEnd = /\s+$/; + /** Used to match leading whitespace. */ + var reTrimStart = /^\s+/; + + /** Used to match a single whitespace character. */ + var reWhitespace = /\s/; /** Used to match wrap detail comments. */ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, @@ -61588,6 +68130,18 @@ module.exports = Array.isArray || function (arr) { /** Used to match words composed of alphanumeric characters. */ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + /** + * Used to validate the `validate` option in `_.template` variable. + * + * Forbids characters which could potentially change the meaning of the function argument definition: + * - "()," (modification of function parameters) + * - "=" (default value) + * - "[]{}" (destructuring of function parameters) + * - "/" (beginning of a comment) + * - whitespace + */ + var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; + /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; @@ -62416,6 +68970,19 @@ module.exports = Array.isArray || function (arr) { }); } + /** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ + function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; + } + /** * The base implementation of `_.unary` without support for storing metadata. * @@ -62749,6 +69316,21 @@ module.exports = Array.isArray || function (arr) { : asciiToArray(string); } + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; + } + /** * Used by `_.unescape` to convert HTML entities to characters. * @@ -64094,16 +70676,10 @@ module.exports = Array.isArray || function (arr) { value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); - - return result; - } - - if (isMap(value)) { + } else if (isMap(value)) { value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); - - return result; } var keysFunc = isFull @@ -65027,8 +71603,8 @@ module.exports = Array.isArray || function (arr) { return; } baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); if (isObject(srcValue)) { - stack || (stack = new Stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { @@ -65148,8 +71724,21 @@ module.exports = Array.isArray || function (arr) { * @returns {Array} Returns the new sorted array. */ function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } + var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); var result = baseMap(collection, function(value, key, collection) { var criteria = arrayMap(iteratees, function(iteratee) { @@ -65406,6 +71995,10 @@ module.exports = Array.isArray || function (arr) { var key = toKey(path[index]), newValue = value; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + if (index != lastIndex) { var objValue = nested[key]; newValue = customizer ? customizer(objValue, key, nested) : undefined; @@ -65558,11 +72151,14 @@ module.exports = Array.isArray || function (arr) { * into `array`. */ function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, + high = array == null ? 0 : array.length; + if (high === 0) { + return 0; + } + + value = iteratee(value); + var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol(value), valIsUndefined = value === undefined; @@ -66845,7 +73441,7 @@ module.exports = Array.isArray || function (arr) { return function(number, precision) { number = toNumber(number); precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); - if (precision) { + if (precision && nativeIsFinite(number)) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. var pair = (toString(number) + 'e').split('e'), @@ -67047,10 +73643,11 @@ module.exports = Array.isArray || function (arr) { if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; } var index = -1, result = true, @@ -67212,10 +73809,11 @@ module.exports = Array.isArray || function (arr) { return false; } } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; } var result = true; stack.set(object, other); @@ -68028,7 +74626,7 @@ module.exports = Array.isArray || function (arr) { } /** - * Gets the value at `key`, unless `key` is "__proto__". + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". * * @private * @param {Object} object The object to query. @@ -68036,6 +74634,10 @@ module.exports = Array.isArray || function (arr) { * @returns {*} Returns the property value. */ function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + if (key == '__proto__') { return; } @@ -70592,6 +77194,10 @@ module.exports = Array.isArray || function (arr) { * // The `_.property` iteratee shorthand. * _.filter(users, 'active'); * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] */ function filter(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -71341,15 +77947,15 @@ module.exports = Array.isArray || function (arr) { * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, + * { 'user': 'fred', 'age': 30 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] */ var sortBy = baseRest(function(collection, iteratees) { if (collection == null) { @@ -71836,6 +78442,7 @@ module.exports = Array.isArray || function (arr) { } if (maxing) { // Handle invocations in a tight loop. + clearTimeout(timerId); timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } @@ -73892,7 +80499,7 @@ module.exports = Array.isArray || function (arr) { if (typeof value != 'string') { return value === 0 ? value : +value; } - value = value.replace(reTrim, ''); + value = baseTrim(value); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) @@ -76222,9 +82829,12 @@ module.exports = Array.isArray || function (arr) { , 'g'); // Use a sourceURL for easier debugging. + // The sourceURL gets injected into the source that's eval-ed, so be careful + // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in + // and escape the comment, thus injecting code that gets evaled. var sourceURL = '//# sourceURL=' + - ('sourceURL' in options - ? options.sourceURL + (hasOwnProperty.call(options, 'sourceURL') + ? (options.sourceURL + '').replace(/\s/g, ' ') : ('lodash.templateSources[' + (++templateCounter) + ']') ) + '\n'; @@ -76257,10 +82867,16 @@ module.exports = Array.isArray || function (arr) { // If `variable` is not specified wrap a with-statement around the generated // code to add the data object to the top of the scope chain. - var variable = options.variable; + var variable = hasOwnProperty.call(options, 'variable') && options.variable; if (!variable) { source = 'with (obj) {\n' + source + '\n}\n'; } + // Throw an error if a forbidden character was found in `variable`, to prevent + // potential command injection attacks. + else if (reForbiddenIdentifierChars.test(variable)) { + throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); + } + // Cleanup code by stripping empty strings. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) .replace(reEmptyStringMiddle, '$1') @@ -76374,7 +82990,7 @@ module.exports = Array.isArray || function (arr) { function trim(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); + return baseTrim(string); } if (!string || !(chars = baseToString(chars))) { return string; @@ -76409,7 +83025,7 @@ module.exports = Array.isArray || function (arr) { function trimEnd(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrimEnd, ''); + return string.slice(0, trimmedEndIndex(string) + 1); } if (!string || !(chars = baseToString(chars))) { return string; @@ -76963,6 +83579,9 @@ module.exports = Array.isArray || function (arr) { * values against any array or object value, respectively. See `_.isEqual` * for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.0.0 @@ -76978,6 +83597,10 @@ module.exports = Array.isArray || function (arr) { * * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); * // => [{ 'a': 4, 'b': 5, 'c': 6 }] + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matches(source) { return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); @@ -76992,6 +83615,9 @@ module.exports = Array.isArray || function (arr) { * `srcValue` values against any array or object value, respectively. See * `_.isEqual` for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.2.0 @@ -77008,6 +83634,10 @@ module.exports = Array.isArray || function (arr) { * * _.find(objects, _.matchesProperty('a', 4)); * // => { 'a': 4, 'b': 5, 'c': 6 } + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matchesProperty(path, srcValue) { return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); @@ -77231,6 +83861,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **all** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -77257,6 +83891,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **any** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -77276,6 +83914,9 @@ module.exports = Array.isArray || function (arr) { * * func(NaN); * // => false + * + * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) + * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) */ var overSome = createOver(arraySome); @@ -78462,10 +85103,11 @@ module.exports = Array.isArray || function (arr) { baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { - var key = (lodashFunc.name + ''), - names = realNames[key] || (realNames[key] = []); - - names.push({ 'name': methodName, 'func': lodashFunc }); + var key = lodashFunc.name + ''; + if (!hasOwnProperty.call(realNames, key)) { + realNames[key] = []; + } + realNames[key].push({ 'name': methodName, 'func': lodashFunc }); } }); @@ -78529,8 +85171,8 @@ module.exports = Array.isArray || function (arr) { } }.call(this)); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],263:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],283:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var HashBase = require('hash-base') @@ -78678,8 +85320,8 @@ function fnI (a, b, c, d, m, k, s) { module.exports = MD5 -},{"hash-base":243,"inherits":259,"safe-buffer":322}],264:[function(require,module,exports){ -(function (Buffer){ +},{"hash-base":264,"inherits":279,"safe-buffer":345}],284:[function(require,module,exports){ +(function (Buffer){(function (){ // constant-space merkle root calculation algorithm module.exports = function fastRoot (values, digestFn) { if (!Array.isArray(values)) throw TypeError('Expected values Array') @@ -78705,8 +85347,8 @@ module.exports = function fastRoot (values, digestFn) { return results[0] } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],265:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],285:[function(require,module,exports){ var bn = require('bn.js'); var brorand = require('brorand'); @@ -78823,7 +85465,7 @@ MillerRabin.prototype.getDivisor = function getDivisor(n, k) { return false; }; -},{"bn.js":90,"brorand":103}],266:[function(require,module,exports){ +},{"bn.js":90,"brorand":103}],286:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -78836,7 +85478,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],267:[function(require,module,exports){ +},{}],287:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -78896,7 +85538,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],268:[function(require,module,exports){ +},{}],288:[function(require,module,exports){ /** * Helpers. */ @@ -79050,8 +85692,100 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } -},{}],269:[function(require,module,exports){ -(function (Buffer){ +},{}],289:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],290:[function(require,module,exports){ +(function (Buffer){(function (){ var createHmac = require('create-hmac') var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs @@ -79133,56 +85867,8 @@ function pbkdf2Sync (password, salt, iterations, keylen, digest) { return DK } -}).call(this,require("buffer").Buffer) -},{"buffer":131,"create-hmac":141}],270:[function(require,module,exports){ -(function (process){ -'use strict'; - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - -}).call(this,require('_process')) -},{"_process":271}],271:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130,"create-hmac":140}],291:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -79368,7 +86054,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],272:[function(require,module,exports){ +},{}],292:[function(require,module,exports){ exports.publicEncrypt = require('./publicEncrypt') exports.privateDecrypt = require('./privateDecrypt') @@ -79380,7 +86066,7 @@ exports.publicDecrypt = function publicDecrypt (key, buf) { return exports.privateDecrypt(key, buf, true) } -},{"./privateDecrypt":294,"./publicEncrypt":295}],273:[function(require,module,exports){ +},{"./privateDecrypt":315,"./publicEncrypt":316}],293:[function(require,module,exports){ var createHash = require('create-hash') var Buffer = require('safe-buffer').Buffer @@ -79401,47 +86087,49 @@ function i2ops (c) { return out } -},{"create-hash":139,"safe-buffer":322}],274:[function(require,module,exports){ +},{"create-hash":138,"safe-buffer":345}],294:[function(require,module,exports){ +arguments[4][143][0].apply(exports,arguments) +},{"./asn1/api":295,"./asn1/base":297,"./asn1/constants":301,"./asn1/decoders":303,"./asn1/encoders":306,"bn.js":90,"dup":143}],295:[function(require,module,exports){ arguments[4][144][0].apply(exports,arguments) -},{"./asn1/api":275,"./asn1/base":277,"./asn1/constants":281,"./asn1/decoders":283,"./asn1/encoders":286,"bn.js":90,"dup":144}],275:[function(require,module,exports){ +},{"./decoders":303,"./encoders":306,"dup":144,"inherits":279}],296:[function(require,module,exports){ arguments[4][145][0].apply(exports,arguments) -},{"../asn1":274,"dup":145,"inherits":259,"vm":242}],276:[function(require,module,exports){ +},{"../base/reporter":299,"dup":145,"inherits":279,"safer-buffer":346}],297:[function(require,module,exports){ arguments[4][146][0].apply(exports,arguments) -},{"../base":277,"buffer":131,"dup":146,"inherits":259}],277:[function(require,module,exports){ +},{"./buffer":296,"./node":298,"./reporter":299,"dup":146}],298:[function(require,module,exports){ arguments[4][147][0].apply(exports,arguments) -},{"./buffer":276,"./node":278,"./reporter":279,"dup":147}],278:[function(require,module,exports){ +},{"../base/buffer":296,"../base/reporter":299,"dup":147,"minimalistic-assert":286}],299:[function(require,module,exports){ arguments[4][148][0].apply(exports,arguments) -},{"../base":277,"dup":148,"minimalistic-assert":266}],279:[function(require,module,exports){ +},{"dup":148,"inherits":279}],300:[function(require,module,exports){ arguments[4][149][0].apply(exports,arguments) -},{"dup":149,"inherits":259}],280:[function(require,module,exports){ +},{"dup":149}],301:[function(require,module,exports){ arguments[4][150][0].apply(exports,arguments) -},{"../constants":281,"dup":150}],281:[function(require,module,exports){ +},{"./der":300,"dup":150}],302:[function(require,module,exports){ arguments[4][151][0].apply(exports,arguments) -},{"./der":280,"dup":151}],282:[function(require,module,exports){ +},{"../base/buffer":296,"../base/node":298,"../constants/der":300,"bn.js":90,"dup":151,"inherits":279}],303:[function(require,module,exports){ arguments[4][152][0].apply(exports,arguments) -},{"../../asn1":274,"dup":152,"inherits":259}],283:[function(require,module,exports){ +},{"./der":302,"./pem":304,"dup":152}],304:[function(require,module,exports){ arguments[4][153][0].apply(exports,arguments) -},{"./der":282,"./pem":284,"dup":153}],284:[function(require,module,exports){ +},{"./der":302,"dup":153,"inherits":279,"safer-buffer":346}],305:[function(require,module,exports){ arguments[4][154][0].apply(exports,arguments) -},{"./der":282,"buffer":131,"dup":154,"inherits":259}],285:[function(require,module,exports){ +},{"../base/node":298,"../constants/der":300,"dup":154,"inherits":279,"safer-buffer":346}],306:[function(require,module,exports){ arguments[4][155][0].apply(exports,arguments) -},{"../../asn1":274,"buffer":131,"dup":155,"inherits":259}],286:[function(require,module,exports){ +},{"./der":305,"./pem":307,"dup":155}],307:[function(require,module,exports){ arguments[4][156][0].apply(exports,arguments) -},{"./der":285,"./pem":287,"dup":156}],287:[function(require,module,exports){ -arguments[4][157][0].apply(exports,arguments) -},{"./der":285,"dup":157,"inherits":259}],288:[function(require,module,exports){ +},{"./der":305,"dup":156,"inherits":279}],308:[function(require,module,exports){ +arguments[4][159][0].apply(exports,arguments) +},{"bn.js":309,"buffer":130,"dup":159,"randombytes":327}],309:[function(require,module,exports){ arguments[4][158][0].apply(exports,arguments) -},{"bn.js":90,"buffer":131,"dup":158,"randombytes":306}],289:[function(require,module,exports){ -arguments[4][165][0].apply(exports,arguments) -},{"dup":165}],290:[function(require,module,exports){ +},{"buffer":239,"dup":158}],310:[function(require,module,exports){ arguments[4][166][0].apply(exports,arguments) -},{"./certificate":291,"asn1.js":274,"dup":166}],291:[function(require,module,exports){ +},{"dup":166}],311:[function(require,module,exports){ arguments[4][167][0].apply(exports,arguments) -},{"asn1.js":274,"dup":167}],292:[function(require,module,exports){ +},{"./certificate":312,"asn1.js":294,"dup":167}],312:[function(require,module,exports){ arguments[4][168][0].apply(exports,arguments) -},{"browserify-aes":107,"buffer":131,"dup":168,"evp_bytestokey":237}],293:[function(require,module,exports){ +},{"asn1.js":294,"dup":168}],313:[function(require,module,exports){ arguments[4][169][0].apply(exports,arguments) -},{"./aesid.json":289,"./asn1":290,"./fixProc":292,"browserify-aes":107,"buffer":131,"dup":169,"pbkdf2":269}],294:[function(require,module,exports){ +},{"browserify-aes":106,"dup":169,"evp_bytestokey":238,"safe-buffer":345}],314:[function(require,module,exports){ +arguments[4][170][0].apply(exports,arguments) +},{"./aesid.json":310,"./asn1":311,"./fixProc":313,"browserify-aes":106,"dup":170,"pbkdf2":290,"safe-buffer":345}],315:[function(require,module,exports){ var parseKeys = require('parse-asn1') var mgf = require('./mgf') var xor = require('./xor') @@ -79548,7 +86236,7 @@ function compare (a, b) { return dif } -},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"safe-buffer":322}],295:[function(require,module,exports){ +},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(require,module,exports){ var parseKeys = require('parse-asn1') var randomBytes = require('randombytes') var createHash = require('create-hash') @@ -79638,7 +86326,7 @@ function nonZero (len) { return out } -},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"randombytes":306,"safe-buffer":322}],296:[function(require,module,exports){ +},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"randombytes":327,"safe-buffer":345}],317:[function(require,module,exports){ var BN = require('bn.js') var Buffer = require('safe-buffer').Buffer @@ -79652,7 +86340,7 @@ function withPublic (paddedMsg, key) { module.exports = withPublic -},{"bn.js":90,"safe-buffer":322}],297:[function(require,module,exports){ +},{"bn.js":90,"safe-buffer":345}],318:[function(require,module,exports){ module.exports = function xor (a, b) { var len = a.length var i = -1 @@ -79662,7 +86350,7 @@ module.exports = function xor (a, b) { return a } -},{}],298:[function(require,module,exports){ +},{}],319:[function(require,module,exports){ var OPS = require('bitcoin-ops') function encodingLength (i) { @@ -79741,8 +86429,8 @@ module.exports = { decode: decode } -},{"bitcoin-ops":41}],299:[function(require,module,exports){ -(function (process,setImmediate){ +},{"bitcoin-ops":41}],320:[function(require,module,exports){ +(function (process,setImmediate){(function (){ // vim:ts=4:sts=4:sw=4: /*! * @@ -81648,8 +88336,8 @@ return Q; }); -}).call(this,require('_process'),require("timers").setImmediate) -},{"_process":271,"timers":349}],300:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),require("timers").setImmediate) +},{"_process":291,"timers":372}],321:[function(require,module,exports){ /** this contains the max string length for all qr code Versions in Binary Safe / Byte Mode each entry is in the order of error correct level @@ -81702,7 +88390,7 @@ exports.QRCapacityTable = [ ,[2953,2331,1663,1273]//40 ]; -},{}],301:[function(require,module,exports){ +},{}],322:[function(require,module,exports){ /* * copyright 2010-2012 Ryan Day * http://github.com/soldair/node-qrcode @@ -81976,7 +88664,7 @@ QRCodeDraw.prototype = { }; -},{"./qrcapacitytable.js":300,"./qrcode.js":302,"bops":91}],302:[function(require,module,exports){ +},{"./qrcapacitytable.js":321,"./qrcode.js":323,"bops":91}],323:[function(require,module,exports){ var bops = require('bops'); /** @@ -83147,7 +89835,7 @@ QRBitBuffer.prototype = { } }; -},{"bops":91}],303:[function(require,module,exports){ +},{"bops":91}],324:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -83233,7 +89921,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],304:[function(require,module,exports){ +},{}],325:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -83320,16 +90008,24 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],305:[function(require,module,exports){ +},{}],326:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":303,"./encode":304}],306:[function(require,module,exports){ -(function (process,global){ +},{"./decode":324,"./encode":325}],327:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' +// limit of Crypto.getRandomValues() +// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues +var MAX_BYTES = 65536 + +// Node supports requesting up to this number of bytes +// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48 +var MAX_UINT32 = 4294967295 + function oldBrowser () { throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') } @@ -83345,19 +90041,23 @@ if (crypto && crypto.getRandomValues) { function randomBytes (size, cb) { // phantomjs needs to throw - if (size > 65536) throw new Error('requested too many random bytes') - // in case browserify isn't using the Uint8Array version - var rawBytes = new global.Uint8Array(size) + if (size > MAX_UINT32) throw new RangeError('requested too many random bytes') + + var bytes = Buffer.allocUnsafe(size) - // This will not work in older browsers. - // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues if (size > 0) { // getRandomValues fails on IE if size == 0 - crypto.getRandomValues(rawBytes) + if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues + // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues + for (var generated = 0; generated < size; generated += MAX_BYTES) { + // buffer.slice automatically checks if the end is past the end of + // the buffer so we don't have to here + crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES)) + } + } else { + crypto.getRandomValues(bytes) + } } - // XXX: phantomjs doesn't like a buffer being passed here - var bytes = Buffer.from(rawBytes.buffer) - if (typeof cb === 'function') { return process.nextTick(function () { cb(null, bytes) @@ -83367,9 +90067,9 @@ function randomBytes (size, cb) { return bytes } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":271,"safe-buffer":322}],307:[function(require,module,exports){ -(function (process,global){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":291,"safe-buffer":345}],328:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' function oldBrowser () { @@ -83479,11 +90179,138 @@ function randomFillSync (buf, offset, size) { return actualFill(buf, offset, size) } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":271,"randombytes":306,"safe-buffer":322}],308:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":291,"randombytes":327,"safe-buffer":345}],329:[function(require,module,exports){ +'use strict'; + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + +var codes = {}; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } -},{"./lib/_stream_duplex.js":309}],309:[function(require,module,exports){ + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +module.exports.codes = codes; + +},{}],330:[function(require,module,exports){ +(function (process){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -83504,43 +90331,37 @@ module.exports = require('./lib/_stream_duplex.js'); // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from // Writable. - 'use strict'; - /**/ -var pna = require('process-nextick-args'); -/**/ - -/**/ var objectKeys = Object.keys || function (obj) { var keys = []; + for (var key in obj) { keys.push(key); - }return keys; + } + + return keys; }; /**/ -module.exports = Duplex; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +module.exports = Duplex; var Readable = require('./_stream_readable'); + var Writable = require('./_stream_writable'); -util.inherits(Duplex, Readable); +require('inherits')(Duplex, Readable); { - // avoid scope creep, the keys array can then be collected + // Allow the keys array to be GC'ed. var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { var method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; @@ -83549,18 +90370,19 @@ util.inherits(Duplex, Readable); function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); - Readable.call(this, options); Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; - - if (options && options.writable === false) this.writable = false; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - this.once('end', onend); + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } } Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { @@ -83568,20 +90390,35 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } }); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer -// the no-half-open enforcer function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); + + process.nextTick(onEndNT, this); } function onEndNT(self) { @@ -83589,33 +90426,32 @@ function onEndNT(self) { } Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined || this._writableState === undefined) { return false; } + return this._readableState.destroyed && this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (this._readableState === undefined || this._writableState === undefined) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; this._writableState.destroyed = value; } }); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - pna.nextTick(cb, err); -}; -},{"./_stream_readable":311,"./_stream_writable":313,"core-util-is":137,"inherits":259,"process-nextick-args":270}],310:[function(require,module,exports){ +}).call(this)}).call(this,require('_process')) +},{"./_stream_readable":332,"./_stream_writable":334,"_process":291,"inherits":279}],331:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -83636,35 +90472,27 @@ Duplex.prototype._destroy = function (err, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. - 'use strict'; module.exports = PassThrough; var Transform = require('./_stream_transform'); -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -util.inherits(PassThrough, Transform); +require('inherits')(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); - Transform.call(this, options); } PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":312,"core-util-is":137,"inherits":259}],311:[function(require,module,exports){ -(function (process,global){ +},{"./_stream_transform":333,"inherits":279}],332:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -83685,118 +90513,110 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Readable; - /**/ -var isArray = require('isarray'); -/**/ -/**/ var Duplex; /**/ Readable.ReadableState = ReadableState; - /**/ + var EE = require('events').EventEmitter; -var EElistenerCount = function (emitter, type) { +var EElistenerCount = function EElistenerCount(emitter, type) { return emitter.listeners(type).length; }; /**/ /**/ + + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } - -/**/ - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ + var debugUtil = require('util'); -var debug = void 0; + +var debug; + if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { - debug = function () {}; + debug = function debug() {}; } /**/ -var BufferList = require('./internal/streams/BufferList'); + +var BufferList = require('./internal/streams/buffer_list'); + var destroyImpl = require('./internal/streams/destroy'); + +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + var StringDecoder; +var createReadableStreamAsyncIterator; +var from; -util.inherits(Readable, Stream); +require('inherits')(Readable, Stream); +var errorOrDestroy = destroyImpl.errorOrDestroy; var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); - - // This is a hack to make sure that our error handler is attached before any + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any // userland ones. NEVER DO THIS. This is here only because this code needs // to continue to work with older versions of Node.js that do not include // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; } -function ReadableState(options, stream) { +function ReadableState(options, stream, isDuplex) { Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - // object stream flag. Used to make read(n) ignore n and to + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - // the point at which it stops calling _read() to fill the buffer + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - // A linked list is used to store data chunks instead of an array because the + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than // array.shift() + this.buffer = new BufferList(); this.length = 0; this.pipes = null; @@ -83804,37 +90624,36 @@ function ReadableState(options, stream) { this.flowing = null; this.ended = false; this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted // immediately, or on a later tick. We set this to true at first, because // any actions that shouldn't happen until "later" should generally also // not happen before the first read call. - this.sync = true; - // whenever we return null, then we set a flag to say + this.sync = true; // whenever we return null, then we set a flag to say // that we're awaiting a 'readable' event emission. + this.needReadable = false; this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. - // has it been destroyed - this.destroyed = false; + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') - // Crypto is kind of old and crusty. Historically, its default string + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + this.readingMore = false; this.decoder = null; this.encoding = null; + if (options.encoding) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; this.decoder = new StringDecoder(options.encoding); @@ -83844,17 +90663,16 @@ function ReadableState(options, stream) { function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy - // legacy this.readable = true; if (options) { if (typeof options.read === 'function') this._read = options.read; - if (typeof options.destroy === 'function') this._destroy = options.destroy; } @@ -83862,36 +90680,40 @@ function Readable(options) { } Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined) { return false; } + return this._readableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._readableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; } }); - Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; + Readable.prototype._destroy = function (err, cb) { - this.push(null); cb(err); -}; - -// Manually shove something into the read() buffer. +}; // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. + + Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; var skipChunkCheck; @@ -83899,10 +90721,12 @@ Readable.prototype.push = function (chunk, encoding) { if (!state.objectMode) { if (typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { chunk = Buffer.from(chunk, encoding); encoding = ''; } + skipChunkCheck = true; } } else { @@ -83910,34 +90734,40 @@ Readable.prototype.push = function (chunk, encoding) { } return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; +}; // Unshift should *always* be something directly out of read() + -// Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { return readableAddChunk(this, chunk, null, true, false); }; function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); var state = stream._readableState; + if (chunk === null) { state.reading = false; onEofChunk(stream, state); } else { var er; if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { - stream.emit('error', er); + errorOrDestroy(stream, er); } else if (state.objectMode || chunk && chunk.length > 0) { if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; } else { state.reading = false; + if (state.decoder && !encoding) { chunk = state.decoder.write(chunk); if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); @@ -83947,61 +90777,73 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { } } else if (!addToFront) { state.reading = false; + maybeReadMore(stream, state); } - } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. - return needMoreData(state); + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); } function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; stream.emit('data', chunk); - stream.read(0); } else { // update the buffer info. state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - if (state.needReadable) emitReadable(stream); } + maybeReadMore(stream, state); } function chunkInvalid(state, chunk) { var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); } - return er; -} -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); + return er; } Readable.prototype.isPaused = function () { return this._readableState.flowing === false; -}; +}; // backwards compatibility. + -// backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; return this; -}; +}; // Don't raise the hwm > 1GB + + +var MAX_HWM = 0x40000000; -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. n = MAX_HWM; } else { // Get the next highest power of 2 to prevent increasing hwm excessively in @@ -84014,56 +90856,55 @@ function computeNewHighWaterMark(n) { n |= n >>> 16; n++; } - return n; -} -// This function is designed to be inlinable, so please take care when making + return n; +} // This function is designed to be inlinable, so please take care when making // changes to the function body. + + function howMuchToRead(n, state) { if (n <= 0 || state.length === 0 && state.ended) return 0; if (state.objectMode) return 1; + if (n !== n) { // Only flow one buffer at a time if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. + } // If we're asking for more than the current hwm, then raise the hwm. + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough + if (n <= state.length) return n; // Don't have enough + if (!state.ended) { state.needReadable = true; return 0; } + return state.length; -} +} // you can override either this method, or the async _read(n) below. + -// you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { debug('read: emitReadable', state.length, state.ended); if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } - n = howMuchToRead(n, state); + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. - // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { if (state.length === 0) endReadable(this); return null; - } - - // All the actual chunk generation logic needs to be + } // All the actual chunk generation logic needs to be // *below* the call to _read. The reason is that in certain // synthetic stream cases, such as passthrough streams, _read // may be a completely synchronous operation which may change @@ -84084,33 +90925,34 @@ Readable.prototype.read = function (n) { // 'readable' etc. // // 3. Actually pull the requested chunks out of the buffer and return. - // if we need a readable event, then we need to do some reading. + + var doRead = state.needReadable; - debug('need readable', doRead); + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - // if we currently have less than the highWaterMark, then also read some if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already + } // however, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. + + if (state.ended || state.reading) { doRead = false; debug('reading or ended', doRead); } else if (doRead) { debug('do read'); state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } @@ -84118,91 +90960,144 @@ Readable.prototype.read = function (n) { if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { - state.needReadable = true; + state.needReadable = state.length <= state.highWaterMark; n = 0; } else { state.length -= n; + state.awaitDrain = 0; } if (state.length === 0) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. - // If we tried to read() past the EOF, then emit end on the next tick. if (nOrig !== n && state.ended) endReadable(this); } if (ret !== null) this.emit('data', ret); - return ret; }; function onEofChunk(stream, state) { + debug('onEofChunk'); if (state.ended) return; + if (state.decoder) { var chunk = state.decoder.end(); + if (chunk && chunk.length) { state.buffer.push(chunk); state.length += state.objectMode ? 1 : chunk.length; } } + state.ended = true; - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; -// Don't emit readable right away in sync mode, because this can trigger + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger // another read() call => stack overflow. This way, it might trigger // a nextTick recursion warning, but that's not so bad. + + function emitReadable(stream) { var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); state.needReadable = false; + if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + process.nextTick(emitReadable_, stream); } } function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); -// at this point, the user has presumably seen the 'readable' event, + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if // it's in progress. // However, if we're not ended, or reading, and the length < hwm, // then go ahead and try to read some more preemptively. + + function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); + process.nextTick(maybeReadMore_, stream, state); } } function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; debug('maybeReadMore read 0'); stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; + if (len === state.length) // didn't get any data, stop spinning. + break; } - state.readingMore = false; -} -// abstract method. to be overridden in specific implementation classes. + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. + + Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); }; Readable.prototype.pipe = function (dest, pipeOpts) { @@ -84213,24 +91108,26 @@ Readable.prototype.pipe = function (dest, pipeOpts) { case 0: state.pipes = dest; break; + case 1: state.pipes = [state.pipes, dest]; break; + default: state.pipes.push(dest); break; } + state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); - + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { debug('onunpipe'); + if (readable === src) { if (unpipeInfo && unpipeInfo.hasUnpiped === false) { unpipeInfo.hasUnpiped = true; @@ -84242,19 +91139,19 @@ Readable.prototype.pipe = function (dest, pipeOpts) { function onend() { debug('onend'); dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter + } // when the dest drains, it reduces the awaitDrain counter // on the source. This would be more elegant with a .once() // handler in flow(), but adding and removing repeatedly is // too slow. + + var ondrain = pipeOnDrain(src); dest.on('drain', ondrain); - var cleanedUp = false; + function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken + debug('cleanup'); // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); dest.removeListener('finish', onfinish); dest.removeListener('drain', ondrain); @@ -84263,75 +91160,71 @@ Readable.prototype.pipe = function (dest, pipeOpts) { src.removeListener('end', onend); src.removeListener('end', unpipe); src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this + cleanedUp = true; // if the reader is waiting for a drain event from this // specific writer, then it would cause it to never start // flowing again. // So, if this is awaiting a drain, then we just call it now. // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; src.on('data', ondata); + function ondata(chunk) { debug('ondata'); - increasedAwaitDrain = false; var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { + debug('dest.write', ret); + + if (ret === false) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. // => Check whether `dest` is still a piping destination. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; } + src.pause(); } - } - - // if the dest has an error, then stop piping into it. + } // if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. + + function onerror(er) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - // Both close and finish should trigger unpipe, but only once. + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + function onclose() { dest.removeListener('finish', onfinish); unpipe(); } + dest.once('close', onclose); + function onfinish() { debug('onfinish'); dest.removeListener('close', onclose); unpipe(); } + dest.once('finish', onfinish); function unpipe() { debug('unpipe'); src.unpipe(dest); - } + } // tell the dest that it's being piped to - // tell the dest that it's being piped to - dest.emit('pipe', src); - // start the flow if it hasn't been started already. + dest.emit('pipe', src); // start the flow if it hasn't been started already. + if (!state.flowing) { debug('pipe resume'); src.resume(); @@ -84341,10 +91234,11 @@ Readable.prototype.pipe = function (dest, pipeOpts) { }; function pipeOnDrain(src) { - return function () { + return function pipeOnDrainFunctionResult() { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { state.flowing = true; flow(src); @@ -84354,27 +91248,24 @@ function pipeOnDrain(src) { Readable.prototype.unpipe = function (dest) { var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; + if (state.pipesCount === 0) return this; // just one destination. most common case. - // just one destination. most common case. if (state.pipesCount === 1) { // passed in one, but it's not the right one. if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. - if (!dest) dest = state.pipes; - - // got a match. state.pipes = null; state.pipesCount = 0; state.flowing = false; if (dest) dest.emit('unpipe', this, unpipeInfo); return this; - } + } // slow case. multiple pipe destinations. - // slow case. multiple pipe destinations. if (!dest) { // remove all. @@ -84385,80 +91276,139 @@ Readable.prototype.unpipe = function (dest) { state.flowing = false; for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; - } + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + - // try to find the right one. var index = indexOf(state.pipes, dest); if (index === -1) return this; - state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this, unpipeInfo); - return this; -}; - -// set up data events if they are asked for +}; // set up data events if they are asked for // Ensure readable listeners eventually get something + + Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); } else if (ev === 'readable') { - var state = this._readableState; if (!state.endEmitted && !state.readableListening) { state.readableListening = state.needReadable = true; + state.flowing = false; state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { + debug('on readable', state.length, state.reading); + + if (state.length) { emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); } } } return res; }; + Readable.prototype.addListener = Readable.prototype.on; +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} + function nReadingNextTick(self) { debug('readable nexttick read 0'); self.read(0); -} - -// pause() and resume() are remnants of the legacy readable stream API +} // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. + + Readable.prototype.resume = function () { var state = this._readableState; + if (!state.flowing) { - debug('resume'); - state.flowing = true; + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; resume(this, state); } + + state.paused = false; return this; }; function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); + process.nextTick(resume_, stream, state); } } function resume_(stream, state) { + debug('resume', state.reading); + if (!state.reading) { - debug('resume read 0'); stream.read(0); } state.resumeScheduled = false; - state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); @@ -84466,31 +91416,37 @@ function resume_(stream, state) { Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { + + if (this._readableState.flowing !== false) { debug('pause'); this._readableState.flowing = false; this.emit('pause'); } + + this._readableState.paused = true; return this; }; function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} -// wrap an old-style stream as the async data source. + while (state.flowing && stream.read() !== null) { + ; + } +} // wrap an old-style stream as the async data source. // This is *not* part of the readable stream interface. // It is an ugly unfortunate mess of history. + + Readable.prototype.wrap = function (stream) { var _this = this; var state = this._readableState; var paused = false; - stream.on('end', function () { debug('wrapped end'); + if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) _this.push(chunk); @@ -84498,42 +91454,41 @@ Readable.prototype.wrap = function (stream) { _this.push(null); }); - stream.on('data', function (chunk) { debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode - // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; var ret = _this.push(chunk); + if (!ret) { paused = true; stream.pause(); } - }); - - // proxy all the other methods. + }); // proxy all the other methods. // important when wrapping filters and duplexes. + for (var i in stream) { if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { return stream[method].apply(stream, arguments); }; }(i); } - } + } // proxy certain important events. + - // proxy certain important events. for (var n = 0; n < kProxyEvents.length; n++) { stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } - - // when we try to consume some more bytes, simply unpause the + } // when we try to consume some more bytes, simply unpause the // underlying stream. + + this._read = function (n) { debug('wrapped _read', n); + if (paused) { paused = false; stream.resume(); @@ -84543,149 +91498,127 @@ Readable.prototype.wrap = function (stream) { return this; }; +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; +} + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._readableState.highWaterMark; } }); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. -// exposed for testing purposes only. Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. // This function is designed to be inlinable, so please take care when making // changes to the function body. + function fromList(n, state) { // nothing buffered if (state.length === 0) return null; - var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); state.buffer.clear(); } else { // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - - return ret; -} - -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} - -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; + ret = state.buffer.consume(n, state.decoder); } - list.length -= c; return ret; } function endReadable(stream) { var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + debug('endReadable', state.endEmitted); if (!state.endEmitted) { state.ended = true; - pna.nextTick(endReadableNT, state, stream); + process.nextTick(endReadableNT, state, stream); } } function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { state.endEmitted = true; stream.readable = false; stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } } } +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = require('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; +} + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; } + return -1; } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":309,"./internal/streams/BufferList":314,"./internal/streams/destroy":315,"./internal/streams/stream":316,"_process":271,"core-util-is":137,"events":239,"inherits":259,"isarray":261,"process-nextick-args":270,"safe-buffer":322,"string_decoder/":339,"util":104}],312:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":329,"./_stream_duplex":330,"./internal/streams/async_iterator":335,"./internal/streams/buffer_list":336,"./internal/streams/destroy":337,"./internal/streams/from":339,"./internal/streams/state":341,"./internal/streams/stream":342,"_process":291,"buffer":130,"events":241,"inherits":279,"string_decoder/":362,"util":239}],333:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -84706,7 +91639,6 @@ function indexOf(xs, x) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -84748,40 +91680,37 @@ function indexOf(xs, x) { // However, even in such a pathological case, only a single written chunk // would be consumed, and then the rest would wait (un-transformed) until // the results of the previous transformed chunk were consumed. - 'use strict'; module.exports = Transform; -var Duplex = require('./_stream_duplex'); +var _require$codes = require('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +var Duplex = require('./_stream_duplex'); -util.inherits(Transform, Duplex); +require('inherits')(Transform, Duplex); function afterTransform(er, data) { var ts = this._transformState; ts.transforming = false; - var cb = ts.writecb; - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); } ts.writechunk = null; ts.writecb = null; - if (data != null) // single equals check for both `null` and `undefined` this.push(data); - cb(er); - var rs = this._readableState; rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } @@ -84789,9 +91718,7 @@ function afterTransform(er, data) { function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); - Duplex.call(this, options); - this._transformState = { afterTransform: afterTransform.bind(this), needTransform: false, @@ -84799,30 +91726,27 @@ function Transform(options) { writecb: null, writechunk: null, writeencoding: null - }; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; + }; // start out asking for a readable event once data is transformed. - // we have implemented the _read method, and done the other things + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. + this._readableState.sync = false; if (options) { if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') this._flush = options.flush; - } + } // When the writable side finishes, then flush out anything remaining. + - // When the writable side finishes, then flush out anything remaining. this.on('prefinish', prefinish); } function prefinish() { var _this = this; - if (typeof this._flush === 'function') { + if (typeof this._flush === 'function' && !this._readableState.destroyed) { this._flush(function (er, data) { done(_this, er, data); }); @@ -84834,9 +91758,7 @@ function prefinish() { Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! +}; // This is the part where you do stuff! // override this function in implementation classes. // 'chunk' is an input chunk. // @@ -84846,8 +91768,10 @@ Transform.prototype.push = function (chunk, encoding) { // Call `cb(err)` when you are done with this chunk. If you pass // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. + + Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -84855,20 +91779,22 @@ Transform.prototype._write = function (chunk, encoding, cb) { ts.writecb = cb; ts.writechunk = chunk; ts.writeencoding = encoding; + if (!ts.transforming) { var rs = this._readableState; if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } -}; - -// Doesn't matter what the args are here. +}; // Doesn't matter what the args are here. // _transform does all the work. // That we got here means that the readable side wants more data. + + Transform.prototype._read = function (n) { var ts = this._transformState; - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + if (ts.writechunk !== null && !ts.transforming) { ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); } else { // mark that we need a transform, so that any data that comes in @@ -84878,30 +91804,24 @@ Transform.prototype._read = function (n) { }; Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); - _this2.emit('close'); }); }; function done(stream, er, data) { if (er) return stream.emit('error', er); - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases // if there's nothing in the write buffer, then that means // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); return stream.push(null); } -},{"./_stream_duplex":309,"core-util-is":137,"inherits":259}],313:[function(require,module,exports){ -(function (process,global,setImmediate){ +},{"../errors":329,"./_stream_duplex":330,"inherits":279}],334:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -84922,35 +91842,29 @@ function done(stream, er, data) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Writable; - /* */ + function WriteReq(chunk, encoding, cb) { this.chunk = chunk; this.encoding = encoding; this.callback = cb; this.next = null; -} - -// It seems a linked list but it is not +} // It seems a linked list but it is not // there will be only 2 of these for each stream + + function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; + this.finish = function () { onCorkedFinish(_this, state); }; @@ -84958,266 +91872,247 @@ function CorkedRequest(state) { /* */ /**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ -/**/ + var Duplex; /**/ Writable.WritableState = WritableState; - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ var internalUtil = { deprecate: require('util-deprecate') }; /**/ /**/ + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } -/**/ - var destroyImpl = require('./internal/streams/destroy'); -util.inherits(Writable, Stream); +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; -function nop() {} +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); +var errorOrDestroy = destroyImpl.errorOrDestroy; - options = options || {}; +require('inherits')(Writable, Stream); - // Duplex streams are both readable and writable, but share +function nop() {} + +function WritableState(options, stream, isDuplex) { + Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - // object stream flag to indicate whether or not this stream + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream // contains buffers or objects. - this.objectMode = !!options.objectMode; - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - - // the point at which write() starts returning false + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); + this.finalCalled = false; // drain event flag. - // if _final has been called - this.finalCalled = false; + this.needDrain = false; // at the start of calling end() - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; + this.ending = false; // when end() has been called, and returned - // has it been destroyed - this.destroyed = false; + this.ended = false; // when 'finish' is emitted - // should we decode strings into buffers before passing to _write? + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - // Crypto is kind of old and crusty. Historically, its default string + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // not an actual buffer we keep track of, but a measurement + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement // of how much we're waiting to get pushed to some underlying // socket or file. - this.length = 0; - // a flag to see when we're in the middle of a write. - this.writing = false; + this.length = 0; // a flag to see when we're in the middle of a write. - // when true all writes will be buffered until .uncork() call - this.corked = 0; + this.writing = false; // when true all writes will be buffered until .uncork() call - // a flag to be able to tell if the onwrite cb is called immediately, + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. - this.sync = true; - // a flag to know if we're processing previously buffered items, which + this.sync = true; // a flag to know if we're processing previously buffered items, which // may call the _write() callback in the same tick, so that we don't // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - // the callback that's passed to _write(chunk,cb) + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { onwrite(stream, er); - }; + }; // the callback that the user supplies to write(chunk,encoding,cb) - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - // the amount that is being written when _write is called. - this.writelen = 0; + this.writecb = null; // the amount that is being written when _write is called. + this.writelen = 0; this.bufferedRequest = null; - this.lastBufferedRequest = null; - - // number of pending user-supplied write callbacks + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - // emit prefinish if the only thing we're waiting for is _write cbs + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs // This is relevant for synchronous Transform streams - this.prefinished = false; - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; + this.prefinished = false; // True if the error was already emitted and should not be thrown again - // count buffered requests - this.bufferedRequestCount = 0; + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. - // allocate the first CorkedRequest, there is always + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; + while (current) { out.push(current); current = current.next; } + return out; }; (function () { try { Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { + get: internalUtil.deprecate(function writableStateBufferGetter() { return this.getBuffer(); }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); } catch (_) {} -})(); - -// Test _writableState for inheritance to account for Duplex streams, +})(); // Test _writableState for inheritance to account for Duplex streams, // whose prototype chain only points to Readable. + + var realHasInstance; + if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { realHasInstance = Function.prototype[Symbol.hasInstance]; Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { + value: function value(object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; - return object && object._writableState instanceof WritableState; } }); } else { - realHasInstance = function (object) { + realHasInstance = function realHasInstance(object) { return object instanceof this; }; } function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - // Writable ctor is applied to Duplexes, too. + Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. // `realHasInstance` is necessary because using plain `instanceof` // would return false, as no `_writableState` property is attached. - // Trying to use the custom `instanceof` for Writable here will also break the // Node.js LazyTransform implementation, which has a non-trivial getter for // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 - this._writableState = new WritableState(options, this); + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. - // legacy. this.writable = true; if (options) { if (typeof options.write === 'function') this._write = options.write; - if (typeof options.writev === 'function') this._writev = options.writev; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - if (typeof options.final === 'function') this._final = options.final; } Stream.call(this); -} +} // Otherwise people can pipe Writable streams, which is just wrong. + -// Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); }; function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb -// Checks that a user-supplied chunk is valid, especially for the particular + errorOrDestroy(stream, er); + process.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular // mode the stream is in. Currently this means that `null` is never accepted // and undefined/non-string values are only allowed in object mode. + + function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; + var er; if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); } + if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; } - return valid; + + return true; } Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer.isBuffer(chunk)) { @@ -85230,21 +92125,16 @@ Writable.prototype.write = function (chunk, encoding, cb) { } if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } - return ret; }; Writable.prototype.cork = function () { - var state = this._writableState; - - state.corked++; + this._writableState.corked++; }; Writable.prototype.uncork = function () { @@ -85252,23 +92142,33 @@ Writable.prototype.uncork = function () { if (state.corked) { state.corked--; - - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); this._writableState.defaultEncoding = encoding; return this; }; +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = Buffer.from(chunk, encoding); } + return chunk; } @@ -85277,29 +92177,28 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } -}); - -// if we're already writing something, then just put this +}); // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. + function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { isBuf = true; encoding = 'buffer'; chunk = newChunk; } } - var len = state.objectMode ? 1 : chunk.length; + var len = state.objectMode ? 1 : chunk.length; state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; if (state.writing || state.corked) { @@ -85311,11 +92210,13 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { callback: cb, next: null }; + if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } + state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); @@ -85329,7 +92230,7 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writecb = cb; state.writing = true; state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } @@ -85339,20 +92240,20 @@ function onwriteError(stream, state, sync, er, cb) { if (sync) { // defer the callback if we are being called synchronously // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen + process.nextTick(cb, er); // this can emit finish, and it will always happen // after error - pna.nextTick(finishMaybe, stream, state); + + process.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; - stream.emit('error', er); + errorOrDestroy(stream, er); } else { // the caller expect this to happen before if // it is async cb(er); stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must + errorOrDestroy(stream, er); // this can emit finish, but finish must // always follow error + finishMaybe(stream, state); } } @@ -85368,21 +92269,18 @@ function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; - + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); onwriteStateUpdate(state); - if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); + var finished = needFinish(state) || stream.destroyed; if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ + process.nextTick(afterWrite, stream, state, finished, cb); } else { afterWrite(stream, state, finished, cb); } @@ -85394,19 +92292,19 @@ function afterWrite(stream, state, finished, cb) { state.pendingcb--; cb(); finishMaybe(stream, state); -} - -// Must force callback to be called on nextTick, so that we don't +} // Must force callback to be called on nextTick, so that we don't // emit 'drain' before the write() consumer gets the 'false' return // value, and has a chance to attach a 'drain' listener. + + function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit('drain'); } -} +} // if there's something in the buffer waiting, then process it + -// if there's something in the buffer waiting, then process it function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; @@ -85417,29 +92315,30 @@ function clearBuffer(stream, state) { var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; - var count = 0; var allBuffers = true; + while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } - buffer.allBuffers = allBuffers; - doWrite(stream, state, true, state.length, buffer, '', holder.finish); - - // doWrite is almost always async, defer these to save a bit of time + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite + state.pendingcb++; state.lastBufferedRequest = null; + if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } + state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one @@ -85448,14 +92347,13 @@ function clearBuffer(stream, state) { var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; - doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then // it means that we need to wait until it does. // also, that means that the chunk and cb are currently // being processed, so move the buffer counter past them. + if (state.writing) { break; } @@ -85469,7 +92367,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); }; Writable.prototype._writev = null; @@ -85486,38 +92384,52 @@ Writable.prototype.end = function (chunk, encoding, cb) { encoding = null; } - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks - // .end() fully uncorks if (state.corked) { state.corked = 1; this.uncork(); - } + } // ignore unnecessary end() calls. - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); + + if (!state.ending) endWritable(this, state, cb); + return this; }; +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); + function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } + function callFinal(stream, state) { stream._final(function (err) { state.pendingcb--; + if (err) { - stream.emit('error', err); + errorOrDestroy(stream, err); } + state.prefinished = true; stream.emit('prefinish'); finishMaybe(stream, state); }); } + function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { + if (typeof stream._final === 'function' && !state.destroyed) { state.pendingcb++; state.finalCalled = true; - pna.nextTick(callFinal, stream, state); + process.nextTick(callFinal, stream, state); } else { state.prefinished = true; stream.emit('prefinish'); @@ -85527,22 +92439,37 @@ function prefinish(stream, state) { function finishMaybe(stream, state) { var need = needFinish(state); + if (need) { prefinish(stream, state); + if (state.pendingcb === 0) { state.finished = true; stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } } } + return need; } function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); + if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); } + state.ended = true; stream.writable = false; } @@ -85550,59 +92477,289 @@ function endWritable(stream, state, cb) { function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; + while (entry) { var cb = entry.callback; state.pendingcb--; cb(err); entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; } Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._writableState === undefined) { return false; } + return this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._writableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._writableState.destroyed = value; } }); - Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; + Writable.prototype._destroy = function (err, cb) { - this.end(); cb(err); }; -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":309,"./internal/streams/destroy":315,"./internal/streams/stream":316,"_process":271,"core-util-is":137,"inherits":259,"process-nextick-args":270,"safe-buffer":322,"timers":349,"util-deprecate":358}],314:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,"_process":291,"buffer":130,"inherits":279,"util-deprecate":381}],335:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +var _Object$setPrototypeO; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var finished = require('./end-of-stream'); + +var kLastResolve = Symbol('lastResolve'); +var kLastReject = Symbol('lastReject'); +var kError = Symbol('error'); +var kEnded = Symbol('ended'); +var kLastPromise = Symbol('lastPromise'); +var kHandlePromise = Symbol('handlePromise'); +var kStream = Symbol('stream'); + +function createIterResult(value, done) { + return { + value: value, + done: done + }; +} + +function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } +} + +function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); +} + +function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; +} + +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; +}), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); +}), _Object$setPrototypeO), AsyncIteratorPrototype); + +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; +}; + +module.exports = createReadableStreamAsyncIterator; +}).call(this)}).call(this,require('_process')) +},{"./end-of-stream":338,"_process":291}],336:[function(require,module,exports){ 'use strict'; +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var _require = require('buffer'), + Buffer = _require.Buffer; + +var _require2 = require('util'), + inspect = _require2.inspect; + +var custom = inspect && inspect.custom || 'inspect'; function copyBuffer(src, target, offset) { - src.copy(target, offset); + Buffer.prototype.copy.call(src, target, offset); } -module.exports = function () { +module.exports = +/*#__PURE__*/ +function () { function BufferList() { _classCallCheck(this, BufferList); @@ -85611,74 +92768,183 @@ module.exports = function () { this.length = 0; } - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; + while (p = p.next) { + ret += s + p.data; + } - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; } - return ret; - }; + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. - return BufferList; -}(); + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":322,"util":104}],315:[function(require,module,exports){ -'use strict'; + break; + } -/**/ + ++c; + } -var pna = require('process-nextick-args'); -/**/ + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; +}(); +},{"buffer":130,"util":239}],337:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; // undocumented cb() API, needed for core, not for public API -// undocumented cb() API, needed for core, not for public API function destroy(err, cb) { var _this = this; @@ -85688,38 +92954,61 @@ function destroy(err, cb) { if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } } - return this; - } - // we set destroyed to true before firing error callbacks in order + return this; + } // we set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks + if (this._readableState) { this._readableState.destroyed = true; - } + } // if this is a duplex stream mark the writable part as destroyed as well + - // if this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function (err) { if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); } } else if (cb) { + process.nextTick(emitCloseNT, _this); cb(err); + } else { + process.nextTick(emitCloseNT, _this); } }); return this; } +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} + +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} + function undestroy() { if (this._readableState) { this._readableState.destroyed = false; @@ -85732,6 +93021,8 @@ function undestroy() { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } @@ -85741,17 +93032,262 @@ function emitErrorNT(self, err) { self.emit('error', err); } +function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} + module.exports = { destroy: destroy, - undestroy: undestroy + undestroy: undestroy, + errorOrDestroy: errorOrDestroy }; -},{"process-nextick-args":270}],316:[function(require,module,exports){ -module.exports = require('events').EventEmitter; +}).call(this)}).call(this,require('_process')) +},{"_process":291}],338:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/end-of-stream with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; -},{"events":239}],317:[function(require,module,exports){ -module.exports = require('./readable').PassThrough +var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; +} + +function noop() {} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} + +module.exports = eos; +},{"../../../errors":329}],339:[function(require,module,exports){ +module.exports = function () { + throw new Error('Readable.from is not available in the browser') +}; + +},{}],340:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/pump with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var eos; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} + +var _require$codes = require('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = require('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} + +function call(fn) { + fn(); +} + +function pipe(from, to) { + return from.pipe(to); +} + +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} + +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} + +module.exports = pipeline; +},{"../../../errors":329,"./end-of-stream":338}],341:[function(require,module,exports){ +'use strict'; + +var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; + +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} + +function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; +} -},{"./readable":318}],318:[function(require,module,exports){ +module.exports = { + getHighWaterMark: getHighWaterMark +}; +},{"../../../errors":329}],342:[function(require,module,exports){ +arguments[4][251][0].apply(exports,arguments) +},{"dup":251,"events":241}],343:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -85759,14 +93295,10 @@ exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); +exports.finished = require('./lib/internal/streams/end-of-stream.js'); +exports.pipeline = require('./lib/internal/streams/pipeline.js'); -},{"./lib/_stream_duplex.js":309,"./lib/_stream_passthrough.js":310,"./lib/_stream_readable.js":311,"./lib/_stream_transform.js":312,"./lib/_stream_writable.js":313}],319:[function(require,module,exports){ -module.exports = require('./readable').Transform - -},{"./readable":318}],320:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); - -},{"./lib/_stream_writable.js":313}],321:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(require,module,exports){ 'use strict' var Buffer = require('buffer').Buffer var inherits = require('inherits') @@ -85931,7 +93463,8 @@ function fn5 (a, b, c, d, e, m, k, s) { module.exports = RIPEMD160 -},{"buffer":131,"hash-base":243,"inherits":259}],322:[function(require,module,exports){ +},{"buffer":130,"hash-base":264,"inherits":279}],345:[function(require,module,exports){ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -85954,6 +93487,8 @@ function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } +SafeBuffer.prototype = Object.create(Buffer.prototype) + // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) @@ -85995,12 +93530,93 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":131}],323:[function(require,module,exports){ +},{"buffer":130}],346:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-disable node/no-deprecated-api */ + +'use strict' + +var buffer = require('buffer') +var Buffer = buffer.Buffer + +var safer = {} + +var key + +for (key in buffer) { + if (!buffer.hasOwnProperty(key)) continue + if (key === 'SlowBuffer' || key === 'Buffer') continue + safer[key] = buffer[key] +} + +var Safer = safer.Buffer = {} +for (key in Buffer) { + if (!Buffer.hasOwnProperty(key)) continue + if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue + Safer[key] = Buffer[key] +} + +safer.Buffer.prototype = Buffer.prototype + +if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) + } + if (value && typeof value.length === 'undefined') { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) + } + return Buffer(value, encodingOrOffset, length) + } +} + +if (!Safer.alloc) { + Safer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) + } + if (size < 0 || size >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + var buf = Buffer(size) + if (!fill || fill.length === 0) { + buf.fill(0) + } else if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + return buf + } +} + +if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process.binding('buffer').kStringMaxLength + } catch (e) { + // we can't determine kStringMaxLength in environments where process.binding + // is unsupported, so let's not set it + } +} + +if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + } + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength + } +} + +module.exports = safer + +}).call(this)}).call(this,require('_process')) +},{"_process":291,"buffer":130}],347:[function(require,module,exports){ 'use strict' module.exports = require('./lib')(require('./lib/elliptic')) -},{"./lib":327,"./lib/elliptic":326}],324:[function(require,module,exports){ -(function (Buffer){ +},{"./lib":351,"./lib/elliptic":350}],348:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict' var toString = Object.prototype.toString @@ -86046,8 +93662,8 @@ exports.isNumberInInterval = function (number, x, y, message) { if (number <= x || number >= y) throw RangeError(message) } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":260}],325:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":280}],349:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var bip66 = require('bip66') @@ -86242,7 +93858,7 @@ exports.signatureImportLax = function (sig) { return { r: r, s: s } } -},{"bip66":40,"safe-buffer":322}],326:[function(require,module,exports){ +},{"bip66":40,"safe-buffer":345}],350:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var createHash = require('create-hash') @@ -86375,7 +93991,10 @@ exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) { tweak = new BN(tweak) if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) - return Buffer.from(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed)) + var point = ecparams.g.mul(tweak).add(pair.pub) + if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) + + return Buffer.from(point.encode(true, compressed)) } exports.publicKeyTweakMul = function (publicKey, tweak, compressed) { @@ -86459,7 +94078,7 @@ exports.sign = function (message, privateKey, noncefn, data) { } exports.verify = function (message, signature, publicKey) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -86469,11 +94088,11 @@ exports.verify = function (message, signature, publicKey) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y}) + return ec.verify(message, sigObj, { x: pair.pub.x, y: pair.pub.y }) } exports.recover = function (message, signature, recovery, compressed) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -86504,7 +94123,7 @@ exports.ecdhUnsafe = function (publicKey, privateKey, compressed) { return Buffer.from(pair.pub.mul(scalar).encode(true, compressed)) } -},{"../messages.json":328,"bn.js":90,"create-hash":139,"elliptic":221,"safe-buffer":322}],327:[function(require,module,exports){ +},{"../messages.json":352,"bn.js":90,"create-hash":138,"elliptic":222,"safe-buffer":345}],351:[function(require,module,exports){ 'use strict' var assert = require('./assert') var der = require('./der') @@ -86751,7 +94370,7 @@ module.exports = function (secp256k1) { } } -},{"./assert":324,"./der":325,"./messages.json":328}],328:[function(require,module,exports){ +},{"./assert":348,"./der":349,"./messages.json":352}],352:[function(require,module,exports){ module.exports={ "COMPRESSED_TYPE_INVALID": "compressed should be a boolean", "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer", @@ -86790,7 +94409,7 @@ module.exports={ "TWEAK_LENGTH_INVALID": "tweak length is invalid" } -},{}],329:[function(require,module,exports){ +},{}],353:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer // prototype class for hash functions @@ -86873,7 +94492,7 @@ Hash.prototype._update = function () { module.exports = Hash -},{"safe-buffer":322}],330:[function(require,module,exports){ +},{"safe-buffer":345}],354:[function(require,module,exports){ var exports = module.exports = function SHA (algorithm) { algorithm = algorithm.toLowerCase() @@ -86890,7 +94509,7 @@ exports.sha256 = require('./sha256') exports.sha384 = require('./sha384') exports.sha512 = require('./sha512') -},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(require,module,exports){ +},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined * in FIPS PUB 180-1 @@ -86986,7 +94605,7 @@ Sha.prototype._hash = function () { module.exports = Sha -},{"./hash":329,"inherits":259,"safe-buffer":322}],332:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],356:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 @@ -87087,7 +94706,7 @@ Sha1.prototype._hash = function () { module.exports = Sha1 -},{"./hash":329,"inherits":259,"safe-buffer":322}],333:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],357:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -87142,7 +94761,7 @@ Sha224.prototype._hash = function () { module.exports = Sha224 -},{"./hash":329,"./sha256":334,"inherits":259,"safe-buffer":322}],334:[function(require,module,exports){ +},{"./hash":353,"./sha256":358,"inherits":279,"safe-buffer":345}],358:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -87279,7 +94898,7 @@ Sha256.prototype._hash = function () { module.exports = Sha256 -},{"./hash":329,"inherits":259,"safe-buffer":322}],335:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],359:[function(require,module,exports){ var inherits = require('inherits') var SHA512 = require('./sha512') var Hash = require('./hash') @@ -87338,7 +94957,7 @@ Sha384.prototype._hash = function () { module.exports = Sha384 -},{"./hash":329,"./sha512":336,"inherits":259,"safe-buffer":322}],336:[function(require,module,exports){ +},{"./hash":353,"./sha512":360,"inherits":279,"safe-buffer":345}],360:[function(require,module,exports){ var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer @@ -87600,7 +95219,7 @@ Sha512.prototype._hash = function () { module.exports = Sha512 -},{"./hash":329,"inherits":259,"safe-buffer":322}],337:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],361:[function(require,module,exports){ "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; sjcl.cipher.aes=function(a){this.j[0][0][0]||this.m();var b,c,d,e,f=this.j[0][4],h=this.j[1];b=a.length;var g=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.c=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^g<<24,g=g<<1^283*(g>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:h[0][f[c>>>24]]^h[1][f[c>>16&255]]^h[2][f[c>>8&255]]^h[3][f[c& 255]]}; @@ -87633,440 +95252,16 @@ sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(thi sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E4;if(0>d||0>c)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,h,g,l,k=[],m=sjcl.bitArray;for(l=1;32*k.length<(d||1);l++){e=f=a.encrypt(m.concat(b,[l]));for(h=1;h*/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":322}],340:[function(require,module,exports){ +},{}],362:[function(require,module,exports){ +arguments[4][253][0].apply(exports,arguments) +},{"dup":253,"safe-buffer":345}],363:[function(require,module,exports){ module.exports = function (options) { options.signer = options.signer || require('./lib/signer-hmac-only'); return require('./lib/index')(options); } -},{"./lib/index":341,"./lib/signer-hmac-only":342}],341:[function(require,module,exports){ +},{"./lib/index":364,"./lib/signer-hmac-only":365}],364:[function(require,module,exports){ /** * original code from http-signature package by Joyent, Inc. * @@ -88225,7 +95420,7 @@ module.exports = function (options) { }; } -},{"util":360}],342:[function(require,module,exports){ +},{"util":263}],365:[function(require,module,exports){ var createHmac = require('create-hmac'); module.exports = function (stringToSign, options) { @@ -88242,7 +95437,7 @@ module.exports = function (stringToSign, options) { return signature; }; -},{"create-hmac":141}],343:[function(require,module,exports){ +},{"create-hmac":140}],366:[function(require,module,exports){ function Agent() { this._defaults = []; } @@ -88264,7 +95459,7 @@ Agent.prototype._setDefaults = function(req) { module.exports = Agent; -},{}],344:[function(require,module,exports){ +},{}],367:[function(require,module,exports){ /** * Root reference for iframes. */ @@ -89186,7 +96381,7 @@ request.put = function(url, data, fn) { return req; }; -},{"./agent-base":343,"./is-object":345,"./request-base":346,"./response-base":347,"component-emitter":136}],345:[function(require,module,exports){ +},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(require,module,exports){ 'use strict'; /** @@ -89203,7 +96398,7 @@ function isObject(obj) { module.exports = isObject; -},{}],346:[function(require,module,exports){ +},{}],369:[function(require,module,exports){ 'use strict'; /** @@ -89899,7 +97094,7 @@ RequestBase.prototype._setTimeouts = function() { } }; -},{"./is-object":345}],347:[function(require,module,exports){ +},{"./is-object":368}],370:[function(require,module,exports){ 'use strict'; /** @@ -90037,7 +97232,7 @@ ResponseBase.prototype._setStatusProperties = function(status){ this.unprocessableEntity = 422 == status; }; -},{"./utils":348}],348:[function(require,module,exports){ +},{"./utils":371}],371:[function(require,module,exports){ 'use strict'; /** @@ -90110,8 +97305,8 @@ exports.cleanHeader = function(header, changesOrigin){ return header; }; -},{}],349:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ +},{}],372:[function(require,module,exports){ +(function (setImmediate,clearImmediate){(function (){ var nextTick = require('process/browser.js').nextTick; var apply = Function.prototype.apply; var slice = Array.prototype.slice; @@ -90188,8 +97383,8 @@ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : funct exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { delete immediateIds[id]; }; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":271,"timers":349}],350:[function(require,module,exports){ +}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":291,"timers":372}],373:[function(require,module,exports){ module.exports = to_utf8 var out = [] @@ -90264,7 +97459,7 @@ function reduced(list) { return out } -},{}],351:[function(require,module,exports){ +},{}],374:[function(require,module,exports){ var native = require('./native') function getTypeName (fn) { @@ -90376,8 +97571,8 @@ module.exports = { getValueTypeName: getValueTypeName } -},{"./native":354}],352:[function(require,module,exports){ -(function (Buffer){ +},{"./native":377}],375:[function(require,module,exports){ +(function (Buffer){(function (){ var NATIVE = require('./native') var ERRORS = require('./errors') @@ -90470,8 +97665,8 @@ for (var typeName in types) { module.exports = types -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":260,"./errors":351,"./native":354}],353:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(require,module,exports){ var ERRORS = require('./errors') var NATIVE = require('./native') @@ -90733,7 +97928,7 @@ typeforce.TfPropertyTypeError = TfPropertyTypeError module.exports = typeforce -},{"./errors":351,"./extra":352,"./native":354}],354:[function(require,module,exports){ +},{"./errors":374,"./extra":375,"./native":377}],377:[function(require,module,exports){ var types = { Array: function (value) { return value !== null && value !== undefined && value.constructor === Array }, Boolean: function (value) { return typeof value === 'boolean' }, @@ -90756,7 +97951,7 @@ for (var typeName in types) { module.exports = types -},{}],355:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ (function (root) { "use strict"; @@ -91179,28 +98374,38 @@ UChar.udata={ unorm.shimApplied = false; if (!String.prototype.normalize) { - String.prototype.normalize = function(form) { - var str = "" + this; - form = form === undefined ? "NFC" : form; - - if (form === "NFC") { - return unorm.nfc(str); - } else if (form === "NFD") { - return unorm.nfd(str); - } else if (form === "NFKC") { - return unorm.nfkc(str); - } else if (form === "NFKD") { - return unorm.nfkd(str); - } else { - throw new RangeError("Invalid normalization form: " + form); + Object.defineProperty(String.prototype, "normalize", { + enumerable: false, + configurable: true, + writable: true, + value: function normalize (/*form*/) { + + var str = "" + this; + var form = arguments[0] === undefined ? "NFC" : arguments[0]; + + if (this === null || this === undefined) { + throw new TypeError("Cannot call method on " + Object.prototype.toString.call(this)); + } + + if (form === "NFC") { + return unorm.nfc(str); + } else if (form === "NFD") { + return unorm.nfd(str); + } else if (form === "NFKC") { + return unorm.nfkc(str); + } else if (form === "NFKD") { + return unorm.nfkd(str); + } else { + throw new RangeError("Invalid normalization form: " + form); + } } - }; + }); unorm.shimApplied = true; } }(this)); -},{}],356:[function(require,module,exports){ +},{}],379:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -91934,7 +99139,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":357,"punycode":240,"querystring":305}],357:[function(require,module,exports){ +},{"./util":380,"punycode":242,"querystring":326}],380:[function(require,module,exports){ 'use strict'; module.exports = { @@ -91952,8 +99157,8 @@ module.exports = { } }; -},{}],358:[function(require,module,exports){ -(function (global){ +},{}],381:[function(require,module,exports){ +(function (global){(function (){ /** * Module exports. @@ -92022,12 +99227,8 @@ function config (name) { return String(val).toLowerCase() === 'true'; } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],359:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"dup":26}],360:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"./support/isBuffer":359,"_process":271,"dup":27,"inherits":259}],361:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],382:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer @@ -92111,15 +99312,15 @@ function encodingLength (number) { return ( number < 0xfd ? 1 - : number <= 0xffff ? 3 - : number <= 0xffffffff ? 5 - : 9 + : number <= 0xffff ? 3 + : number <= 0xffffffff ? 5 + : 9 ) } module.exports = { encode: encode, decode: decode, encodingLength: encodingLength } -},{"safe-buffer":322}],362:[function(require,module,exports){ +},{"safe-buffer":345}],383:[function(require,module,exports){ var bundleFn = arguments[3]; var sources = arguments[4]; var cache = arguments[5]; @@ -92201,8 +99402,8 @@ module.exports = function (fn, options) { return worker; }; -},{}],363:[function(require,module,exports){ -(function (Buffer){ +},{}],384:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') function decodeRaw (buffer, version) { @@ -92267,6 +99468,6 @@ module.exports = { encodeRaw: encodeRaw } -}).call(this,require("buffer").Buffer) -},{"bs58check":127,"buffer":131}]},{},[22])(22) +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":126,"buffer":130}]},{},[22])(22) }); diff --git a/build/blocktrail-sdk-full.min.js b/build/blocktrail-sdk-full.min.js index 05c256e..adbc248 100644 --- a/build/blocktrail-sdk-full.min.js +++ b/build/blocktrail-sdk-full.min.js @@ -1 +1 @@ -var jsPDF=function(e){"use strict";"undefined"==typeof btoa&&(e.btoa=function(e){var t,r,n,i,o,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),c=0,f=0,u="",h=[];do{t=(o=e.charCodeAt(c++)<<16|e.charCodeAt(c++)<<8|e.charCodeAt(c++))>>18&63,r=o>>12&63,n=o>>6&63,i=63&o,h[f++]=a[t]+a[r]+a[n]+a[i]}while(c>16&255,r=s>>8&255,n=255&s,u[f++]=64===i?String.fromCharCode(t):64===o?String.fromCharCode(t,r):String.fromCharCode(t,r,n)}while(c>"),z("/XObject <<"),N.publish("putXobjectDict"),z(">>")},V=function(){!function(){var e,t;for(e in B)B.hasOwnProperty(e)&&((t=B[e]).objectNumber=F(),z("<>"),z("endobj"))}(),N.publish("putResources"),T[2]=m,z("2 0 obj"),z("<<"),q(),z(">>"),z("endobj"),N.publish("postPutResources")},G=function(e,t,r){void 0===C[t]&&(C[t]={}),C[t][r]=e},Y=function(e,r,n,i){var o="F"+(t(B)+1).toString(10),s=B[o]={id:o,PostScriptName:e,fontName:r,fontStyle:n,encoding:i,metadata:{}};return G(o,r,n),N.publish("addFont",s),o},X=function(e,t){return function(e,t){var r,n,i,o,s,a,f,u,h;if(void 0===t&&(t={}),i=t.sourceEncoding?i:"Unicode",s=t.outputEncoding,(t.autoencode||s)&&B[c].metadata&&B[c].metadata[i]&&B[c].metadata[i].encoding&&(o=B[c].metadata[i].encoding,!s&&B[c].encoding&&(s=B[c].encoding),!s&&o.codePages&&(s=o.codePages[0]),"string"==typeof s&&(s=o[s]),s)){for(f=!1,a=[],r=0,n=e.length;r>8&&(f=!0);e=a.join("")}for(r=e.length;void 0===f&&0!==r;)e.charCodeAt(r-1)>>8&&(f=!0),r--;if(f){for(a=t.noBOM?[]:[254,255],r=0,n=e.length;r>8)>>8)throw new Error("Character at position "+r.toString(10)+" of string '"+e+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(h),a.push(u-(h<<8))}return String.fromCharCode.apply(void 0,a)}return e}(e,t).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},J=function(){x=!0,A[++k]=[],z(U(O*h)+" w"),z(S),0!==L&&z(L.toString(10)+" J"),0!==j&&z(j.toString(10)+" j"),N.publish("addPage",{pageNumber:k})},Z=function(e,t){var r;void 0===e&&(e=B[c].fontName),void 0===t&&(t=B[c].fontStyle);try{r=C[e][t]}catch(e){r=void 0}if(!r)throw new Error("Unable to look up font label for font '"+e+"', '"+t+"'. Refer to getFontList() for available fonts.");return r},Q=function(){x=!1,I=2,g=[],T=[],z("%PDF-1.3"),function(){var e,t,r,n,i,o;for(p=u*h,y=f*h,e=1;e<=k;e++){if(F(),z("<>"),z("endobj"),t=A[e].join("\n"),F(),w){for(r=[],n=0;n>8&255,o>>16&255,o>>24&255])],t="",r)r.hasOwnProperty(n)&&(t+=String.fromCharCode.apply(null,r[n]));z("<>")}else z("<>");W(t),z("endobj")}for(T[1]=m,z("1 0 obj"),z("<>"),z("endobj")}(),V(),F(),z("<<"),function(){z("/Producer (jsPDF "+r.version+")"),R.title&&z("/Title ("+X(R.title)+")"),R.subject&&z("/Subject ("+X(R.subject)+")"),R.author&&z("/Author ("+X(R.author)+")"),R.keywords&&z("/Keywords ("+X(R.keywords)+")"),R.creator&&z("/Creator ("+X(R.creator)+")");var e=new Date;z("/CreationDate (D:"+[e.getFullYear(),K(e.getMonth()+1),K(e.getDate()),K(e.getHours()),K(e.getMinutes()),K(e.getSeconds())].join("")+")")}(),z(">>"),z("endobj"),F(),z("<<"),z("/Type /Catalog"),z("/Pages 1 0 R"),z("/OpenAction [3 0 R /FitH null]"),z("/PageLayout /OneColumn"),N.publish("putCatalog"),z(">>"),z("endobj");var e,t,n,i=m;for(z("xref"),z("0 "+(I+1)),z("0000000000 65535 f "),e=1;e<=I;e++)z((t=T[e],void 0,((n=t.toFixed(0)).length<10?new Array(11-n.length).join("0")+n:n)+" 00000 n "));return z("trailer"),z("<<"),z("/Size "+(I+1)),z("/Root "+I+" 0 R"),z("/Info "+(I-1)+" 0 R"),z(">>"),z("startxref"),z(i),z("%%EOF"),x=!0,g.join("\n")},$=function(e){var t="S";return"F"===e?t="f":"FD"!==e&&"DF"!==e||(t="B"),t},ee=function(){var e,t,r,n;for(t=(e=Q()).length,r=new Uint8Array(new ArrayBuffer(t)),n=0;nf&&(l=u,u=f,f=l);else{if("l"!==n&&"landscape"!==n)throw"Invalid orientation: "+n;n="l",f>u&&(l=u,u=f,f=l)}for(d in D.internal={pdfEscape:X,getStyle:$,getFont:function(){return B[Z.apply(D,arguments)]},getFontSize:function(){return P},getLineHeight:function(){return P*M},btoa:btoa,write:function(e,t,r,n){z(1===arguments.length?e:Array.prototype.join.call(arguments," "))},getCoordinateString:function(e){return U(e*h)},getVerticalCoordinateString:function(e){return U((f-e)*h)},collections:{},newObject:F,putStream:W,events:N,scaleFactor:h,pageSize:{width:u,height:f},output:function(e,t){return te(e,t)},getNumberOfPages:function(){return A.length-1},pages:A},D.addPage=function(){return J(),this},D.text=function(e,t,r,n,i){if("number"==typeof e){var o=r;r=t,t=e,e=o}"string"==typeof e&&e.match(/[\n\r]/)&&(e=e.split(/\r\n|\r|\n/g)),"number"==typeof n&&(i=n,n=null);var s="",a="Td";if(i){i*=Math.PI/180;var u=Math.cos(i),l=Math.sin(i);s=[U(u),U(l),U(-1*l),U(u),""].join(" "),a="Tm"}if("noBOM"in(n=n||{})||(n.noBOM=!0),"autoencode"in n||(n.autoencode=!0),"string"==typeof e)e=X(e,n);else{if(!(e instanceof Array))throw new Error('Type of text must be string or Array. "'+e+'" is not recognized.');for(var d=e.concat(),p=[],y=d.length;y--;)p.push(X(d.shift(),n));e=p.join(") Tj\nT* (")}return z("BT\n/"+c+" "+P+" Tf\n"+P*M+" TL\n"+E+"\n"+s+U(t*h)+" "+U((f-r)*h)+" "+a+"\n("+e+") Tj\nET"),this},D.line=function(e,t,r,n){return z(U(e*h)+" "+U((f-t)*h)+" m "+U(r*h)+" "+U((f-n)*h)+" l S"),this},D.lines=function(e,t,r,n,i,o){var s,a,c,u,l,d,p,y,b,v,g,m,w;for("number"==typeof e&&(s=e,a=t,e=r,t=s,r=a),i=$(i),n=void 0===n?[1,1]:n,z(H(t*h)+" "+H((f-r)*h)+" m "),c=n[0],u=n[1],d=e.length,m=t,w=r,l=0;l>16&255,t=i>>8&255,r=255&i}return E=0===e&&0===t&&0===r||void 0===t?H(e/255)+" g":[H(e/255),H(t/255),H(r/255),"rg"].join(" "),this},D.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},D.setLineCap=function(e){var t=this.CapJoinStyles[e];if(void 0===t)throw new Error("Line cap style of '"+e+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=t,z(t.toString(10)+" J"),this},D.setLineJoin=function(e){var t=this.CapJoinStyles[e];if(void 0===t)throw new Error("Line join style of '"+e+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return j=t,z(t.toString(10)+" j"),this},D.output=te,D.save=function(e){D.output("save",e)},r.API)r.API.hasOwnProperty(d)&&("events"===d&&r.API.events.length?function(e,t){var r,n,i;for(i=t.length-1;-1!==i;i--)r=t[i][0],n=t[i][1],e.subscribe.apply(e,[r].concat("function"==typeof n?[n]:n))}(N,r.API.events):D[d]=r.API[d]);return function(){var e,t,r,n,i=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"]];for(e=0,t=i.length;en&&(i.push(e.slice(c,o)),a=0,c=o),a+=t[o],o++;return c!==o&&i.push(e.slice(c,o)),i}),i=function(e,i,o){o||(o={});var s,a,c,f,u,h=t(" ",o)[0],l=e.split(" "),d=[],p=[d],y=o.textIndent||0,b=0,v=0;for(c=0,f=l.length;ci){if(v>i){for(u=n(s,a,i-(y+b),i),d.push(u.shift()),d=[u.pop()];u.length;)p.push([u.shift()]);v=r(a.slice(s.length-d[0].length))}else d=[s];p.push(d),y=v,b=h}else d.push(s),y+=b+v,b=h;var g=[];for(c=0,f=p.length;c>"),"trns"in e&&e.trns.constructor==Array){for(var o="",s=0,a=e.trns.length;s>"),i(e.data),n("endobj"),"smask"in e){var c="/Predictor 15 /Colors 1 /BitsPerComponent "+e.bpc+" /Columns "+e.w,f={w:e.w,h:e.h,cs:"DeviceGray",bpc:e.bpc,dp:c,data:e.smask};"f"in e&&(f.f=e.f),r.call(this,f)}e.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+e.pal.length+">>"),i(this.arrayBufferToBinaryString(new Uint8Array(e.pal))),n("endobj"))},n=function(){var e=this.internal.collections.addImage_images;for(var t in e)r.call(this,e[t])},i=function(){var e,t=this.internal.collections.addImage_images,r=this.internal.write;for(var n in t)r("/I"+(e=t[n]).i,e.n,"0","R")},o=function(e,t){return e||t||(e=-96,t=-96),e<0&&(e=-1*info.w*72/e/this.internal.scaleFactor),t<0&&(t=-1*info.h*72/t/this.internal.scaleFactor),0===e&&(e=t*info.w/info.h),0===t&&(t=e*info.h/info.w),[e,t]};e.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},e.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},e.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},e.isString=function(e){return"string"==typeof e},e.extractInfoFromBase64DataURI=function(e){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(e)},e.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},e.isArrayBuffer=function(e){return!!this.supportsArrayBuffer()&&e instanceof ArrayBuffer},e.isArrayBufferView=function(e){return!!this.supportsArrayBuffer()&&(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)},e.binaryStringToUint8Array=function(e){for(var t=e.length,r=new Uint8Array(t),n=0;n>18]+n[(258048&t)>>12]+n[(4032&t)>>6]+n[63&t];return 1==s?r+=n[(252&(t=i[a]))>>2]+n[(3&t)<<4]+"==":2==s&&(r+=n[(64512&(t=i[a]<<8|i[a+1]))>>10]+n[(1008&t)>>4]+n[(15&t)<<2]+"="),r},e.createImageInfo=function(e,t,r,n,i,o,s,a,c,f,u,h){var l={alias:a,w:t,h:r,cs:n,bpc:i,i:s,data:e};return o&&(l.f=o),c&&(l.dp=c),f&&(l.trns=f),u&&(l.pal=u),h&&(l.smask=h),l},e.addImage=function(r,s,a,c,f,u,h,l){if("number"==typeof s){var d=u;u=f,f=c,c=a,a=s,s=d||"jpeg"}var p,y,b,v,g,m=function(){var e=this.internal.collections.addImage_images;return e||(this.internal.collections.addImage_images=e={},this.internal.events.subscribe("putResources",n),this.internal.events.subscribe("putXobjectDict",i)),e}.call(this);if((b=l)&&"string"==typeof b&&(b=b.toUpperCase()),l=b in e.image_compression?b:e.image_compression.NONE,s=s.toLowerCase(),function(e){return void 0===e||null===e}(h)&&(h=void 0),"object"==typeof(v=r)&&1===v.nodeType&&(r=function(e,t){var r=document.createElement("canvas");r.width=e.clientWidth||e.width,r.height=e.clientHeight||e.height;var n=r.getContext("2d");if(!n)throw"addImage requires canvas to be supported by browser.";return n.drawImage(e,0,0,r.width,r.height),r.toDataURL("png"==t?"image/png":"image/jpeg")}(r,s)),this.isString(r)){var w=this.extractInfoFromBase64DataURI(r);w?(s=w[2],r=atob(w[3]),this.supportsArrayBuffer()&&(y=r,r=this.binaryStringToUint8Array(r))):255!==r.charCodeAt(0)&&(p=function(e,t){var r;if(t)for(var n in t)if(e===t[n].alias){r=t[n];break}return r}(r,m))}if(g=s,-1===t.indexOf(g))throw new Error("addImage currently only supports formats "+t+", not '"+s+"'");if(function(t){return"function"!=typeof e["process"+t.toUpperCase()]}(s))throw new Error("please ensure that the plugin for '"+s+"' support is added");var _=function(e){var t=0;return e&&(t=Object.keys?Object.keys(e).length:function(e){var t=0;for(var r in e)e.hasOwnProperty(r)&&t++;return t}(e)),t}(m),E=p;if(E||(E=this["process"+s.toUpperCase()](r,_,h,l,y)),!E)throw new Error("An unkwown error occurred whilst processing the image");return function(e,t,r,n,i,s,a){var c=o(r,n),f=this.internal.getCoordinateString,u=this.internal.getVerticalCoordinateString;r=c[0],n=c[1],a[s]=i,this.internal.write("q",f(r),"0 0",f(n),f(e),u(t+n),"cm /I"+i.i,"Do Q")}.call(this,a,c,f,u,E,_,m),this};var s=function(e,t){return e.subarray(t,t+4)};e.processJPEG=function(e,t,r,n,i){var o,a=this.color_spaces.DEVICE_RGB,c=this.decode.DCT_DECODE;return this.isString(e)?(o=function(e){var t;if(255===!e.charCodeAt(0)||216===!e.charCodeAt(1)||255===!e.charCodeAt(2)||224===!e.charCodeAt(3)||!e.charCodeAt(6)==="J".charCodeAt(0)||!e.charCodeAt(7)==="F".charCodeAt(0)||!e.charCodeAt(8)==="I".charCodeAt(0)||!e.charCodeAt(9)==="F".charCodeAt(0)||0===!e.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var r=256*e.charCodeAt(4)+e.charCodeAt(5),n=4,i=e.length;n7)return{width:((t=s(e,i+5))[2]<<8)+t[3],height:(t[0]<<8)+t[1]};i+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")}(e),e=i||this.arrayBufferToBinaryString(e),this.createImageInfo(e,o.width,o.height,a,8,c,t,r)):null)},e.processJPG=function(e,t,r,n,i){return this.processJPEG(e,t,r,n,i)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(e){"use strict";var t=e.document,r=e.URL||e.webkitURL||e,n=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in n,o=e.webkitRequestFileSystem,s=e.requestFileSystem||o||e.mozRequestFileSystem,a=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c=0,f=[],u=function(e,t,r){for(var n=(t=[].concat(t)).length;n--;){var i=e["on"+t[n]];if("function"==typeof i)try{i.call(e,r||e)}catch(e){a(e)}}},h=function(r,a){var h,l,d,p,y,b=this,v=r.type,g=!1,m=function(){var t=(e.URL||e.webkitURL||e).createObjectURL(r);return f.push(t),t},w=function(){u(b,"writestart progress write writeend".split(" "))},_=function(){!g&&h||(h=m()),l&&(l.location.href=h),b.readyState=b.DONE,w()},E=function(e){return function(){if(b.readyState!==b.DONE)return e.apply(this,arguments)}},S={create:!0,exclusive:!1};if(b.readyState=b.INIT,a||(a="download"),i&&(h=m(),n.href=h,n.download=a,p=n,(y=t.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),p.dispatchEvent(y)))return b.readyState=b.DONE,void w();e.chrome&&v&&"application/octet-stream"!==v&&(d=r.slice||r.webkitSlice,r=d.call(r,0,r.size,"application/octet-stream"),g=!0),o&&"download"!==a&&(a+=".download"),l="application/octet-stream"===v||o?e:e.open(),s?(c+=r.size,s(e.TEMPORARY,c,E(function(e){e.root.getDirectory("saved",S,E(function(e){var t=function(){e.getFile(a,S,E(function(e){e.createWriter(E(function(t){t.onwriteend=function(t){l.location.href=e.toURL(),f.push(e),b.readyState=b.DONE,u(b,"writeend",t)},t.onerror=function(){var e=t.error;e.code!==e.ABORT_ERR&&_()},"writestart progress write abort".split(" ").forEach(function(e){t["on"+e]=b["on"+e]}),t.write(r),b.abort=function(){t.abort(),b.readyState=b.DONE},b.readyState=b.WRITING}),_)}),_)};e.getFile(a,{create:!1},E(function(e){e.remove(),t()}),E(function(e){e.code===e.NOT_FOUND_ERR?t():_()}))}),_)}),_)):_()},l=h.prototype;return l.abort=function(){this.readyState=this.DONE,u(this,"abort")},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,e.addEventListener("unload",function(){for(var e=f.length;e--;){var t=f[e];"string"==typeof t?r.revokeObjectURL(t):t.remove()}f.length=0},!1),function(e,t){return new h(e,t)}}(self);!function(e){"use strict";var t=function(){var e="function"==typeof Deflater;if(!e)throw new Error("requires deflate.js for compression");return e},r=function(t,r,s,h){var l=5,d=c;switch(h){case e.image_compression.FAST:l=3,d=a;break;case e.image_compression.MEDIUM:l=6,d=f;break;case e.image_compression.SLOW:l=9,d=u}t=o(t,r,s,d);var p=new Uint8Array(n(l)),y=i(t),b=new Deflater(l),v=b.append(t),g=b.flush(),m=p.length+v.length+g.length,w=new Uint8Array(m+4);return w.set(p),w.set(v,p.length),w.set(g,p.length+v.length),w[m++]=y>>>24&255,w[m++]=y>>>16&255,w[m++]=y>>>8&255,w[m++]=255&y,e.arrayBufferToBinaryString(w)},n=function(e,t){var r=Math.LOG2E*Math.log(32768)-8<<4|8,n=r<<8;return n|=Math.min(3,(t-1&255)>>1)<<6,n|=0,[r,255&(n+=31-n%31)]},i=function(e,t){for(var r,n=1,i=0,o=e.length,s=0;o>0;){o-=r=o>t?t:o;do{i+=n+=e[s++]}while(--r);n%=65521,i%=65521}return(i<<16|n)>>>0},o=function(e,t,r,n){for(var i,o,s,a=e.length/t,c=new Uint8Array(e.length+a),f=l(),u=0;u>>1)&255;return o},u=function(e,t,r){var n,i,o,s,a=[],c=0,f=e.length;for(a[0]=4;c>>v&255,v+=c.bits;w[E]=k>>>v&255}if(16===c.bits){g=(B=new Uint32Array(c.decodePixels().buffer)).length,m=new Uint8Array(g*(32/c.pixelBitlength)*c.colors),w=new Uint8Array(g*(32/c.pixelBitlength));for(var k,A=c.colors>1,I=(E=0,S=0,0);E>>0&255,A&&(m[S++]=k>>>16&255,k=B[E++],m[S++]=k>>>0&255),w[I++]=k>>>16&255;b=8}s!==e.image_compression.NONE&&t()?(n=r(m,c.width*c.colors,c.colors,s),d=r(w,c.width,1,s)):(n=m,d=w,y=null)}if(3===c.colorType&&(p=this.color_spaces.INDEXED,l=c.palette,c.transparency.indexed)){var x=c.transparency.indexed,T=0;for(E=0,g=x.length;En&&(r=n)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(t,r)},lookChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(e,t,r){for(var n=e+t;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,e,t,r)},skip:function(e){e||(e=1),this.pos+=e},reset:function(){this.pos=0}},e}(),FlateStream=function(){var e=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),n=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function o(e){throw new Error(e)}function s(e){var t=0,r=e[t++],n=e[t++];-1!=r&&-1!=n||o("Invalid header in flate stream"),8!=(15&r)&&o("Unknown compression method in flate stream"),((r<<8)+n)%31!=0&&o("Bad FCHECK in flate stream"),32&n&&o("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=t,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}return s.prototype=Object.create(DecodeStream.prototype),s.prototype.getBits=function(e){for(var t,r=this.codeSize,n=this.codeBuf,i=this.bytes,s=this.bytesPos;r>e,this.codeSize=r-=e,this.bytesPos=s,t},s.prototype.getCode=function(e){for(var t=e[0],r=e[1],n=this.codeSize,i=this.codeBuf,s=this.bytes,a=this.bytesPos;n>16,h=65535&f;return(0==n||n>u,this.codeSize=n-u,this.bytesPos=a,h},s.prototype.generateHuffmanTable=function(e){for(var t=e.length,r=0,n=0;nr&&(r=e[n]);for(var i=1<>=1;for(n=u;n0;)t[p++]=i}var a=this.getBits(3);if(1&a&&(this.eof=!0),0!=(a>>=1)){var c,f;if(1==a)c=n,f=i;else if(2==a){for(var u=this.getBits(5)+257,h=this.getBits(5)+1,l=this.getBits(4)+4,d=Array(e.length),p=0;p=w&&(w=(O=this.ensureBuffer(_+1)).length),O[_++]=E;else{if(256==E)return void(this.bufferLength=_);var S=(E=t[E-=257])>>16;S>0&&(S=this.getBits(S));b=(65535&E)+S;E=this.getCode(f),(S=(E=r[E])>>16)>0&&(S=this.getBits(S));var k=(65535&E)+S;_+b>=w&&(w=(O=this.ensureBuffer(_+b)).length);for(var A=0;At;0<=t?++l:--l)e.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(t),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((u=n-this.transparency.indexed.length)>0)for(d=0;0<=u?du;0<=u?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(t)[0];break;case 2:this.transparency.rgb=this.read(t)}break;case"tEXt":a=(h=this.read(t)).indexOf(0),c=String.fromCharCode.apply(String,h.slice(0,a)),this.text[c]=String.fromCharCode.apply(String,h.slice(a+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=t}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return n.load=function(e,t,r){var i;return"function"==typeof t&&(r=t),(i=new XMLHttpRequest).open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){var e;return e=new n(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=t?t.getContext:void 0)&&e.render(t),"function"==typeof r?r(e):void 0},i.send(null)},0,1,2,0,1,n.prototype.read=function(e){var t,r;for(r=[],t=0;0<=e?te;0<=e?++t:--t)r.push(this.data[this.pos++]);return r},n.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.decodePixels=function(e){var t,r,n,i,o,s,a,c,f,u,h,l,d,p,y,b,v,g,m,w,_,E,S;if(null==e&&(e=this.imgData),0===e.length)return new Uint8Array(0);for(e=(e=new FlateStream(e)).getBytes(),b=(l=this.pixelBitlength/8)*this.width,d=new Uint8Array(b*this.height),s=e.length,y=0,p=0,r=0;p1&&r/i0})})})}),s.then(function(e){o.resolve({has_transactions:e})},function(e){o.reject(e)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){if(null===e.data)return e;var t=n.converter.convertAddressTxs(e);return t.data=t.data.filter(function(e){return!e.confirmations}),t}),r)},_.prototype.addressUnspentOutputs=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(t){return null===t.data?t:n.converter.convertAddressUnspentOutputs(t,e)}),r)},_.prototype.batchAddressUnspentOutputs=function(e,t,r){var n=this;return n.converter instanceof f?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBatchAddressUnspentOutputs(e)}),r):("function"==typeof t&&(r=t,t=null),w(n.dataClient.post("/address/unspent-outputs",t,{addresses:e}),r))},_.prototype.verifyAddress=function(e,t,r){return this.verifyMessage(e,e,t,r)},_.prototype.allBlocks=function(e,t){var r=this;return"function"==typeof e&&(t=e,e=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(e)).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlocks(e)}),t)},_.prototype.block=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlock(e.data)}),t)},_.prototype.blockLatest=function(e){var t=this;return w(t.dataClient.get(t.converter.getUrlForBlock("latest"),null).then(function(e){return t.converter.handleErrors(t,e)}).then(function(e){return null===e.data?e:t.converter.convertBlock(e.data)}),e)},_.prototype.blockTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBlockTxs(e)}),r)},_.prototype.transaction=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(t){return null===t.data?t:r.converter instanceof f?r.dataClient.get(r.converter.getUrlForRawTransaction(e),null).then(function(e){return[t,e.data]}).then(function(e){if(null!==e){var t=e[0],n=e[1];return r.converter.convertTx(t,n)}return e}):r.converter.convertTx(t)}),t)},_.prototype.transactions=function(e,t){var r=this;return r.converter instanceof f?w(r.dataClient.get(r.converter.getUrlForTransactions(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertTxs(e)}),t):w(r.dataClient.post("/transactions",null,e,null,!1),t)},_.prototype.allWebhooks=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/webhooks",e,t)},_.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.post("/webhook",null,{url:e,identifier:t},r)},_.prototype.getLegacyBitcoinCashAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromBase58Check(e,this.network),e}catch(e){}if((t=o.address.fromCashAddress(e,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(t.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(t.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromCashAddress(e,this.network),e}catch(e){}if((t=o.address.fromBase58Check(e,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(t.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(t.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(e,t){return this.blocktrailClient.get("/webhook/"+e,null,t)},_.prototype.updateWebhook=function(e,t,r){return this.blocktrailClient.put("/webhook/"+e,null,t,r)},_.prototype.deleteWebhook=function(e,t){return this.blocktrailClient.delete("/webhook/"+e,null,null,t)},_.prototype.getWebhookEvents=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/webhook/"+e+"/events",t,r)},_.prototype.subscribeTransaction=function(e,t,r,n){var i={event_type:"transaction",transaction:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(e,t,r,n){var i={event_type:"address-transactions",address:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(e,t,r){return t.forEach(function(e){e.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+e+"/events/batch",null,t,r)},_.prototype.subscribeNewBlocks=function(e,t){return this.blocktrailClient.post("/webhook/"+e+"/events",null,{event_type:"block"},t)},_.prototype.unsubscribeAddressTransactions=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/address-transactions/"+t,null,null,r)},_.prototype.unsubscribeTransaction=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/transaction/"+t,null,null,r)},_.prototype.unsubscribeNewBlocks=function(e,t){return this.blocktrailClient.delete("/webhook/"+e+"/block",null,null,t)},_.prototype.getWalletLatestBlock=function(e){return this.blocktrailClient.get("/block/latest",null,e)},_.prototype.initWallet=function(e,t){var r=this;if("object"!=typeof e&&(e={identifier:arguments[0],passphrase:arguments[1]},t=arguments[2]),e.check_backup_key&&"string"!=typeof e.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(t);var a=e.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(t){var i=e.keyIndex||t.key_index;if(e.walletVersion=t.wallet_version,e.check_backup_key&&e.check_backup_key!==t.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(t.backup_public_key[0],r.network),f=n.mapValues(t.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),u=n.mapValues(t.primary_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),h=new c(r,a,e.walletVersion,t.primary_mnemonic,t.encrypted_primary_seed,t.encrypted_secret,u,s,f,i,t.segwit||0,r.testnet,r.regtest,t.checksum,t.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.recoverySecret=t.recovery_secret,e.readOnly?h:h.unlock(e).then(function(){return h})})),s.promise):(s.reject(new y.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(e,t){var r=this;if("object"!=typeof e){var n=arguments[0],o=arguments[1],s=arguments[2];t=arguments[3],"function"==typeof s&&(t=s,s=null),e={identifier:n,passphrase:o,keyIndex:s}}e.walletVersion=e.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(t),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),e.keyIndex=e.keyIndex||0,e.passphrase=e.passphrase||e.password,delete e.password,!e.identifier)return a.reject(new y.WalletCreateError("Identifier is required")),a.promise;e.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):a.reject(new y.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(e){var t=this,r=i.defer();return i.nextTick(function(){if(!e.primaryMnemonic&&!e.primarySeed){if(!e.passphrase&&!e.password)return r.reject(new y.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;e.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==e.storePrimaryMnemonic&&(e.storePrimaryMnemonic=!0)}e.backupMnemonic||e.backupPublicKey||(e.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),t.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),t.resolveBackupPublicKeyFromOptions(e).then(function(e){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),a=e.keyIndex,f=e.primaryPrivateKey.deriveHardened(a).neutered();return t.storeNewWalletV1(e.identifier,[f.toBase58(),"M/"+a+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storePrimaryMnemonic&&e.primaryMnemonic,s,a,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V1,e.primaryMnemonic,null,null,{keyIndex:f},e.backupPublicKey,u,a,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:e.passphrase,primarySeed:e.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:e.primaryMnemonic,backupMnemonic:e.backupMnemonic,blocktrailPublicKeys:u}]})})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)})}),r.promise},_.prototype._createNewWalletV2=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new y.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||b(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return function(e,t){return i.when(e).then(function(e){if(e.storeDataOnServer){if(!e.secret){if(!e.passphrase)throw new y.WalletCreateError("Can't encrypt data without a passphrase");t(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),e.secret=b(c.WALLET_ENTROPY_BITS/8).toString("hex"),e.encryptedSecret=v.AES.encrypt(e.secret,e.passphrase).toString(v.format.OpenSSL)}t(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),e.encryptedPrimarySeed=v.AES.encrypt(e.primarySeed.toString("base64"),e.secret).toString(v.format.OpenSSL),e.recoverySecret=b(c.WALLET_ENTROPY_BITS/8).toString("hex"),t(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),e.recoveryEncryptedSecret=v.AES.encrypt(e.secret,e.recoverySecret).toString(v.format.OpenSSL)}return e})}(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),f=e.keyIndex;return t.storeNewWalletV2(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+f+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,f,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V2,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,u,f,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?a.entropyToMnemonic(y.convert(e.encryptedPrimarySeed,"base64","hex")):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed.toString("hex")):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?a.entropyToMnemonic(y.convert(e.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:e.encryptedSecret?a.entropyToMnemonic(y.convert(e.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:u}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype._createNewWalletV3=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new y.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||b(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return t.produceEncryptedDataV3(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),f=e.keyIndex;return t.storeNewWalletV3(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+f+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,f,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V3,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,u,f,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?p.encode(e.encryptedPrimarySeed):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?p.encode(e.recoveryEncryptedSecret):null,encryptedSecret:e.encryptedSecret?p.encode(e.encryptedSecret):null,blocktrailPublicKeys:u}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype.storeNewWalletV1=function(e,t,r,n,i,o,s){var a={identifier:e,wallet_version:c.WALLET_VERSION_V1,primary_public_key:t,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(e,t,r,n,i,o,s,a,f,u){var h={identifier:e,wallet_version:c.WALLET_VERSION_V2,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:f||null,segwit:u};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(e,t,r,n,i,o,s,a,f,u){var h={identifier:e,wallet_version:c.WALLET_VERSION_V3,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:f||null,segwit:u};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e,null,t,r)},_.prototype.upgradeKeyIndex=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/upgrade",null,{key_index:t,primary_public_key:r},n)},_.prototype.getWalletBalance=function(e,t){return this.blocktrailClient.get("/wallet/"+e+"/balance",null,!0,t)},_.prototype.doWalletDiscovery=function(e,t,r){return this.blocktrailClient.get("/wallet/"+e+"/discovery",{gap:t},!0,r)},_.prototype.getNewDerivation=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e+"/path",null,{path:t},r)},_.prototype.deleteWallet=function(e,t,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+e,{force:n},{checksum:t,signature:r},i)},_.prototype.coinSelection=function(e,t,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var f=i.defer();f.promise.spreadNodeify(a);var u={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(u.forcefee=s.forcefee),f.resolve(this.blocktrailClient.post("/wallet/"+e+"/coin-selection",u,t).then(function(e){return[e.utxos,e.fee,e.change,e]},function(e){if(e.message.match(/too low to pay the fee/))throw y.WalletFeeError(e);throw e})),f.promise},_.prototype.feePerKB=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.blocktrailClient.get("/fee-per-kb")),t.promise},_.prototype.sendTransaction=function(e,t,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof t?c.raw_transaction=t:"object"==typeof t&&Object.keys(t).map(function(e){c[e]=t[e]});var f={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(f.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(f.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(e){return String.fromCharCode(e)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+e+"/send",f,c,a)},_.prototype.setupWalletWebhook=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/webhook",null,{url:r,identifier:t},n)},_.prototype.deleteWalletWebhook=function(e,t,r){return this.blocktrailClient.delete("/wallet/"+e+"/webhook/"+t,null,null,r)},_.prototype.walletTransactions=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/transactions",t,!0,r)},_.prototype.walletAddresses=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/addresses",t,!0,r)},_.prototype.labelWalletAddress=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/address/"+t+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(e,t,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:t?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+e+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/utxos",t,!0,r)},_.prototype.allWallets=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/wallets",e,!0,t)},_.prototype.verifyMessage=function(e,t,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(t,this.network.messagePrefix,e,new Buffer(r,"base64"));o.resolve(a)}catch(e){o.reject(e)}return o.promise},_.prototype.faucetWithdrawl=function(e,t,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:e,amount:t},r)},_.prototype.sendRawTransaction=function(e,t){return this.blocktrailClient.post("/send-raw-tx",null,e,t)},_.prototype.price=function(e){return this.blocktrailClient.get("/price",null,!1,e)},t.exports=_}).call(this,e("_process"),e("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:271,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:131,"crypto-js":178,lodash:262,q:299,randombytes:306}],2:[function(e,t,r){var n=function(){};n.prototype.paginationParams=function(e){return e},n.prototype.getUrlForBlock=function(e){return"/block/"+e},n.prototype.getUrlForTransaction=function(e){return"/transaction/"+e},n.prototype.getUrlForBlockTransaction=function(e){return"/block/"+e+"/transactions"},n.prototype.getUrlForAddress=function(e){return"/address/"+e},n.prototype.getUrlForAddressTransactions=function(e){return"/address/"+e+"/transactions"},n.prototype.getUrlForAddressUnspent=function(e){return"/address/"+e+"/unspent-outputs"},n.prototype.convertBlock=function(e){return e},n.prototype.convertBlockTxs=function(e){return e},n.prototype.convertTx=function(e){return e},n.prototype.convertAddressTxs=function(e){return e},n.prototype.convertAddress=function(e){return e},n.prototype.convertAddressUnspentOutputs=function(e){return e},n.prototype.convertBatchAddressUnspentOutputs=function(e){return e},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(e,t){return t},t.exports=n},{}],3:[function(e,t,r){(function(Buffer){var r=e("util"),n=e("assert"),i=e("crypto-js"),o=e("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(e,t,r){return new Buffer(e,t).toString(r)},c=function(e,t){return function(e,t){var r=o.mnemonicToEntropy(e),n=a(r,"hex","base64"),c=i.AES.decrypt(n,t).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(e,t).toString(i.enc.Utf8)},f=function(e,t){return a(c(e,t),"base64","hex")},u=function(e,t){var r=i.AES.encrypt(e,t).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(e,t){return new Buffer(f(e,t),"hex")},s.aesDecryptMnemonicToSeedHex=f,s.aesEncryptSeedToMnemonic=u,s.aesEncryptSeedHexToMnemonic=function(e,t){return u(a(e,"hex","base64"),t)},s.aesEncryptSeedBufferToMnemonic=function(e,t){return u(e.toString("base64"),t)},s.V3Crypt={KeyDerivation:e("./keyderivation"),Encryption:e("./encryption"),EncryptionMnemonic:e("./encryption_mnemonic")},s.toSatoshi=function(e){return parseInt((e*s.COIN).toFixed(0),10)},s.toBTC=function(e){return(e/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(e){e.spreadNodeify&&e.spreadDone||(e.spreadDone=function(t,r,n){return e(t).spreadDone(r,n)},e.makePromise.prototype.spreadDone=function(e,t){return this.all().done(function(t){return e.apply(void 0,t)},t)},e.spreadNodeify=function(t,r){return e(t).spreadNodeify(r)},e.makePromise.prototype.spreadNodeify=function(t){if(!t)return this;this.then(function(r){e.nextTick(function(){t.apply(void 0,[null].concat(r))})},function(r){e.nextTick(function(){t(r)})})})},Error.extend=function(e,t){n(e,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=e,this.code=t,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var e,t=0,r=this.length-1;t<=r;++t,--r)e=this[t],this[t]=this[r],this[r]=e;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(e("q")),t.exports=s}).call(this,e("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:131,"crypto-js":178,q:299,util:360}],4:[function(e,t,r){var n=e("./wallet"),i=e("./blocktrail"),o=e("bitcoinjs-lib"),s=function(e,t){this.network=e,this.useNewCashAddr=t};function a(e,t,r){var n;try{n=o.address.toOutputScript(e,t,r)}catch(e){n=null}return n}function c(e){var t;try{t=o.script.toASM(e)}catch(e){t=null}return t}function f(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function u(e){var t;try{t=o.script.classifyOutput(e)}catch(e){t=null}return t}function h(e){switch(e){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+e)}}function l(e){return new Date(1e3*e).toISOString().replace(/\.000Z$/,"+0000")}function d(e){return e&&1===e.length?e[0]:e}function p(e){var t,r={};for(var n in r.size=e.vsize,r.hash=e.hash,r.block_height=e.block_height,r.time=r.block_time=l(e.block_time),r.block_hash=e.block_hash,r.confirmations=e.confirmations,r.is_coinbase=e.is_coinbase,t=r.is_coinbase?e.outputs[0].value-e.fee:e.inputs_value,r.total_input_value=t,r.total_output_value=e.outputs.reduce(function(e,t){return e+t.value},0),r.total_fee=e.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,e.inputs){var s,a,c,u,p=e.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&e)&&(r+=t),0!==(e>>>=1);)t+=t;return r});var i={chunkSize:4,paddingDummy:129},o=function(e){if(e[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-e.length%i.chunkSize)};i.encode=function(e){r(e instanceof Buffer,"Data must be provided as a Buffer");var t=o(e),i=n.entropyToMnemonic(t+e.toString("hex"));try{n.mnemonicToEntropy(i)}catch(e){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(e){r("string"==typeof e,"Mnemonic must be provided as a string");for(var t=new Buffer(n.mnemonicToEntropy(e),"hex"),i=0;t[i]===this.paddingDummy;)i++;var s=t.slice(i,t.length);if(o(s)!==t.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},t.exports=i}).call(this,e("buffer").Buffer)},{assert:24,bip39:36,buffer:131}],7:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(e,t,i){if(i=i||this.defaultIterations,r(e instanceof Buffer,"Password must be provided as a Buffer"),r(t instanceof Buffer,"Salt must be provided as a Buffer"),r(t.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),t.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(e,t,i,this.keySizeBits/8)}};t.exports=i}).call(this,e("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:131}],8:[function(e,t,r){(function(Buffer){t.exports={digest:function(e,t,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(e,t,r,n).buffer)}}}).call(this,e("buffer").Buffer)},{buffer:131}],9:[function(e,t,r){t.exports={VERSION:"3.7.22"}},{}],10:[function(e,t,r){(function(r){var n=e("./blocktrail"),i=e("lodash"),o=e("url"),s=e("querystring"),a=e("q"),c=e("create-hash"),f=e("superagent"),u=e("superagent-http-signature/index-hmac-only"),h=e("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(e){this.https=e.https,this.host=e.host,this.endpoint=e.endpoint,this.auth=e.auth,this.port=e.port,this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.contentMd5=void 0===e.contentMd5||e.contentMd5,this.params=i.defaults({},e.params),this.headers=i.defaults({},e.headers)}p.qs=function(e){var t=[],r=Object.keys(e);return r.sort(),r.forEach(function(r){var n={};n[r]=e[r],t.push(s.stringify(n))}),t.join("&")},p.prototype.request=function(e,t,r,n,s){this.deferred=a.defer(),this.callback=s||d;var f=o.parse(t,!0),u=p.qs(i.defaults({},r||{},f.query||{},this.params||{}));this.path="".concat(this.endpoint,f.pathname),u&&(this.path=this.path.concat("?",u)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===e||"DELETE"===e?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",e,this.host,this.path);var y={hostname:this.host,path:this.path,port:this.port,method:e,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(y),this.deferred.promise},p.prototype.performRequest=function(e){var t=this,r=e.method,n=!1;"http-signature"===e.auth&&(n=!0,delete e.auth);var o=(t.https?"https://":"http://")+e.hostname+e.path,s=f(r,o);if(!t.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(t.payload),i.forEach(e.headers,function(e,t){s.set(t,e)}),n){if(!t.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return t.deferred.reject(a),t.callback(a)}s.use(u({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:t.apiSecret,keyId:t.apiKey}))}return s.end(function(e,r){var n;if(e){var i=p.handleFailure(e.response&&e.response.body,e.status);return t.deferred.reject(i),t.callback(i,e.response&&e.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!e&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(t){e=t}return n||(n=r.text),e||200===r.status||(e=p.handleFailure(r.text,r.statusCode)),e?t.deferred.reject(e):t.deferred.resolve(n),t.callback(e,n)}),t.deferred},p.handleFailure=function(e,t){var r,n;if("object"==typeof e)r=e;else try{r=JSON.parse(e)}catch(e){}if(r){var i=r.msg||"";i||429===t&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(e){"msg"!==e&&(n[e]=r[e])})}else n=e?new Error(e):new Error("Unknown Server Error");return t&&(n.statusCode=t),p.convertError(n)},p.convertError=function(e){return e.requires_2fa&&!e.requires_email_2fa?new n.WalletMissing2FAError:e.requires_email_2fa?new n.WalletMissingEmail2FAError:e.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:e},t.exports=p}).call(this,e("_process"))},{"./blocktrail":3,_process:271,"create-hash":139,debug:204,lodash:262,q:299,querystring:305,superagent:344,"superagent-http-signature/index-hmac-only":340,url:356}],11:[function(e,t,r){var n=e("lodash"),i=e("./request"),o=e("q"),s=function(t){this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.https=t.https,this.host=t.host,this.port=t.port,this.endpoint=t.endpoint,this.btccom=!!t.btccom,void 0!==t.throttleRequestsTimeout?this.throttleRequestsTimeout=t.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+e("./pkginfo").VERSION},t.defaultHeaders))};s.prototype.throttle=function(){var e=this,t=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return t.resolve(),o.delay(e.throttleRequestsTimeout)}):(this.nextRequest=o.delay(e.throttleRequestsTimeout),t.resolve()):t.resolve(),t.promise},s.prototype.create_request=function(e){return e=n.defaults({},e,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(e)},s.prototype.post=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",e,t,r,n)})},s.prototype.put=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",e,t,r,n)})},s.prototype.get=function(e,t,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",e,t,null,n)})},s.prototype.delete=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",e,t,r,n)})},t.exports=function(e){return new s(e)}},{"./pkginfo":9,"./request":10,lodash:262,q:299}],12:[function(e,t,r){var n=e("../api_client"),i=e("lodash"),o=e("q"),s=e("async"),a=function(e){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,e);var t=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=t.network,this.settings.testnet=t.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(e,t){switch(e.toLowerCase()){case"btc":case"bitcoin":return t?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return t?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+e)}},a.prototype.setPaginationLimit=function(e){this.settings.paginationLimit=e},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(e){return Math.max(e.optimal,e.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(e){var t=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:t.settings.paginationLimit};t.client.batchAddressUnspentOutputs(e,o).then(function(e){i=i.concat(e.data),n++,r()},function(e){console.log("error happened:",e),r(e)})},function(){return null},function(e){e&&console.log("complete, but with errors",e.message);var t={};i.forEach(function(e){var r=e.address;void 0===t[r]&&(t[r]=[]),t[r].push({hash:e.hash,index:e.index,value:e.value,script_hex:e.script_hex})}),r.resolve(t)}),r.promise},a.prototype.batchAddressHasTransactions=function(e){return this.client.batchAddressHasTransactions(e).then(function(e){return e.has_transactions})},t.exports=a},{"../api_client":1,async:28,lodash:262,q:299}],13:[function(e,t,r){var n=e("../blocktrail"),i=e("superagent"),o=e("lodash"),s=e("q"),a=function(e){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===e.host&&e.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,e),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(e){var t=s.defer(),r={addrs:e.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.txid,index:e.vout,value:n.toSatoshi(e.amount),script_hex:e.scriptPubKey,confirmations:e.confirmations})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={addrs:e.join(",")};return this.postEndpoint("addrs/txs",t).then(function(e){return e.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(e){return-1===e[4]?1e5:e[4]<1e-5?1e3:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("tx/send",{rawtx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=s.defer();return i.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=s.defer();return i.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,lodash:262,q:299,superagent:344}],14:[function(e,t,r){e("../blocktrail");var n=e("superagent"),i=e("lodash"),o=e("q"),s=e("bitcoinjs-lib"),a=function(e){if(!("host"in e))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,e)};a.prototype.getBatchUnspentOutputs=function(e){var t=o.defer(),r={address:e};return this.postEndpoint("addressListUnspent",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.tx_hash,index:e.tx_pos,value:e.value,script_hex:s.address.toOutputScript(t,s.networks.bitcoincash),confirmations:1})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={address:e};return this.postEndpoint("addressHasTransactions",t).then(function(e){return e.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(e){return-1===e[4]?1e5:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("publishTx",{tx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=o.defer();return n.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=o.defer();return n.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:262,q:299,superagent:344}],15:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(e){return e?33:65},getLengthForScriptPush:function(e){if(e<75)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(e){if(e<253)return 1;var t;if(e<65535)t=2;else if(e<4294967295)t=4;else{if(!(e<0x10000000000000000))throw new Error("Size of varint too large");t=8}return 1+t},estimateMultisigStackSize:function(e,t){var r,n=[0];for(r=0;r0&&(s.map(function(e){f+=a.getLengthForVarInt(e)+e}),f+=a.getLengthForVarInt(s.length)),[c,f]},estimateInputFromScripts:function(e,t,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(e)){var c=n.script.multisig.output.decode(e);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(e)){var f=n.script.pubKey.output.decode(e);a=this.estimateP2PKStackSize(f)[0]}else{if(!n.script.pubKeyHash.output.check(e))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,t,i)},estimateUtxo:function(e,t){var r=Buffer.from(e.scriptpubkey_hex,"hex"),i=null,o=null;e.redeem_script&&("string"==typeof e.redeem_script?i=Buffer.from(e.redeem_script,"hex"):e.redeem_script instanceof Buffer&&(i=e.redeem_script)),e.witness_script&&("string"==typeof e.witness_script?o=Buffer.from(e.witness_script,"hex"):e.witness_script instanceof Buffer&&(o=e.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var f=n.script.types,u=[f.MULTISIG,f.P2PKH,f.P2PK],h=n.script.classifyOutput(a);if(-1===u.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,t);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(e,t){var r=0,n=0;return e.map(function(e){var o=i.estimateUtxo(e);r+=40+o.scriptSig,t&&(n+=o.witness)}),t&&n>0&&(r+=2+n),r},calculateOutputsSize:function(e){var t=0;return e.map(function(e){var r=i.getLengthForVarInt(e.script.length);t+=8+r+e.script.length}),t},estimateTxWeight:function(e,t){var r=i.calculateOutputsSize(e.outs);return 3*(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!1)+i.getLengthForVarInt(e.outs.length)+r+4)+(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!0)+i.getLengthForVarInt(e.outs.length)+r+4)},estimateTxVsize:function(e,t){return parseInt(Math.ceil(i.estimateTxWeight(e,t)/4),10)}};t.exports=i}).call(this,e("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:131}],16:[function(e,t,r){var n=e("lodash"),i=e("q"),o=e("async"),s=function(e,t){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,t),this.dataClient=e};s.prototype.getUTXOs=function(e){var t=this,r={},s=i.defer();return o.eachSeries(n.chunk(e,t.settings.batchChunkSize),function(e,i){t.settings.logging&&console.log("checking batch of "+e.length+" addresses for UTXOs",e.join(",")),t.dataClient.getBatchUnspentOutputs(e).done(function(e){n.each(e,function(e,t){e.length>0&&(r[t]=e)}),i()},function(e){i(e)})},function(e){e&&console.log("error encountered",e),s.resolve(r)}),s.promise},t.exports=s},{async:28,lodash:262,q:299}],17:[function(e,t,r){(function(e){var r=!!e.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),t.exports=function(){return r}}).call(this,e("_process"))},{_process:271}],18:[function(e,t,r){(function(Buffer){var r=e("lodash"),n=e("assert"),i=e("q"),o=e("async"),s=e("bitcoinjs-lib"),a=e("bitcoinjs-message"),c=e("./blocktrail"),f=e("crypto-js"),u=e("./encryption"),h=e("./encryption_mnemonic"),l=e("./size_estimation"),d=e("bip39"),p="sign",y=function(e,t,i,o,a,c,f,u,h,l,d,p,b,v,g,m,w){this.sdk=e,this.identifier=t,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=b,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(u instanceof s.HDNode),n(r.every(f,function(e){return e instanceof s.HDNode})),n(r.every(h,function(e){return e instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=u,this.blocktrailPublicKeys=h,this.primaryPublicKeys=f,this.keyIndex=l,this.bitcoinCash?(this.chain=y.CHAIN_BCC_DEFAULT,this.changeChain=y.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=y.CHAIN_BTC_SEGWIT,this.changeChain=y.CHAIN_BTC_SEGWIT):(this.chain=y.CHAIN_BTC_DEFAULT,this.changeChain=y.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=g,this.secret=null,this.seedHex=null};function b(e,t){var r,n;try{r=s.address.fromBech32(e,t),n=null}catch(e){n=e}if(!n&&r.prefix!==t.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function v(e,t){var r,n;e=e.toLowerCase();try{r=s.address.fromCashAddress(e),n=null}catch(e){n=e}if(n)try{r=s.address.fromCashAddress(t.cashAddrPrefix+":"+e),n=null}catch(e){n=e}if(!n&&r.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix");return[n,r]}function g(e,t){var r,n;try{r=s.address.fromBase58Check(e),n=null}catch(e){n=e}if(!n&&r.version!==t.pubKeyHash&&r.version!==t.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}y.WALLET_VERSION_V1="v1",y.WALLET_VERSION_V2="v2",y.WALLET_VERSION_V3="v3",y.WALLET_ENTROPY_BITS=256,y.OP_RETURN="opreturn",y.DATA=y.OP_RETURN,y.PAY_PROGRESS_START=0,y.PAY_PROGRESS_COIN_SELECTION=10,y.PAY_PROGRESS_CHANGE_ADDRESS=20,y.PAY_PROGRESS_SIGN=30,y.PAY_PROGRESS_SEND=40,y.PAY_PROGRESS_DONE=100,y.CHAIN_BTC_DEFAULT=0,y.CHAIN_BTC_SEGWIT=2,y.CHAIN_BCC_DEFAULT=1,y.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,y.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,y.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,y.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,y.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,y.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,y.prototype.isSegwit=function(){return!!this.segwit},y.prototype.unlock=function(e,t){var n=this,o=i.defer();return o.promise.nodeify(t),e=r.merge({},e),i.fcall(function(){switch(n.walletVersion){case y.WALLET_VERSION_V1:return n.unlockV1(e);case y.WALLET_VERSION_V2:return n.unlockV2(e);case y.WALLET_VERSION_V3:return n.unlockV3(e);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(e){n.primaryPrivateKey=e;var t=n.primaryPrivateKey.getAddress();if(t!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+t+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(e){o.resolve(e)},function(e){o.reject(e)}),o.promise},y.prototype.unlockV1=function(e){var t=this;return e.primaryMnemonic=void 0!==e.primaryMnemonic?e.primaryMnemonic:t.primaryMnemonic,e.secretMnemonic=void 0!==e.secretMnemonic?e.secretMnemonic:t.secretMnemonic,t.sdk.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return t.primarySeed=e.primarySeed,e.primaryPrivateKey})},y.prototype.unlockV2=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(e.primarySeed)r.primarySeed=e.primarySeed;else if(e.secret)try{if(r.primarySeed=new Buffer(f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(f.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");e.passphrase=e.passphrase||e.password;try{if(r.secret=f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedSecret),e.passphrase).toString(f.enc.Utf8),!r.secret.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(f.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},y.prototype.unlockV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){return i.when().then(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!e.primarySeed){if(e.secret)return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");return e.passphrase=e.passphrase||e.password,delete e.password,r.sdk.promisedDecrypt(new Buffer(e.encryptedSecret,"base64"),new Buffer(e.passphrase)).then(function(e){r.secret=e},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=e.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},y.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},y.prototype.upgradeToV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===y.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===y.WALLET_VERSION_V2?r._upgradeV2ToV3(e,n.notify.bind(n)):r.walletVersion===y.WALLET_VERSION_V1?r._upgradeV1ToV3(e,n.notify.bind(n)):void 0}).then(function(e){n.resolve(e)},function(e){n.reject(e)}),n.promise},y.prototype._upgradeV2ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),wallet_version:y.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=y.WALLET_VERSION_V3,r})})})},y.prototype._upgradeV1ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.recoveryEncryptedSecret=e.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),recovery_secret:e.recoverySecret.toString("hex"),wallet_version:y.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=y.WALLET_VERSION_V3,r})})})},y.prototype.doPasswordChange=function(e){var t=this;return i.when(null).then(function(){if(t.walletVersion===y.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(t.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!t.secret)throw new c.WalletLockedError("No secret");var r,n;if(t.walletVersion===y.WALLET_VERSION_V2)r=f.AES.encrypt(t.secret,e).toString(f.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof e)e=new Buffer(e);else if(!(e instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=u.encrypt(t.secret,e),n=h.encode(r),r=r.toString("base64")}return[r,n]})},y.prototype.passwordChange=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.fcall(function(){return r.doPasswordChange(e).then(function(e){var t=e[0],n=e[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:t}).then(function(){return r.encryptedSecret=t,{encryptedSecret:n}})}).then(function(e){n.resolve(e)},function(e){n.reject(e)})}),n.promise},y.prototype.getAddressByPath=function(e){return this.getWalletScriptByPath(e).address},y.prototype.getRedeemScriptByPath=function(e){return this.getWalletScriptByPath(e).redeemScript},y.prototype.getWalletScriptByPath=function(e){var t,r,n=this.getPrimaryPublicKey(e),i=this.getBlocktrailPublicKey(e),o=y.deriveByPath(this.backupPublicKey,e.replace("'",""),"M"),a=y.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),f=parseInt(e.split("/")[2]);"bitcoincash"!==this.network&&f===y.CHAIN_BTC_SEGWIT?(t=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(t))):(t=null,r=c);var u=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:t,redeemScript:r,scriptPubKey:u,address:s.address.fromOutputScript(u,this.network,this.useNewCashAddr)}},y.prototype.getPrimaryPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[t]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+t+") is unknown to us");this.primaryPublicKeys[t]=y.deriveByPath(this.primaryPrivateKey,"M/"+t+"'","m")}var r=this.primaryPublicKeys[t];return y.deriveByPath(r,e,"M/"+t+"'")},y.prototype.getBlocktrailPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[t])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+t+") is unknown to us");var r=this.blocktrailPublicKeys[t];return y.deriveByPath(r,e,"M/"+t+"'")},y.prototype.upgradeKeyIndex=function(e,t){var n=this,o=i.defer();if(o.promise.nodeify(t),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(e).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,e,[a.toBase58(),"M/"+e+"'"]).then(function(t){return n.keyIndex=e,r.forEach(t.blocktrail_public_keys,function(e,t){n.blocktrailPublicKeys[t]=s.HDNode.fromBase58(e[0],n.network)}),n.primaryPublicKeys[e]=a,!0})),o.promise},y.prototype.getNewAddress=function(e,t){var r=this;"function"==typeof e&&(t=e,e=null);var n=i.defer();if(n.promise.spreadNodeify(t),e!==parseInt(e,10)){if(void 0!==e&&null!==e)return n.reject(new Error("Invalid chain index")),n.promise;e=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+e).then(function(e){var t,n=e.path,i=e.address;try{t=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type&&(r.bypassNewAddressCheck=!1)}catch(t){throw new c.WalletAddressError("Failed to decode address ["+e.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(e.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type){var a;try{a=r.decodeAddress(o)}catch(e){throw new c.WalletAddressError("Error while verifying address from server ["+e.message+"]")}if(a.decoded.hash.toString("hex")!==t.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var f=a.decoded.version===s.script.types.P2PKH&&t.decoded.version===r.network.pubKeyHash,u=a.decoded.version===s.script.types.P2SH&&t.decoded.version===r.network.scriptHash;if(!f&&!u)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+e.address+"] !== ["+i+"]")}return[i,n]})),n.promise},y.prototype.getBalance=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier).then(function(e){return[e.confirmed,e.unconfirmed]})),t.promise},y.prototype.getInfo=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier)),t.promise},y.prototype.deleteWallet=function(e,t){"function"==typeof e&&(t=e,e=!1);var r=i.defer();if(r.promise.nodeify(t),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,e).then(function(e){return e.deleted})),r.promise},y.prototype.pay=function(e,t,r,n,o,s,a,f){var u=this;"function"==typeof t?(f=t,t=null):"function"==typeof r?(f=r,r=!1):"function"==typeof n?(f=n,n=!0):"function"==typeof o?(f=o,o=null):"function"==typeof s?(f=s,s=null):"function"==typeof a&&(f=a,a={}),n=void 0===n||n,o=o||y.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(f),u.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(y.PAY_PROGRESS_START),u.buildTransaction(e,t,r,n,o,a).then(function(e){return e},function(e){l.reject(e)},function(e){l.notify(e)}).spread(function(e,t){l.notify(y.PAY_PROGRESS_SEND);var r={signed_transaction:e.toHex(),base_transaction:e.__toBuffer(null,null,!1).toString("hex")};return u.sendTransaction(r,t.map(function(e){return e.path}),h,s,a.prioboost,a).then(function(e){if(l.notify(y.PAY_PROGRESS_DONE),e&&e.complete&&"false"!==e.complete)return e.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(e){throw e}).then(function(e){l.resolve(e)},function(e){l.reject(e)})}),l.promise)},y.prototype.decodeAddress=function(e){return y.getAddressAndType(e,this.network,this.useNewCashAddr)},y.getAddressAndType=function(e,t,r){var n,i,o;function a(r,s){var a=r(e,t);null===a[0]?(n=a[1],i=s):o=a[0]}if(t!==s.networks.bitcoin&&t!==s.networks.testnet&&t!==s.networks.regtest||a(b,"bech32"),!n&&"cashAddrPrefix"in t&&r&&a(v,"cashaddr"),n||a(g,"base58"),n)return{address:e,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},y.convertPayToOutputs=function(e,t,r){var n,i=[];if(Array.isArray(e))n=function(e,t,r){if("object"!=typeof t)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(t);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=t.scriptPubKey,r.value=t.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=t.address,r.value=t.value;else{if(2!==n.length||2!==t.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=t[0],r.value=t[1]}};else{if("object"!=typeof e)throw new Error("Invalid input");n=function(e,t,r){if(r.address=e.trim(),r.value=t,r.address===y.OP_RETURN){var n=Buffer.isBuffer(t)?t:new Buffer(t,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(e).forEach(function(o){var a={};if(n(o,e[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var f=y.getAddressAndType(a.address,t,r);a.scriptPubKey=s.address.toOutputScript(f.address,t,r).toString("hex"),delete a.address}catch(e){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+e.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},y.prototype.buildTransaction=function(e,t,n,a,f,u,h){var l=this;"function"==typeof t?(h=t,t=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof f?(h=f,f=null):"function"==typeof u&&(h=u,u={}),a=void 0===a||a,f=f||y.FEE_STRATEGY_OPTIMAL,u=u||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=y.convertPayToOutputs(e,l.network,l.useNewCashAddr)}catch(e){return d.reject(e),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(y.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,f,u).spread(function(e,n,u){var d,b,v=[],g=i.defer();return o.waterfall([function(t){var r=e.map(function(e){return e.value}).reduce(function(e,t){return e+t})-h.map(function(e){return e.value}).reduce(function(e,t){return e+t})-n;if(r>2*c.DUST&&r!==u)return t(new c.WalletFeeError("the amount of change ("+u+") suggested by the coin selection seems incorrect ("+r+")"));t()},function(e){b=new s.TransactionBuilder(l.network),l.bitcoinCash&&b.enableBitcoinCash(),e()},function(t){var r;for(r=0;r0)if(u<=c.DUST)u=0;else if(!t)return g.notify(y.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return e(r);t=n,e()});e()},function(e){if(u>0){var n={scriptPubKey:s.address.toOutputScript(t,l.network,l.useNewCashAddr),value:u};a?v.splice(r.random(0,v.length),0,n):v.push(n)}e()},function(e){v.forEach(function(e){b.addOutput(e.scriptPubKey,e.value)}),e()},function(t){var r,n,i,o,a;for(g.notify(y.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case y.FEE_STRATEGY_HIGH_PRIORITY:case y.FEE_STRATEGY_OPTIMAL:case y.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}t()}],function(t){t?g.reject(new c.WalletSendError(t)):g.resolve([d,e])}),g.promise}))}),d.promise},y.prototype.coinSelection=function(e,t,r,n,o,s){var a;"function"==typeof t?(s=t,t=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),t=void 0===t||t,n=n||y.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=y.convertPayToOutputs(e,this.network,this.useNewCashAddr)}catch(e){var c=i.defer();return c.promise.nodeify(s),c.reject(e),c.promise}return this.sdk.coinSelection(this.identifier,a,t,r,n,o,s)},y.prototype.sendTransaction=function(e,t,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var f=i.defer();return f.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,e,t,r,n,o,s).then(function(e){f.resolve(e)},function(e){e.requires_2fa?f.reject(new c.WalletMissing2FAError):e.message.match(/Invalid two_factor_token/)?f.reject(new c.WalletInvalid2FAError):f.reject(e)}),f.promise},y.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,t,e,r)},y.prototype.deleteWebhook=function(e,t){return"function"==typeof e&&(t=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,e,t)},y.prototype.transactions=function(e,t){return this.sdk.walletTransactions(this.identifier,e,t)},y.prototype.maxSpendable=function(e,t,r,n){return"function"==typeof e?(n=e,e=!1):"function"==typeof t?(n=t,t=null):"function"==typeof r&&(n=r,r={}),"object"==typeof e?(r=e,e=!1):"object"==typeof t&&(r=t,t=null),void 0!==(r=r||{}).allowZeroConf&&(e=r.allowZeroConf),void 0!==r.feeStrategy&&(t=r.feeStrategy),t=t||y.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,e,t,r,n)},y.prototype.addresses=function(e,t){return this.sdk.walletAddresses(this.identifier,e,t)},y.prototype.labelAddress=function(e,t,r){return this.sdk.labelWalletAddress(this.identifier,e,t,r)},y.prototype.utxos=function(e,t){return this.sdk.walletUTXOs(this.identifier,e,t)},y.prototype.unspentOutputs=y.prototype.utxos,y.sortMultiSigKeys=function(e){return e.sort(function(e,t){return e.toString("hex").localeCompare(t.toString("hex"))}),e},y.estimateIncompleteTxFee=function(e,t){var r=y.estimateIncompleteTxSize(e),n=r/1e3,i=Math.ceil(r/1e3);return t?parseInt(n*t,10):parseInt(i*c.BASE_FEE,10)},y.estimateVsizeFee=function(e,t,r){var n=l.estimateTxVsize(e,t),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},y.estimateIncompleteTxSize=function(e){var t=16;return t+=34*e.outs.length,e.ins.forEach(function(e){var r=e.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var f=s.script.decompile(a),u=f[0];if(u===s.opcodes.OP_0||us.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=f[a.chunks.length-2];if(u===s.opcodes.OP_0||us.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=u-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+e)+" using blocktrail key index: "+r+", chain: "+c),f.notify({message:"generating addresses "+p+" -> "+(p+e),increment:e,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,e,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+e+" addresses..."),f.notify({message:"starting fund discovery for "+e+" addresses",increment:e,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(u.keys(c)).then(function(l){return y=l,n.settings.logging&&console.log("batch "+(y?"has":"does not have")+" transactions..."),h.when(y).then(function(h){if(h)return n.utxoFinder.getUTXOs(u.keys(c)).then(function(h){if(t.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p=0;f--)if(u[f]!==h[f])return!1;for(f=u.length-1;f>=0;f--)if(c=u[f],!g(e[c],t[c],r,n))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function m(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&b(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!e&&o.isError(i),c=!e&&i&&!r;if((a&&s&&w(i,r)||c)&&b(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(y((t=this).actual),128)+" "+t.operator+" "+p(y(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=b,h.ok=v,h.equal=function(e,t,r){e!=t&&b(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&b(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){g(e,t,!1)||b(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){g(e,t,!0)||b(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){g(e,t,!1)&&b(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){g(t,r,!0)&&b(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&b(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&b(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var E=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":27}],25:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],26:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],27:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),u(n,e,n.depth)}function c(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function f(e,t){return e}function u(e,t,n){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return v(i)||(i=u(e,i,n)),i}var o=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(v(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),E(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(t);if(0===s.length){if(S(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(m(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(E(t))return h(t)}var f,w="",k=!1,A=["{","}"];(d(t)&&(k=!0,A=["[","]"]),S(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return m(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),E(t)&&(w=" "+h(t)),0!==s.length||k&&0!=t.length?n<0?m(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=k?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,w,A)):A[0]+w+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),x(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(r)?u(e,c.value,null):u(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function y(e){return null===e}function b(e){return"number"==typeof e}function v(e){return"string"==typeof e}function g(e){return void 0===e}function m(e){return w(e)&&"[object RegExp]"===k(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===k(e)}function E(e){return w(e)&&("[object Error]"===k(e)||e instanceof Error)}function S(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(g(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=y,r.isNullOrUndefined=function(e){return null==e},r.isNumber=b,r.isString=v,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=g,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:271,inherits:25}],28:[function(e,t,r){(function(e,r){!function(){var n,i,o={};function s(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(e){return"[object Array]"===a.call(e)},f=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=e.length&&r()}f(e,function(e){t(e,s(i))})},o.forEach=o.each,o.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r();var n=0,i=function(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1)>=e.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(e,t,r,n){l(t).apply(null,[e,r,n])},o.forEachLimit=o.eachLimit;var l=function(e){return function(t,r,n){if(n=n||function(){},!t.length||e<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=t.length)return n();for(;s=t.length?n():a())})}()}},d=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.each].concat(t))}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.eachSeries].concat(t))}},y=function(e,t,r,n){if(t=u(t,function(e,t){return{index:t,value:e}}),n){var i=[];e(t,function(e,t){r(e.value,function(r,n){i[e.index]=n,t(r)})},function(e){n(e,i)})}else e(t,function(e,t){r(e.value,function(e){t(e)})})};o.map=d(y),o.mapSeries=p(y),o.mapLimit=function(e,t,r,n){return b(t)(e,r,n)};var b=function(e){return function(e,t){return function(){var r=Array.prototype.slice.call(arguments);return t.apply(null,[l(e)].concat(r))}}(e,y)};o.reduce=function(e,t,r,n){o.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(e,t,r,n){var i=u(e,function(e){return e}).reverse();o.reduce(i,t,r,n)},o.foldr=o.reduceRight;var v=function(e,t,r,n){var i=[];e(t=u(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r&&i.push(e),t()})},function(e){n(u(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var g=function(e,t,r,n){var i=[];e(t=u(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r||i.push(e),t()})},function(e){n(u(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.reject=d(g),o.rejectSeries=p(g);var m=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(e){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(e){r(!1)})},o.any=o.some,o.every=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(e){r(!0)})},o.all=o.every,o.sortBy=function(e,t,r){o.map(e,function(e,r){t(e,function(t,n){t?r(t):r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,u(t.sort(function(e,t){var r=e.criteria,n=t.criteria;return rn?1:0}),function(e){return e.value}))})},o.auto=function(e,t){t=t||function(){};var r=h(e),n=r.length;if(!n)return t();var i={},s=[],a=function(e){s.unshift(e)},u=function(){n--,f(s.slice(0),function(e){e()})};a(function(){if(!n){var e=t;t=function(){},e(null,i)}}),f(r,function(r){var n=c(e[r])?e[r]:[e[r]],l=function(e){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),e){var s={};f(h(i),function(e){s[e]=i[e]}),s[r]=n,t(e,s),t=function(){}}else i[r]=n,o.setImmediate(u)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return t=function(e,t){return e&&i.hasOwnProperty(t)},n=!0,((e=d).reduce?e.reduce(t,n):(f(e,function(e,r,i){n=t(n,e,r,i)}),n))&&!i.hasOwnProperty(r);var e,t,n};if(p())n[n.length-1](l,i);else{var y=function(){p()&&(!function(e){for(var t=0;t>>1);r(t,e[o])>=0?n=o:i=o-1}return n}(e.tasks,s,r)+1,0,s),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),o.setImmediate(e.process)})}(n,e,t,i)},delete n.unshift,n},o.cargo=function(e,t){var r=!1,n=[],i={tasks:n,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,r){c(e)||(e=[e]),f(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof t?n.splice(0,t):n.splice(0,n.length),a=u(s,function(e){return e.data});i.empty&&i.empty(),r=!0,e(a,function(){r=!1;var e=arguments;f(s,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(e){return function(t){var r=Array.prototype.slice.call(arguments,1);t.apply(null,r.concat([function(t){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&f(r,function(t){console[e](t)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(e,t){var r={},n={};t=t||function(e){return e};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=t.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],e.apply(null,i.concat([function(){r[a]=arguments;var e=n[a];delete n[a];for(var t=0,i=e.length;t2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(e,t){!function r(n){if(n){if(t)return t(n);throw n}e(r)}()},void 0!==t&&t.exports?t.exports=o:void 0!==define&&define.amd?define([],function(){return o}):n.async=o}()}).call(this,e("_process"),e("timers").setImmediate)},{_process:271,timers:349}],29:[function(e,t,r){const Buffer=e("safe-buffer").Buffer;t.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);t.fill(255);for(let r=0;r>>0,f=new Uint8Array(c);for(;e[o];){let n=t[e.charCodeAt(o)];if(255===n)return;let i=0;for(let e=c-1;(0!==n||i>>0,f[e]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");a=i,o++}if(" "===e[o])return;let u=c-a;for(;u!==c&&0===f[u];)u++;const h=Buffer.allocUnsafe(s+(c-u));h.fill(0,0,s);let l=s;for(;u!==c;)h[l++]=f[u++];return h}return{encode:function(t){if(!Buffer.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";let i=0,s=0,a=0;const c=t.length;for(;a!==c&&0===t[a];)a++,i++;const f=(c-a)*o+1>>>0,u=new Uint8Array(f);for(;a!==c;){let e=t[a],n=0;for(let t=f-1;(0!==e||n>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");s=n,a++}let h=f-s;for(;h!==f&&0===u[h];)h++;let l=n.repeat(i);for(;h0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=e.indexOf("="))>0?e.length-s:0)>0?e.length-4:e.length,t=0,n=0;t>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(e[t])<<2|r.indexOf(e[t+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(e[t])<<10|r.indexOf(e[t+1])<<4|r.indexOf(e[t+2])>>2,a.push(o>>8&255),a.push(255&o)),a},t.exports.fromByteArray=function(e){var t,n,i,o,s=e.length%3,a="";for(t=0,i=e.length-s;t>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=e[e.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(e[e.length-2]<<8)+e[e.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(e,t,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function c(e){for(var t=1,r=0;r126)throw new Error("Invalid prefix ("+e+")");t=a(t)^n>>5}t=a(t);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+e);var o=e.slice(0,n),s=e.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var f=c(o),u=[],h=0;h=s.length||u.push(d)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:o,words:u}},encode:function(e,t){if(e.length+7+t.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(e=e.toLowerCase()),i=e+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var f=0;f<6;++f)r=a(r);r^=1;for(var u=0;u<6;++u){var h=r>>5*(5-u)&31;i+=n.charAt(h)}return i},toWords:function(e){return f(e,8,5,!0)},fromWords:function(e){return f(e,5,8,!1)}}},{}],32:[function(e,t,r){function BigInteger(e,t,r){if(!(this instanceof BigInteger))return new BigInteger(e,t,r);null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}var n=BigInteger.prototype;n.__bigi=e("../package.json").version,BigInteger.isBigInteger=function(e,t){return e&&e.__bigi&&(!t||e.__bigi===n.__bigi)},BigInteger.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function f(e){return a.charAt(e)}function u(e,t){var r=c[e.charCodeAt(t)];return null==r?-1:r}function h(e){var t=new BigInteger;return t.fromInt(e),t}function l(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function d(e){this.m=e}function p(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function E(e){return e}function S(e){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.convert=function(e){var t=new BigInteger;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},p.prototype.revert=function(e){var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},p.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},n.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+i:this.t=0},n.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&e[n]:u(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},n.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},n.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},n.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},n.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},n.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var f=o.t,u=o[f-1];if(0!=u){var h=u*(1<1?o[f-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),BigInteger.ONE.dlShiftTo(f,g),g.subTo(o,o);o.t=0;){var m=r[--b]==u?this.DM:Math.floor(r[b]*d+(r[b-1]+y)*p);if((r[b]+=o.am(0,m,r,v,0,f))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=t.convert(this),o=l(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},n.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=f(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=f(r));return i?o:"0"},n.negate=function(){var e=new BigInteger;return BigInteger.ZERO.subTo(this,e),e},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(e){var t=new BigInteger;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},n.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new p(t),this.exp(e,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},n.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),b,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},n.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},n.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},n.millerRabin=function(e){var t=this.subtract(BigInteger.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>k.length&&(e=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},n.equals=function(e){return 0==this.compareTo(e)},n.min=function(e){return this.compareTo(e)<0?this:e},n.max=function(e){return this.compareTo(e)>0?this:e},n.and=function(e){var t=new BigInteger;return this.bitwiseTo(e,y,t),t},n.or=function(e){var t=new BigInteger;return this.bitwiseTo(e,b,t),t},n.xor=function(e){var t=new BigInteger;return this.bitwiseTo(e,v,t),t},n.andNot=function(e){var t=new BigInteger;return this.bitwiseTo(e,g,t),t},n.not=function(){for(var e=new BigInteger,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var u=new BigInteger;for(n.sqrTo(s[1],u);a<=f;)s[a]=new BigInteger,n.mulTo(u,s[a-2],s[a]),a+=2}var y,b,v=e.t-1,g=!0,m=new BigInteger;for(i=l(e[v])-1;v>=0;){for(i>=c?y=e[v]>>i-c&f:(y=(e[v]&(1<0&&(y|=e[v-1]>>this.DB+i-c)),a=r;0==(1&y);)y>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),g)s[y].copyTo(o),g=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(b=o,o=m,m=b),n.mulTo(m,s[y],o)}for(;v>=0&&0==(e[v]&1<=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(e)>=0;)a.subTo(e,a);for(;a.signum()<0;)a.addTo(e,a);return a},n.pow=function(e){return this.exp(e,new _)},n.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(t=0;t-1});n(i,"Invalid mnemonic");var o=r.map(function(e){return p(t.indexOf(e).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),f=o.slice(s),u=c.match(/(.{1,8})/g).map(function(e){return parseInt(e,2)}),l=new Buffer(u),d=h(l);return n(d===f,"Invalid mnemonic checksum"),l.toString("hex")}function u(e,t){t=t||a;var r=new Buffer(e,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(e){var r=parseInt(e,2);return t[r]}).join(" ")}function h(e){var t=i("sha256").update(e).digest(),r=8*e.length/32;return d([].slice.call(t)).slice(0,r)}function l(e){return"mnemonic"+(s.nfkd(e)||"")}function d(e){return e.map(function(e){return p(e.toString(2),"0",8)}).join("")}function p(e,t,r){for(;e.length>>24]^b[a>>16&255]^v[c>>8&255]^g[255&t]^i[p],u=e[a>>>24]^b[c>>16&255]^v[t>>8&255]^g[255&o]^i[p+1],h=e[c>>>24]^b[t>>16&255]^v[o>>8&255]^g[255&a]^i[p+2],t=e[t>>>24]^b[o>>16&255]^v[a>>8&255]^g[255&c]^i[p+3],p+=4,o=f,a=u,c=h;for(l=0;4>l;l++)y[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[c>>8&255]<<8^m[255&t]^i[p++],f=o,o=a,a=c,c=t,t=f;return y}function c(e,t){var r,n=s.random.D[e],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;rt&&(e.i[t]=e.i[t]+1|0,!e.i[t]);t++);return e.F.encrypt(e.i)}function l(e,t){return function(){t.apply(e,arguments)}}void 0!==t&&t.exports&&(t.exports=s),"function"==typeof define&&define([],function(){return s}),s.cipher.aes=function(e){this.o[0][0][0]||this.t();var t,r,i,o,a=this.o[0][4],c=this.o[1],f=1;for(4!==(t=e.length)&&6!==t&&8!==t&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==e%t&&(r=r<<8^r>>>24^f<<24,f=f<<1^283*(f>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(e){return a(this,e,0)},decrypt:function(e){return a(this,e,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var e,t,r,n,i,o,s,a=this.o[0],c=this.o[1],f=a[4],u=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!f[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,f[t]=o,u[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},s.bitArray={bitSlice:function(e,t,r){return e=s.bitArray.R(e.slice(t/32),32-(31&t)).slice(1),r===i?e:s.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(s.bitArray.bitLength(e)!==s.bitArray.bitLength(t))return o;var r,n=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=s.bitArray.getPartial(o),n.push(s.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},s.codec.utf8String={fromBits:function(e){var t,r,n="",i=s.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],n=0;for(t=0;t>>i)>>>26),6>i?(a=e[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!t;)n+="=";return n},toBits:function(e,t){e=e.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,f=0;for(t&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(e.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),f=i<<32-a):f^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,f,1)),o}},s.codec.base64url={fromBits:function(e){return s.codec.base64.fromBits(e,1,1)},toBits:function(e){return s.codec.base64.toBits(e,1)}},s.hash.sha256=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha256.hash=function(e){return(new s.hash.sha256).update(e).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=512+t&-512;t<=e;t+=512)this.r(r.splice(0,16));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;t*t<=n;t++)if(0==n%t)continue e;8>r&&(this.l[r]=e(Math.pow(n,.5))),this.b[r]=e(Math.pow(n,1/3)),r++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?t=n[e]:(t=n[e+1&15],r=n[e+14&15],t=n[15&e]=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&e]+n[e+9&15]|0),t=t+d+(u>>>6^u>>>11^u>>>25^u<<26^u<<21^u<<7)+(l^u&(h^l))+o[e],d=l,l=h,h=u,u=f+t|0,f=c,c=a,s=t+((a=s)&c^f&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+f|0,i[4]=i[4]+u|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha512.hash=function(e){return(new s.hash.sha512).update(e).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=1024+t&-1024;t<=e;t+=1024)this.r(r.splice(0,32));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}var r,n=0,i=2;e:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue e;8>n&&(this.l[2*n]=e(Math.pow(i,.5)),this.l[2*n+1]=t(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=e(Math.pow(i,1/3)),this.b[2*n+1]=t(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7],p=i[8],y=i[9],b=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=f,I=u,x=h,T=l,B=d,C=p,P=y,O=b,M=v,R=g,L=m,j=w,D=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((H=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(e-7)],z=n[2*(e-16)],F=n[2*(e-16)+1];t=t+K+((r=N+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=H)>>>0>>0?1:0),t+=z+((r+=F)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;K=C&O^~C&R;var W=P&M^~P&L,q=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];N=(N=(N=(N=j+((P<<18|C>>>14)^(P<<14|C>>>18)^(C<<23|P>>>9))+((U=D+((C<<18|P>>>14)^(C<<14|P>>>18)^(P<<23|C>>>9)))>>>0>>0?1:0))+(K+((U=U+W)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+H+((r=F+q)>>>0>>0?1:0),j=R,D=L,R=O,L=M,O=C,M=P,C=T+N+((P=B+U|0)>>>0>>0?1:0)|0,T=I,B=x,I=k,x=A,k=E,A=S,E=N+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,f=i[3]=f+A|0,i[2]=c+k+(f>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=u+I+(h>>>0>>0?1:0)|0,d=i[7]=d+B|0,i[6]=l+T+(d>>>0>>0?1:0)|0,y=i[9]=y+P|0,i[8]=p+C+(y>>>0

>>0?1:0)|0,v=i[11]=v+M|0,i[10]=b+O+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+R+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(e){s.mode.ccm.w.push(e)},unListenProgress:function(e){-1<(e=s.mode.ccm.w.indexOf(e))&&s.mode.ccm.w.splice(e,1)},X:function(e){var t,r=s.mode.ccm.w.slice();for(t=0;tu&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-u&&(a=15-u),r=f.clamp(r,8*(15-a)),t=s.mode.ccm.O(e,t,r,i,o,a),c=s.mode.ccm.s(e,c,r,t,o,a),f.concat(c.data,c.tag)},decrypt:function(e,t,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,f=a.bitLength(t),u=a.clamp(t,f-o),h=a.bitSlice(t,f-o);f=(f-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),t=2;4>t&&f>>>8*t;t++);return t<15-c&&(t=15-c),r=a.clamp(r,8*(15-t)),u=s.mode.ccm.s(e,u,r,h,o,t),e=s.mode.ccm.O(e,u.data,r,i,o,t),a.equal(u.tag,e)||n(new s.exception.corrupt("ccm: tag doesn't match")),u.data},ga:function(e,t,r,n,i,o){var a=[],c=s.bitArray,f=c.j;if(n=[c.partial(8,(t.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=e.encrypt(n),t.length)for(65279>=(r=c.bitLength(t)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,t),t=0;to||16h&&(s.mode.ccm.X(a/f),h+=l),r[3]++,i=e.encrypt(r),t[a]^=i[0],t[a+1]^=i[1],t[a+2]^=i[2],t[a+3]^=i[3];return{tag:n,data:c.clamp(t,u)}}},s.mode.ocb2={name:"ocb2",encrypt:function(e,t,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,f=s.mode.ocb2.K,u=s.bitArray,h=u.j,l=[0,0,0,0];r=f(e.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),e.encrypt(o(n(o(c,n(c))),a))},K:function(e){return[e[0]<<1^e[1]>>>31,e[1]<<1^e[2]>>>31,e[2]<<1^e[3]>>>31,e[3]<<1^135*(e[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(e,t,r,n,i){var o=t.slice(0);return t=s.bitArray,n=n||[],e=s.mode.gcm.s(!0,e,o,n,r,i||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,a){var c=t.slice(0),f=s.bitArray,u=f.bitLength(c);return a=a||128,i=i||[],a<=u?(t=f.bitSlice(c,u-a),c=f.bitSlice(c,0,u-a)):(t=c,c=[]),e=s.mode.gcm.s(o,e,c,i,r,a),f.equal(e.tag,t)||n(new s.exception.corrupt("gcm: tag doesn't match")),e.data},ba:function(e,t){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=t.slice(0),r=0;128>r;r++){for((n=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(e,t,r){var n,i=r.length;for(t=t.slice(0),n=0;ni&&(e=t.hash(e)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),e=new(o=o||s.misc.hmac)(e);var a,c,f,u,h=[],l=s.bitArray;for(u=1;32*h.length<(i||1);u++){for(o=a=e.encrypt(l.concat(t,[u])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[u].update([o,this.H++,2,t,f,e.length].concat(e))}break;case"string":t===i&&(t=e.length),this.f[u].update([o,this.H++,3,t,f,e.length]),this.f[u].update(e);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[u]+=t,this.g+=t,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(e){return e=this.L[e!==i?e:this.G],this.n&&this.n>=e?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=e?this.C|this.p:this.p},getProgress:function(e){return e=this.L[e||this.G],this.n>=e?1:this.g>e?1:this.g/e},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(e,t){this.D[e][this.Y++]=t},removeEventListener:function(e,t){var r,n,i=this.D[e],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===t&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=t.iter||64!==t.ts&&96!==t.ts&&128!==t.ts||128!==t.ks&&192!==t.ks&&256!==t.ks||!t.iv||2>t.iv.length||472)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}}},{"safe-buffer":322}],41:[function(e,t,r){t.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(e,t,r){var n=e("./index.json"),i={};for(var o in n){i[n[o]]=o}t.exports=i},{"./index.json":41}],43:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bech32"),i=e("cashaddress"),o=e("bs58check"),s=e("./script"),a=e("./templates"),c=e("./networks"),f=e("typeforce"),u=e("./types");function h(e){var t=o.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function l(e){var t=n.decode(e),r=n.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:Buffer.from(r)}}function d(e){return i.decode(e)}function p(e,t){f(u.tuple(u.Hash160bit,u.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)}function y(e,t,r){var i=n.toWords(e);return i.unshift(t),n.encode(r,i)}function b(e,t,r){return i.encode(r,t,e)}t.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(e,t,r){if(t=t||c.bitcoin,r=r||!1,"cashAddrPrefix"in t&&r){if(s.pubKeyHash.output.check(e))return b(s.compile(e).slice(3,23),a.types.P2PKH,t.cashAddrPrefix);if(s.scriptHash.output.check(e))return b(s.compile(e).slice(2,22),a.types.P2SH,t.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(e))return p(s.compile(e).slice(3,23),t.pubKeyHash);if(s.scriptHash.output.check(e))return p(s.compile(e).slice(2,22),t.scriptHash)}if(s.witnessPubKeyHash.output.check(e))return y(s.compile(e).slice(2,22),0,t.bech32);if(s.witnessScriptHash.output.check(e))return y(s.compile(e).slice(2,34),0,t.bech32);throw new Error(s.toASM(e)+" has no matching Address")},toBase58Check:p,toBech32:y,toCashAddress:b,toOutputScript:function(e,t,r){var n;if("cashAddrPrefix"in(t=t||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}try{if("pubkeyhash"===(n=d(t.cashAddrPrefix+":"+e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}if(n&&n.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix")}try{if((n=h(e)).version===t.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===t.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(e){}if(!n&&"bech32"in t){try{n=l(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(e+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:127,cashaddress:134,"safe-buffer":322,typeforce:353}],44:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("merkle-lib/fastRoot"),s=e("typeforce"),a=e("./types"),c=e("varuint-bitcoin"),f=e("./transaction");function u(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}u.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var t=0;function r(r){return t+=r,e.slice(t-r,t)}function n(){var r=e.readUInt32LE(t);return t+=4,r}var i=new u;if(i.version=function(){var r=e.readInt32LE(t);return t+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===e.length)return i;function o(){var r=f.fromBuffer(e.slice(t),!0);return t+=r.byteLength(),r}var s,a=(s=c.decode(e,t),t+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&e,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-t),n},u.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},u.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=u.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},u.prototype.checkProofOfWork=function(){var e=n(this.getHash()),t=u.calculateTarget(this.bits);return e.compare(t)<=0},t.exports=u},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":129,"merkle-lib/fastRoot":264,"safe-buffer":322,typeforce:353,"varuint-bitcoin":361}],45:[function(e,t,r){var n=e("pushdata-bitcoin"),i=e("varuint-bitcoin");function o(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}t.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(e,t,r){return o(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},{"pushdata-bitcoin":298,"varuint-bitcoin":361}],46:[function(e,t,r){var n=e("create-hash");function i(e){return n("rmd160").update(e).digest()}function o(e){return n("sha256").update(e).digest()}t.exports={hash160:function(e){return i(o(e))},hash256:function(e){return o(o(e))},ripemd160:i,sha1:function(e){return n("sha1").update(e).digest()},sha256:o}},{"create-hash":139}],47:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("create-hmac"),i=e("typeforce"),o=e("./types"),BigInteger=e("bigi"),s=e("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),f=e("ecurve").getCurveByName("secp256k1");function u(e,t,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),u=Buffer.alloc(32,1);s=n("sha256",s).update(u).update(a).update(t).update(e).digest(),u=n("sha256",s).update(u).digest(),s=n("sha256",s).update(u).update(c).update(t).update(e).digest(),u=n("sha256",s).update(u).digest(),u=n("sha256",s).update(u).digest();for(var h=BigInteger.fromBuffer(u);h.signum()<=0||h.compareTo(f.n)>=0||!r(h);)s=n("sha256",s).update(u).update(a).digest(),u=n("sha256",s).update(u).digest(),u=n("sha256",s).update(u).digest(),h=BigInteger.fromBuffer(u);return h}var h=f.n.shiftRight(1);t.exports={deterministicGenerateK:u,sign:function(e,t){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=t.toBuffer(32),c=BigInteger.fromBuffer(e),l=f.n,d=f.G;return u(e,a,function(e){var i=d.multiply(e);return!f.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=e.modInverse(l).multiply(c.add(t.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(e,t,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=f.n,s=f.G,a=t.r,c=t.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var u=BigInteger.fromBuffer(e),h=c.modInverse(n),l=u.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!f.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:f}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":141,ecurve:218,"safe-buffer":322,typeforce:353}],48:[function(e,t,r){var n=e("./address"),i=e("./crypto"),o=e("./ecdsa"),s=e("randombytes"),a=e("typeforce"),c=e("./types"),f=e("wif"),u=e("./networks"),BigInteger=e("bigi"),h=e("ecurve"),l=o.__curve;function ECPair(e,t,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},e){if(e.signum()<=0)throw new Error("Private key must be greater than 0");if(e.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(c.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||u.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(e,t){var r=h.Point.decodeFrom(l,e);return new ECPair(null,r,{compressed:r.compressed,network:t})},ECPair.fromWIF=function(e,t){var r=f.decode(e),n=r.version;if(c.Array(t)){if(!(t=t.filter(function(e){return n===e.wif}).pop()))throw new Error("Unknown network version")}else if(t=t||u.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},ECPair.makeRandom=function(e){var t,r=(e=e||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),t=BigInteger.fromBuffer(n)}while(t.signum()<=0||t.compareTo(l.n)>=0);return new ECPair(t,null,e)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");return o.sign(e,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return f.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(e,t){return o.verify(e,t,this.Q)},t.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:218,randombytes:306,typeforce:353,wif:363}],49:[function(e,t,r){(function(Buffer){var r=e("bip66"),n=e("typeforce"),i=e("./types"),BigInteger=e("bigi");function o(e,t){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=e,this.s=t}o.parseCompact=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t!==(7&t))throw new Error("Invalid signature parameter");return{compressed:!!(4&t),i:3&t,signature:new o(BigInteger.fromBuffer(e.slice(1,33)),BigInteger.fromBuffer(e.slice(33)))}},o.fromDER=function(e){var t=r.decode(e);return new o(BigInteger.fromDERInteger(t.r),BigInteger.fromDERInteger(t.s))},o.parseScriptSignature=function(e){var t=e.readUInt8(e.length-1),r=-193&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);return{signature:o.fromDER(e.slice(0,-1)),hashType:t}},o.prototype.toCompact=function(e,t){t&&(e+=4),e+=27;var r=Buffer.alloc(65);return r.writeUInt8(e,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var e=Buffer.from(this.r.toDERInteger()),t=Buffer.from(this.s.toDERInteger());return r.encode(e,t)},o.prototype.toScriptSignature=function(e){var t=-193&e;if(t<=0||t>=4)throw new Error("Invalid hashType "+e);var r=Buffer.alloc(1);return r.writeUInt8(e,0),Buffer.concat([this.toDER(),r])},t.exports=o}).call(this,e("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:131,typeforce:353}],50:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bs58check"),i=e("./crypto"),o=e("create-hmac"),s=e("typeforce"),a=e("./types"),c=e("./networks"),BigInteger=e("bigi"),ECPair=e("./ecpair"),f=e("ecurve"),u=f.getCurveByName("secp256k1");function HDNode(e,t){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!e.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=e,this.chainCode=t,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(e,t){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:t}),i)},HDNode.fromSeedHex=function(e,t){return HDNode.fromSeedBuffer(Buffer.from(e,"hex"),t)},HDNode.fromBase58=function(e,t){var r=n.decode(e);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(t)){if(!(i=t.filter(function(e){return o===e.bip32.private||o===e.bip32.public}).pop()))throw new Error("Unknown network version")}else i=t||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var y=f.Point.decodeFrom(u,r.slice(45,78));u.validate(y),l=new ECPair(null,y,{network:i})}var b=new HDNode(l,d);return b.depth=s,b.index=h,b.parentFingerprint=a,b},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var e=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},HDNode.prototype.sign=function(e){return this.keyPair.sign(e)},HDNode.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},HDNode.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(e){s(a.UInt32,e);var t=e>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),f=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(u.n)>=0)return this.derive(e+1);if(this.isNeutered()){var l=u.G.multiply(h).add(this.keyPair.Q);if(u.isInfinity(l))return this.derive(e+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(u.n);if(0===d.signum())return this.derive(e+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,f);return p.depth=this.depth+1,p.index=e,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(e){return s(a.UInt31,e),this.derive(e+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(e){s(a.BIP32Path,e);var t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new Error("Not a master node");t=t.slice(1)}return t.reduce(function(e,t){var r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)},t.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:127,"create-hmac":141,ecurve:218,"safe-buffer":322,typeforce:353}],51:[function(e,t,r){t.exports={Block:e("./block"),ECPair:e("./ecpair"),ECSignature:e("./ecsignature"),HDNode:e("./hdnode"),Transaction:e("./transaction"),TransactionBuilder:e("./transaction_builder"),address:e("./address"),bufferutils:e("./bufferutils"),crypto:e("./crypto"),networks:e("./networks"),opcodes:e("bitcoin-ops"),script:e("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(e,t,r){t.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=e("pushdata-bitcoin"),o=e("typeforce"),s=e("./types"),a=e("./script_number"),c=e("bitcoin-ops"),f=e("bitcoin-ops/map"),u=c.OP_RESERVED;function h(e){return s.Buffer(e)||function(e){return s.Number(e)&&(e===c.OP_0||e>=c.OP_1&&e<=c.OP_16||e===c.OP_1NEGATE)}(e)}function l(e){return s.Array(e)&&e.every(h)}function d(e){return 0===e.length?c.OP_0:1===e.length?e[0]>=1&&e[0]<=16?u+e[0]:129===e[0]?c.OP_1NEGATE:void 0:void 0}function p(e){if(Buffer.isBuffer(e))return e;o(s.Array,e);var t=e.reduce(function(e,t){return Buffer.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+i.encodingLength(t.length)+t.length:e+1},0),r=Buffer.allocUnsafe(t),n=0;if(e.forEach(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,n),void(n+=1);n+=i.encode(r,e.length,n),e.copy(r,n),n+=e.length}else r.writeUInt8(e,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function y(e){if(s.Array(e))return e;o(s.Buffer,e);for(var t=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(e,r);if(null===a)return[];if((r+=a.size)+a.number>e.length)return[];var f=e.slice(r,r+a.number);r+=a.number;var u=d(f);void 0!==u?t.push(u):t.push(f)}else t.push(n),r+=1}return t}function b(e){var t=-193&e;return t>0&&t<4}t.exports={compile:p,decompile:y,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(e){return void 0!==c[e]?c[e]:(o(s.Hex,e),Buffer.from(e,"hex"))}))},toASM:function(e){return Buffer.isBuffer(e)&&(e=y(e)),e.map(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]}).join(" ")},toStack:function(e){return e=y(e),o(l,e),e.map(function(e){return Buffer.isBuffer(e)?e:e===c.OP_0?Buffer.allocUnsafe(0):a.encode(e-u)})},number:e("./script_number"),isCanonicalPubKey:function(e){if(!Buffer.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!Buffer.isBuffer(e)&&!!b(e[e.length-1])&&n.check(e.slice(0,-1))},isPushOnly:l,isDefinedHashType:b};var v=e("./templates");for(var g in v)t.exports[g]=v[g]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":298,"safe-buffer":322,typeforce:353}],54:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;t.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),n=Buffer.allocUnsafe(r),i=e<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":322}],55:[function(e,t,r){var n=e("../script").decompile,i=e("./multisig"),o=e("./nulldata"),s=e("./pubkey"),a=e("./pubkeyhash"),c=e("./scripthash"),f=e("./witnesspubkeyhash"),u=e("./witnessscripthash"),h=e("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};t.exports={classifyInput:function(e,t){var r=n(e);return a.input.check(r)?l.P2PKH:i.input.check(r,t)?l.MULTISIG:c.input.check(r,t)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(e){if(f.output.check(e))return l.P2WPKH;if(u.output.check(e))return l.P2WSH;if(a.output.check(e))return l.P2PKH;if(c.output.check(e))return l.P2SH;var t=n(e);return i.output.check(t)?l.MULTISIG:s.output.check(t)?l.P2PK:h.output.check(t)?l.WITNESS_COMMITMENT:o.output.check(t)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return f.input.check(r)?l.P2WPKH:u.input.check(r,t)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:f,witnessScriptHash:u,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(e,t,r){t.exports={input:e("./input"),output:e("./output")}},{"./input":57,"./output":58}],57:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){return e===o.OP_0||n.isCanonicalSignature(e)}function a(e,t){var r=n.decompile(e);return!(r.length<2)&&(r[0]===o.OP_0&&(t?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function f(e,t){if(i([s],e),t){var r=n.multisig.output.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,e.map(function(e){return e===o.OP_0?c:e}))}function u(e,t){return i(a,e,t),e.slice(1)}t.exports={check:a,decode:function(e,t){return u(n.decompile(e),t)},decodeStack:u,encode:function(e,t){return n.compile(f(e,t))},encodeStack:f}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":322,typeforce:353}],58:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=s.OP_RESERVED;function c(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},t.exports={check:c,decode:function(e,t){var r=n.decompile(e);return o(c,r,t),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(r1&&t[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},t.exports={output:{check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Buffer,e),n.compile([s.OP_RETURN,e])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:353}],60:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function s(e){return i(n.isCanonicalSignature,e),[e]}function a(e){return i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e){return n.compile(s(e))},encodeStack:s}},{"../../script":53,typeforce:353}],62:[function(e,t,r){var n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},t.exports={check:s,decode:function(e){var t=n.decompile(e);return i(s,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:353}],63:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function s(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function a(e){return i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e,t){return n.compile(s(e,t))},encodeStack:s}},{"../../script":53,typeforce:353}],65:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 25===t.length&&t[0]===s.OP_DUP&&t[1]===s.OP_HASH160&&20===t[2]&&t[23]===s.OP_EQUALVERIFY&&t[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_DUP,s.OP_HASH160,e,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],66:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce");function o(e,t){var r=n.decompile(e);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,t),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(e,t){var r=n.compile(t);return[].concat(e,r)}function a(e){return i(o,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}o.toJSON=function(){return"scriptHash input"},t.exports={check:o,decode:function(e){var t=a(n.decompile(e));return t.redeemScriptSig=n.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:a,encode:function(e,t){var r=n.decompile(e);return n.compile(s(r,t))},encodeStack:s}},{"../../script":53,"safe-buffer":322,typeforce:353}],68:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 23===t.length&&t[0]===s.OP_HASH160&&20===t[1]&&t[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_HASH160,e,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],69:[function(e,t,r){t.exports={output:e("./output")}},{"./output":70}],70:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(e){var t=n.compile(e);return t.length>37&&t[0]===s.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},t.exports={check:c,decode:function(e){return o(c,e),n.decompile(e)[1].slice(4,36)},encode:function(e){o(i.Hash256bit,e);var t=Buffer.allocUnsafe(36);return a.copy(t,0),e.copy(t,4),n.compile([s.OP_RETURN,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":322,typeforce:353}],71:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}s.toJSON=function(){return"witnessPubKeyHash input"},t.exports={check:s,decodeStack:function(e){return i(s,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},{"../../script":53,typeforce:353}],73:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 22===t.length&&t[0]===s.OP_0&&20===t[1]}a.toJSON=function(){return"Witness pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_0,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],74:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(e,t,r){var n=e("../scripthash/input");t.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 34===t.length&&t[0]===s.OP_0&&32===t[1]}a.toJSON=function(){return"Witness scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash256bit,e),n.compile([s.OP_0,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],77:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("./script"),s=e("./bufferutils"),a=e("bitcoin-ops"),c=e("typeforce"),f=e("./types"),u=e("varuint-bitcoin");function h(e){var t=e.length;return u.encodingLength(t)+t}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),g={script:d,valueBuffer:v};l.fromBuffer=function(e,t){var r=0;function n(t){return r+=t,e.slice(r-t,r)}function i(){var t=e.readUInt32LE(r);return r+=4,t}function o(){var t=s.readUInt64LE(e,r);return r+=8,t}function a(){var t=u.decode(e,r);return r+=u.decode.bytes,t}function c(){return n(a())}function f(){for(var e=a(),t=[],r=0;r=this.ins.length)return b;var n=o.compile(o.decompile(t).filter(function(e){return e!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(e>=this.outs.length)return b;s.outs.length=e+1;for(var u=0;u0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(f.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,o)}return this.hashForSignature(e,t,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(e,t){return this.__toBuffer(e,t,!0)},l.prototype.__toBuffer=function(e,t,r){e||(e=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=t||0;function o(t){i+=t.copy(e,i)}function a(t){i=e.writeUInt8(t,i)}function c(t){i=e.writeUInt32LE(t,i)}function f(t){u.encode(t,e,i),i+=u.encode.bytes}function h(e){f(e.length),o(e)}n=this.version,i=e.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),f(this.ins.length),this.ins.forEach(function(e){o(e.hash),c(e.index),h(e.script),c(e.sequence)}),f(this.outs.length),this.outs.forEach(function(t){var r;t.valueBuffer?o(t.valueBuffer):(r=t.value,i=s.writeUInt64LE(e,r,i)),h(t.script)}),d&&this.ins.forEach(function(e){var t;f((t=e.witness).length),t.forEach(h)}),c(this.locktime),void 0!==t?e.slice(t,i):e},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(e,t){c(f.tuple(f.Number,f.Buffer),arguments),this.ins[e].script=t},l.prototype.setWitness=function(e,t){c(f.tuple(f.Number,[f.Buffer]),arguments),this.ins[e].witness=t},t.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,typeforce:353,"varuint-bitcoin":361}],78:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./address"),o=e("./crypto"),s=e("./script"),a=e("./networks"),c=e("bitcoin-ops"),f=e("typeforce"),u=e("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=e("./ecpair"),p=e("./ecsignature"),y=e("./transaction");function b(e){return-1!==l.indexOf(e)}function v(e){return-1!==d.indexOf(e)}function g(e,t){if(0===e.length&&0===t.length)return{};var r,n,i,a,c,f,u,l,d,p,y=!1,g=!1,m=!1,w=s.decompile(e);s.classifyInput(w,!0)===h.P2SH&&(m=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(t,!0);if(_===h.P2WSH){if(f=t[t.length-1],u=s.classifyOutput(f),g=!0,y=!0,0===e.length){if(r=s.witnessScriptHash.output.encode(o.sha256(f)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(f)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!b(s.classifyOutput(f)))throw new Error("unsupported witness script");a=f,i=u,p=t.slice(0,-1)}else if(_===h.P2WPKH){y=!0;var E=t[t.length-1],S=o.hash160(E);if(0===e.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=t}else if(c){if(!v(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(e),p=w;var k=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=t.slice(1).map(function(e){return 0===e.length?void 0:e})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(y)};return m&&(A.redeemScript=c,A.redeemScriptType=l),g&&(A.witnessScript=f,A.witnessScriptType=u),A}function m(e,t,r){f(u.Buffer,e);var n=s.decompile(e);t||(t=s.classifyOutput(e));var i=[];switch(t){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:i,scriptType:t,signatures:i.map(function(){})}}function w(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(e,t,r,n,i){var a,c,l,d,p,y,b,v,g,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),b=o.sha256(i),w(e,p),!r.equals(s.witnessScriptHash.output.encode(b)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=y=a.scriptType,g=i}else if(r){if(w(e,p=o.hash160(r)),!(a=m(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,g=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,b=o.sha256(i)),!(a=m(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(b),E=S=!0,v=y=a.scriptType,g=i}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(c=e.prevOutType,l=e.prevOutScript,!(a=m(e.prevOutScript,e.prevOutType,t)).pubKeys)return;E=e.prevOutType===h.P2WPKH,v=c,g=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(t)),h.P2PKH,t),E=!1,v=c=h.P2PKH,g=l;if(void 0!==n||E){if(f(u.Satoshi,n),void 0!==e.value&&e.value!==n)throw new Error("Input didn't match witnessValue");e.value=n}v===h.P2WPKH&&(g=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(g))),_&&(e.redeemScript=r,e.redeemScriptType=d),S&&(e.witnessScript=i,e.witnessScriptType=y),e.pubKeys=a.pubKeys,e.signatures=a.signatures,e.signScript=g,e.signType=v,e.prevOutScript=l,e.prevOutType=c,e.witness=E}function E(e,t,r,n){if(e===h.P2PKH){if(1===t.length&&Buffer.isBuffer(t[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&Buffer.isBuffer(t[0]))return s.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map(function(e){return e||c.OP_0}),n||(t=t.filter(function(e){return e!==c.OP_0})),s.multisig.input.encodeStack(t)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(e,t){this.prevTxMap={},this.network=e||a.bitcoin,this.maximumFeeRate=t||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new y}function k(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&void 0!==e.witness}function A(e){return e.readUInt8(e.length-1)}S.prototype.enableBitcoinCash=function(e){void 0===e&&(e=!0),this.bitcoinCash=e},S.prototype.enableBitcoinGold=function(e){void 0===e&&(e=!0),this.bitcoinGold=e},S.prototype.setLockTime=function(e){if(f(u.UInt32,e),this.inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},S.prototype.setVersion=function(e){f(u.UInt32,e),this.tx.version=e},S.fromTransaction=function(e,t,r){var n=new S(t);return"number"==typeof r&&(r===y.FORKID_BTG?n.enableBitcoinGold(!0):r===y.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(e.version),n.setLockTime(e.locktime),e.outs.forEach(function(e){n.addOutput(e.script,e.value)}),e.ins.forEach(function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness,value:e.value})}),n.inputs.forEach(function(t,n){!function(e,t,r,n,i){if(e.signType===h.MULTISIG&&e.signScript&&e.pubKeys.length!==e.signatures.length){var o=e.signatures.concat();e.signatures=e.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,f){if(!s)return!1;var u,h=p.parseScriptSignature(s);switch(i){case y.FORKID_BCH:u=t.hashForCashSignature(r,e.signScript,n,h.hashType);break;case y.FORKID_BTG:u=t.hashForGoldSignature(r,e.signScript,n,h.hashType);break;default:u=e.witness?t.hashForWitnessV0(r,e.signScript,n,h.hashType):t.hashForSignature(r,e.signScript,h.hashType)}return!!c.verify(u,h.signature)&&(o[f]=void 0,a=s,!0)}),a})}}(t,e,n,t.value,r)}),n},S.prototype.addInput=function(e,t,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof e)e=n(Buffer.from(e,"hex"));else if(e instanceof y){var s=e.outs[t];i=s.script,o=s.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(e,t,r){if(y.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=g(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!e)throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];b(r)&&(n=E(r,e.signatures,e.pubKeys,t));var o=!1;if(r===s.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");b(e.redeemScriptType)&&(n=E(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(o=!0,r=e.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,e.signatures,e.pubKeys,t);break;case s.types.P2WSH:if(!t&&!b(e.witnessScriptType))throw new Error("Impossible to sign this type");b(e.witnessScriptType)&&((i=E(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return o&&n.push(e.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,e);if(!e&&!b(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},S.prototype.sign=function(e,t,r,n,i,o){if(t.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);n=n||y.SIGHASH_ALL;var s=this.inputs[e];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=t.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(e,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(e,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(e,s.signScript,i,n):this.tx.hashForSignature(e,s.signScript,n),!s.pubKeys.some(function(e,r){if(!c.equals(e))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!t.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=t.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(e){return void 0===e.signatures||e.signatures.every(function(e){return!e||A(e)&y.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===y.SIGHASH_NONE||(n===y.SIGHASH_SINGLE?e<=t:void 0)})})},S.prototype.__overMaximumFees=function(e){return(this.inputs.reduce(function(e,t){return e+(t.value>>>0)},0)-this.tx.outs.reduce(function(e,t){return e+t.value},0))/e>this.maximumFeeRate},t.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,typeforce:353}],79:[function(e,t,r){var n=e("typeforce"),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),f=n.compile({r:a,s:a}),u=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:f,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:u,Satoshi:function(e){return n.UInt53(e)&&e<=s},UInt31:function(e){return n.UInt32(e)&&e<=i}};for(var l in n)h[l]=n[l];t.exports=h},{typeforce:353}],80:[function(e,t,r){(function(Buffer){var r=e("bs58check"),n=e("buffer-equals"),i=e("create-hash"),o=e("secp256k1"),s=e("varuint-bitcoin");function a(e,t){var r=s.encodingLength(e.length),n=new Buffer(t.length+r+e.length);return n.write(t,0),s.encode(e.length,n,t.length),n.write(e,t.length+r),function(e){var t=i("sha256").update(e).digest();return i("sha256").update(t).digest()}(n)}t.exports={magicHash:a,sign:function(e,t,r,n){var i=a(e,t),s=o.sign(i,r);return function(e,t,r){return r&&(t+=4),Buffer.concat([new Buffer([t+27]),e])}(s.signature,s.recovery,n)},verify:function(e,t,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var f,u,h=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&t),recovery:3&t,signature:e.slice(1)}}(c),l=a(e,t),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(f=d,u=i("sha256").update(f).digest(),i("ripemd160").update(u).digest()),y=r.decode(s).slice(1);return n(p,y)}}}).call(this,e("buffer").Buffer)},{bs58check:83,buffer:131,"buffer-equals":128,"create-hash":139,secp256k1:323,"varuint-bitcoin":361}],81:[function(e,t,r){t.exports=function(e){for(var t={},r=e.length,n=e.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var f=0;e[f]===n&&f0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===t[c]&&c=0;--f)a+=e[n[f]];return a},decodeUnsafe:o,decode:function(e){var t=o(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(e,t,r){var n=e("base-x");t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(e,t,r){(function(Buffer){"use strict";var r=e("bs58"),n=e("create-hash");function i(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}function o(e){var t=e.slice(0,-4),r=e.slice(-4),n=i(t);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return t}function s(e){var t=r.decodeUnsafe(e);if(t)return o(new Buffer(t))}t.exports={encode:function(e){var t=i(e);return r.encode(Buffer.concat([e,t],e.length+4))},decode:function(e){var t=r.decode(e),n=o(new Buffer(t));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this,e("buffer").Buffer)},{bs58:82,buffer:131,"create-hash":139}],84:[function(e,t,r){(function(r){var n=e("async"),i=e("lodash"),o=e("fs"),s=e("./branding-logo"),a=e("./qrCode-browser"),c=e("./pdf_writer"),f=e("bowser"),u=function(e,t,r,n){var o=this;t=t||{},r=r||{},n=n||{},o.identifier=e,o.backupInfo=t,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],t.blocktrailPublicKeys&&i.each(t.blocktrailPublicKeys,function(e,t){o.blocktrailPublicKeys.push({keyIndex:t,pubKey:e,path:"M/"+t+"'"})})};u.saveAsSupported=function(){if(f.browser.ios||f.browser.blackberry||f.browser.firefoxos||f.browser.webos||f.browser.bada||f.browser.tizen||f.browser.sailfish)return!1;if(f.browser.android){if(!f.browser.chrome)return!1;if(f.browser.version.split(".")[0]<41)return!1;if(f.browser.osversion.split(".")[0]<=4)return!1}return!0},u.prototype.generateHTML=function(e){var t=this,s={identifier:t.identifier,backupInfo:t.backupInfo,totalPubKeys:t.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(t.extraInfo,function(e,t){return"string"!=typeof e?e:{title:t,value:e}}),options:t.options};n.forEach(Object.keys(t.blocktrailPublicKeys),function(e,r){var n=t.blocktrailPublicKeys[e];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(e,t){n.qr=t,r(e)})},function(n){if(n)return e(n);var a;i.each(t.blocktrailPublicKeys,function(e){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+e.keyIndex+" ",s.pubKeysHtml+="Path: "+e.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(t){return e(t)}e(null,a(s))})},u.prototype.generatePDF=function(e){var t=this,r=new c,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(e){t.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(t.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+t.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(t.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),t.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.primaryMnemonic)})}),t.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.backupMnemonic)})}),t.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.encryptedPrimarySeed)})}),t.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.backupSeed)})}),t.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(t.blocktrailPublicKeys),function(e,r){var n=t.blocktrailPublicKeys[e];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(e,t){n.qr=t,r(e)})},function(n){if(n)return e(n);Object.keys(t.blocktrailPublicKeys).forEach(function(e,n){var i=t.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),t.extraInfo&&i.each(t.extraInfo,function(e,t){var n,i;"string"!=typeof e?(n=e.title,i=e.subtitle,e=e.value):n=t,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(e)})})}),e()})):e()},function(e){t.backupInfo.encryptedSecret&&t.options.page2&&(t.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.encryptedSecret)})})),e()},function(e){t.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),e()}],function(t){if(t)return e(t);e(null,r.doc)})}catch(t){return void e(t)}},t.exports=u}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:238,lodash:89}],85:[function(e,t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(e,t,r){var n=function(e){var t=jsPDF;if(void 0===t)throw new Error("jsPDF not found");e=e||{},this.doc=new t("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==e.margin?e.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(e,t){this.font.push(e),this.doc.setFont(this.font[this.font.length-1]),t&&t(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(e,t,r){this.fontSize.push(e),this.lineMargin.push(t),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(e,t){this.textColor.push(e),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),t&&t(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(e,t,r,n){var i=this;"function"==typeof t?(n=t,t=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(e,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(e){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(e,i.margin+(t||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(t||0),i.yPos);n&&n()},n.prototype.HR=function(e,t){var r=e||0,n=this.docWidth-this.margin-this.margin-(e||0),i=t||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(e,t,r,n){this.doc.line(e+this.margin,t+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(e,t,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(e,t,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(e){this.yPos+=e||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(e){this.setFontSize(24,[12,8],e)},n.prototype.FONT_SIZE_SUBHEADER=function(e){this.setFontSize(18,[8,5],e)},n.prototype.FONT_SIZE_NORMAL=function(e){this.setFontSize(13,[2,2],e)},n.prototype.FONT_SIZE_SMALL=function(e){this.setFontSize(10,[2,2],e)},n.prototype.TEXT_COLOR_BLACK=function(e){this.setTextColor([0,0,0],e)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(e){this.setTextColor([150,150,150],e)},n.prototype.TEXT_COLOR_GREY=function(e){this.setTextColor([51,51,51],e)},n.prototype.TEXT_COLOR_RED=function(e){this.setTextColor([255,0,0],e)},t.exports=n},{}],87:[function(e,t,r){var n=e("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(e,t,r){this.init(),this.qrcodedraw.draw(this.canvasEl,e,t,r)},i.prototype.toDataURL=function(e,t,r){this.draw(e,t,function(e,t){if(e)return r?r(e):null;r(null,t.toDataURL("image/jpeg"))})},t.exports=new i},{"qrcode-canvas":301}],88:[function(e,t,r){t.exports=e("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(e,t,r){(function(e){(function(){var n,i,o,s="3.1.0",a=1,c=2,f=4,u=8,h=16,l=32,d=64,p=128,y=256,b=30,v="...",g=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",I="[object Array]",x="[object Boolean]",T="[object Date]",B="[object Error]",C="[object Function]",P="[object Number]",O="[object Object]",M="[object RegExp]",R="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",W="[object Uint32Array]",q=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,J=RegExp(Y.source),Z=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,ee=/<%=([\s\S]+?)%>/g,te=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ne=/^\s*function[ \n\r\t]+\w/,ie=/^0[xX]/,oe=/^\[object .+?Constructor\]$/,se=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ae=/($^)/,ce=/[.*+?^${}()|[\]\/\\]/g,fe=RegExp(ce.source),ue=/\bthis\b/,he=/['\n\r\u2028\u2029\\]/g,le=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),de=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pe=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],ye=-1,be={};be[j]=be[D]=be[N]=be[U]=be[H]=be[K]=be[z]=be[F]=be[W]=!0,be[A]=be[I]=be[L]=be[x]=be[T]=be[B]=be[C]=be["[object Map]"]=be[P]=be[O]=be[M]=be["[object Set]"]=be[R]=be["[object WeakMap]"]=!1;var ve={};ve[A]=ve[I]=ve[L]=ve[x]=ve[T]=ve[j]=ve[D]=ve[N]=ve[U]=ve[H]=ve[P]=ve[O]=ve[M]=ve[R]=ve[K]=ve[z]=ve[F]=ve[W]=!0,ve[B]=ve[C]=ve["[object Map]"]=ve["[object Set]"]=ve["[object WeakMap]"]=!1;var ge={leading:!1,maxWait:0,trailing:!1},me={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},we={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_e={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ee={function:!0,object:!0},Se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ke=Ee[typeof window]&&window!==(this&&this.window)?window:this,Ae=Ee[typeof r]&&r&&!r.nodeType&&r,Ie=Ee[typeof t]&&t&&!t.nodeType&&t,xe=Ae&&Ie&&"object"==typeof e&&e;!xe||xe.global!==xe&&xe.window!==xe&&xe.self!==xe||(ke=xe);var Te=Ie&&Ie.exports===Ae&&Ae;function Be(e,t){if(e!==t){var r=e==e,n=t==t;if(e>t||!r||void 0===e&&n)return 1;if(e-1;);return r}function Le(e,t){for(var r=e.length;r--&&t.indexOf(e.charAt(r))>-1;);return r}function je(e,t){return Be(e.criteria,t.criteria)||e.index-t.index}function De(e,t){for(var r=-1,n=e.criteria,i=t.criteria,o=n.length;++r=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function We(e,t){for(var r=-1,n=e.length,i=-1,o=[];++r>>1,Pt=yt?yt.BYTES_PER_ELEMENT:0,Ot=we.pow(2,53)-1,Mt=pt&&new pt;function Rt(e){if(ze(e)&&!Wn(e)){if(e instanceof Lt)return e;if(Ze.call(e,"__wrapped__"))return new Lt(e.__wrapped__,e.__chain__,Kt(e.__actions__))}return new Lt(e)}function Lt(e,t,r){this.__actions__=r||[],this.__chain__=!!t,this.__wrapped__=e}var jt=Rt.support={};function Dt(e){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=xt,this.views=null,this.wrapped=e}function Nt(){this.__data__={}}function Ut(e){var t=e?e.length:0;for(this.data={hash:vt(null),set:new ut};t--;)this.push(e[t])}function Ht(e,t){var r=e.data;return("string"==typeof t||Xn(t)?r.set.has(t):r.hash[t])?0:-1}function Kt(e,t){var n=-1,i=e.length;for(t||(t=r(i));++nn&&(n=i)}return n}function Gt(e,t,r,n){var i=-1,o=e.length;for(n&&o&&(r=e[++i]);++i=200&&Ur(t),c=t.length;a&&(o=Ht,s=!1,t=a);e:for(;++if))return!1;for(;h&&++co?0:o+t),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),c=[];a?(n=Ht,o=!1):(s=!1,a=t?[]:c);e:for(;++r>>1,s=e[o];(r?s<=t:s3&&Jr(arguments[1],arguments[2],arguments[3])&&(t=2),t>3&&"function"==typeof arguments[t-2])var n=Mr(arguments[--t-1],arguments[t--],5);else t>2&&"function"==typeof arguments[t-1]&&(n=arguments[--t]);for(var i=0;++ii)||c===n&&c===o)&&(i=c,o=e)}),o}(r,n,t)}}function Fr(e,t,i,o,s,p,b,v,g,m){var w=t&y,_=t&a,E=t&c,S=t&u,k=t&f,A=t&h,I=!E&&Kr(e),x=e;return function f(){for(var u=arguments.length,h=u,y=r(u);h--;)y[h]=arguments[h];if(o&&(y=Lr(y,o,s)),p&&(y=jr(y,p,b)),S||A){var T=f.placeholder,B=We(y,T);if((u-=B.length)=(t=+t)||!gt(t))return"";var i=t-n;return pi(r=null==r?" ":r+"",it(i/r.length)).slice(0,i)}function qr(e,t,n,i,o,s,u,b){var v=t&c;if(!v&&!Yn(e))throw new Ie(S);var g=i?i.length:0;if(g||(t&=~(l|d),i=o=null),g-=o?o.length:0,t&d){var m=i,w=o;i=o=null}var _=!v&&Gr(e),E=[e,t,n,i,o,m,w,s,u,b];if(_&&!0!==_&&(function(e,t){var r=e[1],n=t[1],i=r|n,o=y|p,s=a|c,u=o|s|f|h,l=r&y&&!(n&y),d=r&p&&!(n&p),b=(d?e:t)[7],v=(l?e:t)[8],g=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=u&&(r-1&&e%1==0&&e-1&&e%1==0&&e<=Ot}function Qr(e){return e==e&&(0===e?1/e>0:!Xn(e))}function $r(e,t){e=cn(e);for(var r=-1,n=t.length,i={};++r0){if(++tn>=g)return e}else tn=0;return Ar(e,t)});function on(e){var t,r;return Rt.support,!(!ze(e)||$e.call(e)!=O||!(Ze.call(e,"constructor")||"function"!=typeof(t=e.constructor)||t instanceof t))&&(pr(e,function(e,t){r=t}),void 0===r||Ze.call(e,r))}function sn(e){for(var t=si(e),r=t.length,n=r&&e.length,i=Rt.support,o=n&&Zr(n)&&(Wn(e)||i.nonEnumArgs&&Fn(e)),s=-1,a=[];++s>>0,i=r(n);++t-1:Yr(e,t,r)>-1)}var _n=Dr(function(e,t,r){Ze.call(e,r)?++e[r]:e[r]=1});function En(e,t,r){var n=Wn(e)?Ft:cr;return"function"==typeof t&&void 0===r||(t=Vr(t,r,3)),n(e,t)}function Sn(e,t,r){return(Wn(e)?Wt:fr)(e,t=Vr(t,r,3))}function kn(e,t,r){if(Wn(e)){var i=hn(e,t,r);return i>-1?e[i]:n}return ur(e,t=Vr(t,r,3),sr)}function An(e,t,r){return"function"==typeof t&&void 0===r&&Wn(e)?zt(e,t):sr(e,Mr(t,r,3))}function In(e,t,r){return"function"==typeof t&&void 0===r&&Wn(e)?function(e,t){for(var r=e.length;r--&&!1!==t(e[r],r,e););return e}(e,t):ar(e,Mr(t,r,3))}var xn=Dr(function(e,t,r){Ze.call(e,r)?e[r].push(t):e[r]=[t]}),Tn=Dr(function(e,t,r){e[r]=t});function Bn(e,t,r){return(Wn(e)?qt:wr)(e,t=Vr(t,r,3))}var Cn=zr(Vt),Pn=zr(function(e){for(var t=-1,r=e.length,n=xt;++t0?e[Sr(0,i-1)]:n}var o=jn(e);return o.length=_t(t<0?0:+t||0,o.length),o}function jn(e){for(var t=-1,n=(e=an(e)).length,i=r(n);++t0?r=t.apply(this,arguments):t=null,r}}function Hn(e,t,r){var i,o,s,a,c,f,u,h=0,l=!1,d=!0;if(!Yn(e))throw new Ie(S);if(t=t<0?0:t,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&wt(+r.maxWait||0,t),d="trailing"in r?r.trailing:d);function y(){var r=t-(Nn()-a);if(r<=0||r>t){o&&ot(o);var l=u;o=f=u=n,l&&(h=Nn(),s=e.apply(c,i),f||o||(i=c=null))}else f=ht(y,r)}function b(){f&&ot(f),o=f=u=n,(d||l!==t)&&(h=Nn(),s=e.apply(c,i),f||o||(i=c=null))}function v(){if(i=arguments,a=Nn(),c=this,u=d&&(f||!p),!1===l)var r=p&&!f;else{o||p||(h=a);var n=l-(a-h),v=n<=0||n>l;v?(o&&(o=ot(o)),h=a,s=e.apply(c,i)):o||(o=ht(b,n))}return v&&f?f=ot(f):f||t===l||(f=ht(y,t)),r&&(v=!0,s=e.apply(c,i)),!v||f||o||(i=c=null),s}return v.cancel=function(){f&&ot(f),o&&ot(o),o=f=u=n},v}function Kn(){var e=arguments,t=e.length-1;if(t<0)return function(){};if(!Ft(e,Yn))throw new Ie(S);return function(){for(var r=t,n=e[r].apply(this,arguments);r--;)n=e[r].call(this,n);return n}}function zn(e,t){if(!Yn(e)||t&&!Yn(t))throw new Ie(S);var r=function(){var n=r.cache,i=t?t.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=e.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function Fn(e){return Zr(ze(e)?e.length:n)&&$e.call(e)==A||!1}var Wn=bt||function(e){return ze(e)&&Zr(e.length)&&$e.call(e)==I||!1};function qn(e){return e&&1===e.nodeType&&ze(e)&&$e.call(e).indexOf("Element")>-1||!1}function Vn(e){return ze(e)&&"string"==typeof e.message&&$e.call(e)==B||!1}jt.dom||(qn=function(e){return e&&1===e.nodeType&&ze(e)&&!Qn(e)||!1});var Gn=St||function(e){return"number"==typeof e&>(e)};function Yn(e){return"function"==typeof e||!1}function Xn(e){var t=typeof e;return"function"==t||e&&"object"==t||!1}function Jn(e){return null!=e&&($e.call(e)==C?tt.test(Xe.call(e)):ze(e)&&oe.test(e)||!1)}function Zn(e){return"number"==typeof e||ze(e)&&$e.call(e)==P||!1}(Yn(/x/)||dt&&!Yn(dt))&&(Yn=function(e){return $e.call(e)==C});var Qn=at?function(e){if(!e||$e.call(e)!=O)return!1;var t=e.valueOf,r=Jn(t)&&(r=at(t))&&at(r);return r?e==r||at(e)==r:on(e)}:on;function $n(e){return ze(e)&&$e.call(e)==M||!1}function ei(e){return"string"==typeof e||ze(e)&&$e.call(e)==R||!1}function ti(e){return ze(e)&&Zr(e.length)&&be[$e.call(e)]||!1}function ri(e){return er(e,si(e))}var ni=Nr(Qt);function ii(e){return vr(e,si(e))}var oi=mt?function(e){if(e)var t=e.constructor,r=e.length;return"function"==typeof t&&t.prototype===e||"function"!=typeof e&&r&&Zr(r)?sn(e):Xn(e)?mt(e):[]}:sn;function si(e){if(null==e)return[];Xn(e)||(e=Ee(e));var t=e.length;t=t&&Zr(t)&&(Wn(e)||jt.nonEnumArgs&&Fn(e))&&t||0;for(var n=e.constructor,i=-1,o="function"==typeof n&&n.prototype==e,s=r(t),a=t>0;++i2){var i=Ir(arguments,2),o=We(i,e.placeholder);n|=l}return qr(t,n,r,i,o)},Rt.bindAll=function(e){return function(e,t){for(var r=-1,n=t.length;++r1?hr(arguments,!1,!1,1):ii(e))},Rt.bindKey=function e(t,r){var n=a|c;if(arguments.length>2){var i=Ir(arguments,2),o=We(i,e.placeholder);n|=l}return qr(r,n,t,i,o)},Rt.callback=_i,Rt.chain=gn,Rt.chunk=function(e,t,n){t=(n?Jr(e,t,n):null==t)?1:wt(+t||1,1);for(var i=0,o=e?e.length:0,s=-1,a=r(it(o/t));i=120&&Ur(t&&s)))}r=e.length;var a=e[0],c=-1,f=a?a.length:0,u=[],h=n[0];e:for(;++c-1;)lt.call(e,i,1);return e},Rt.pullAt=function(e){return function(e,t){var r=t.length,n=$t(e,t);for(t.sort(Be);r--;){var i=parseFloat(t[r]);if(i!=o&&Xr(i)){var o=i;lt.call(e,i,1)}}return n}(e||[],hr(arguments,!1,!1,1))},Rt.range=function(e,t,n){n&&Jr(e,t,n)&&(t=n=null),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var i=-1,o=wt(it((t-e)/(n||1)),0),s=r(o);++i3&&Jr(t[1],t[2],t[3])&&(t=[e,t[1]]);var i=-1,o=e?e.length:0,s=hr(t,!1,!1,1),a=Zr(o)?r(o):[];return sr(e,function(e,t,o){for(var c=s.length,f=r(c);c--;)f[c]=null==e?n:e[s[c]];a[++i]={criteria:f,index:i,value:e}}),Pe(a,De)},Rt.take=function(e,t,r){return e&&e.length?((r?Jr(e,t,r):null==t)&&(t=1),Ir(e,0,t<0?0:t)):[]},Rt.takeRight=function(e,t,r){var n=e?e.length:0;return n?((r?Jr(e,t,r):null==t)&&(t=1),Ir(e,(t=n-(+t||0))<0?0:t)):[]},Rt.takeRightWhile=function(e,t,r){var n=e?e.length:0;if(!n)return[];for(t=Vr(t,r,3);n--&&t(e[n],n,e););return Ir(e,n+1)},Rt.takeWhile=function(e,t,r){var n=e?e.length:0;if(!n)return[];var i=-1;for(t=Vr(t,r,3);++i=0&&e.indexOf(t,r)==r},Rt.escape=function(e){return(e=Oe(e))&&Z.test(e)?e.replace(X,Ue):e},Rt.escapeRegExp=hi,Rt.every=En,Rt.find=kn,Rt.findIndex=hn,Rt.findKey=function(e,t,r){return ur(e,t=Vr(t,r,3),yr,!0)},Rt.findLast=function(e,t,r){return ur(e,t=Vr(t,r,3),ar)},Rt.findLastIndex=function(e,t,r){var n=e?e.length:0;for(t=Vr(t,r,3);n--;)if(t(e[n],n,e))return n;return-1},Rt.findLastKey=function(e,t,r){return ur(e,t=Vr(t,r,3),br,!0)},Rt.findWhere=function(e,t){return kn(e,_r(t))},Rt.first=ln,Rt.has=function(e,t){return!!e&&Ze.call(e,t)},Rt.identity=Si,Rt.includes=wn,Rt.indexOf=dn,Rt.isArguments=Fn,Rt.isArray=Wn,Rt.isBoolean=function(e){return!0===e||!1===e||ze(e)&&$e.call(e)==x||!1},Rt.isDate=function(e){return ze(e)&&$e.call(e)==T||!1},Rt.isElement=qn,Rt.isEmpty=function(e){if(null==e)return!0;var t=e.length;return Zr(t)&&(Wn(e)||ei(e)||Fn(e)||ze(e)&&Yn(e.splice))?!t:!oi(e).length},Rt.isEqual=function(e,t,r,i){if(!(r="function"==typeof r&&Mr(r,i,3))&&Qr(e)&&Qr(t))return e===t;var o=r?r(e,t):n;return void 0===o?gr(e,t,r):!!o},Rt.isError=Vn,Rt.isFinite=Gn,Rt.isFunction=Yn,Rt.isMatch=function(e,t,n,i){var o=oi(t),s=o.length;if(!(n="function"==typeof n&&Mr(n,i,3))&&1==s){var a=o[0],c=t[a];if(Qr(c))return null!=e&&c===e[a]&&Ze.call(e,a)}for(var f=r(s),u=r(s);s--;)c=f[s]=t[o[s]],u[s]=Qr(c);return mr(e,o,f,u,n)},Rt.isNaN=function(e){return Zn(e)&&e!=+e},Rt.isNative=Jn,Rt.isNull=function(e){return null===e},Rt.isNumber=Zn,Rt.isObject=Xn,Rt.isPlainObject=Qn,Rt.isRegExp=$n,Rt.isString=ei,Rt.isTypedArray=ti,Rt.isUndefined=function(e){return void 0===e},Rt.kebabCase=li,Rt.last=function(e){var t=e?e.length:0;return t?e[t-1]:n},Rt.lastIndexOf=function(e,t,r){var n=e?e.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?wt(n+r,0):_t(r||0,n-1))+1;else if(r){var o=e[i=Pr(e,t,!0)-1];return(t==t?t===o:o!=o)?i:-1}if(t!=t)return Ke(e,i,!0);for(;i--;)if(e[i]===t)return i;return-1},Rt.max=Cn,Rt.min=Pn,Rt.noConflict=function(){return t._=et,this},Rt.noop=Ii,Rt.now=Nn,Rt.pad=function(e,t,r){t=+t;var n=(e=Oe(e)).length;if(n>=t||!gt(t))return e;var i=(t-n)/2,o=st(i);return(r=Wr("",it(i),r)).slice(0,o)+e+r},Rt.padLeft=function(e,t,r){return(e=Oe(e))&&Wr(e,t,r)+e},Rt.padRight=function(e,t,r){return(e=Oe(e))&&e+Wr(e,t,r)},Rt.parseInt=di,Rt.random=function(e,t,r){r&&Jr(e,t,r)&&(t=r=null);var n=null==e,i=null==t;if(null==r&&(i&&"boolean"==typeof e?(r=e,e=1):"boolean"==typeof t&&(r=t,i=!0)),n&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,r||e%1||t%1){var o=At();return _t(e+o*(t-e+parseFloat("1e-"+((o+"").length-1))),t)}return Sr(e,t)},Rt.reduce=Mn,Rt.reduceRight=Rn,Rt.repeat=pi,Rt.result=function(e,t,r){var i=null==e?n:e[t];return void 0===i&&(i=r),Yn(i)?i.call(e):i},Rt.runInContext=e,Rt.size=function(e){var t=e?e.length:0;return Zr(t)?t:oi(e).length},Rt.snakeCase=bi,Rt.some=Dn,Rt.sortedIndex=function(e,t,r,n){var i=Vr(r);return i===tr&&null==r?Pr(e,t):Or(e,t,i(r,n,1))},Rt.sortedLastIndex=function(e,t,r,n){var i=Vr(r);return i===tr&&null==r?Pr(e,t,!0):Or(e,t,i(r,n,1),!0)},Rt.startCase=vi,Rt.startsWith=function(e,t,r){return e=Oe(e),r=null==r?0:_t(r<0?0:+r||0,e.length),e.lastIndexOf(t,r)==r},Rt.template=function(e,t,r){var i=Rt.templateSettings;r&&Jr(e,t,r)&&(t=r=null),e=Oe(e);var o,s,a=Qt(Qt({},(t=Qt(Qt({},r||t),i,Zt)).imports),i.imports,Zt),c=oi(a),f=Br(a,c),u=0,h=t.interpolate||ae,l="__p += '",d=Se((t.escape||ae).source+"|"+h.source+"|"+(h===ee?te:ae).source+"|"+(t.evaluate||ae).source+"|$","g"),p="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++ye+"]")+"\n";e.replace(d,function(t,r,n,i,a,c){return n||(n=i),l+=e.slice(u,c).replace(he,He),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t}),l+="';\n";var y=t.variable;y||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(q,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var b=wi(function(){return me(c,p+"return "+l).apply(n,f)});if(b.source=l,Vn(b))throw b;return b},Rt.trim=gi,Rt.trimLeft=function(e,t,r){var n=e;return(e=Oe(e))?(r?Jr(n,t,r):null==t)?e.slice(qe(e)):e.slice(Re(e,t+"")):e},Rt.trimRight=function(e,t,r){var n=e;return(e=Oe(e))?(r?Jr(n,t,r):null==t)?e.slice(0,Ve(e)+1):e.slice(0,Le(e,t+"")+1):e},Rt.trunc=function(e,t,r){r&&Jr(e,t,r)&&(t=null);var n=b,i=v;if(null!=t)if(Xn(t)){var o="separator"in t?t.separator:o;n="length"in t?+t.length||0:n,i="omission"in t?Oe(t.omission):i}else n=+t||0;if(n>=(e=Oe(e)).length)return e;var s=n-i.length;if(s<1)return i;var a=e.slice(0,s);if(null==o)return a+i;if($n(o)){if(e.slice(s).search(o)){var c,f,u=e.slice(0,s);for(o.global||(o=Se(o.source,(re.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(u);)f=c.index;a=a.slice(0,null==f?s:f)}}else if(e.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Rt.unescape=function(e){return(e=Oe(e))&&J.test(e)?e.replace(Y,Ge):e},Rt.uniqueId=function(e){var t=++Qe;return Oe(e)+t},Rt.words=mi,Rt.all=En,Rt.any=Dn,Rt.contains=wn,Rt.detect=kn,Rt.foldl=Mn,Rt.foldr=Rn,Rt.head=ln,Rt.include=wn,Rt.inject=Mn,Ai(Rt,(yi={},yr(Rt,function(e,t){Rt.prototype[t]||(yi[t]=e)}),yi),!1),Rt.sample=Ln,Rt.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return Ln(t,e)}):Ln(this.value())},Rt.VERSION=s,zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){Rt[e].placeholder=Rt}),zt(["filter","map","takeWhile"],function(e,t){var r=t==w;Dt.prototype[e]=function(e,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||t==E&&i.dir<0,s.push({iteratee:Vr(e,n,3),type:t}),i}}),zt(["drop","take"],function(e,t){var r=e+"Count",n=e+"While";Dt.prototype[e]=function(n){n=null==n?1:wt(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=t?_t(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:e+(i.dir<0?"Right":"")});return i},Dt.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()},Dt.prototype[e+"RightWhile"]=function(e,t){return this.reverse()[n](e,t).reverse()}}),zt(["first","last"],function(e,t){var r="take"+(t?"Right":"");Dt.prototype[e]=function(){return this[r](1).value()[0]}}),zt(["initial","rest"],function(e,t){var r="drop"+(t?"":"Right");Dt.prototype[e]=function(){return this[r](1)}}),zt(["pluck","where"],function(e,t){var r=t?"filter":"map",n=t?_r:Er;Dt.prototype[e]=function(e){return this[r](n(t?e:e+""))}}),Dt.prototype.dropWhile=function(e,t){var r,n,i=this.dir<0;return e=Vr(e,t,3),this.filter(function(t,o,s){return r=r&&(i?on),n=o,r||(r=!e(t,o,s))})},Dt.prototype.reject=function(e,t){return e=Vr(e,t,3),this.filter(function(t,r,n){return!e(t,r,n)})},Dt.prototype.slice=function(e,t){var r=(e=null==e?0:+e||0)<0?this.takeRight(-e):this.drop(e);return void 0!==t&&(r=(t=+t||0)<0?r.dropRight(-t):r.take(t-e)),r},yr(Dt.prototype,function(e,t){var r=Rt[t],n=/^(?:first|last)$/.test(t);Rt.prototype[t]=function(){var t=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=t instanceof Dt,c=a&&!s;if(n&&!o)return c?e.call(t):r.call(Rt,this.value());var f=function(e){var t=[e];return ct.apply(t,i),r.apply(Rt,t)};if(a||Wn(t)){var u=c?t:new Dt(this),h=e.apply(u,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[f],thisArg:Rt}),new Lt(h,o)}return this.thru(f)}}),zt(["concat","join","pop","push","shift","sort","splice","unshift"],function(e){var t=xe[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(e);Rt.prototype[e]=function(){var e=arguments;return n&&!this.__chain__?t.apply(this.value(),e):this[r](function(r){return t.apply(r,e)})}}),Dt.prototype.clone=function(){var e=this.actions,t=this.iteratees,r=this.views,n=new Dt(this.wrapped);return n.actions=e?Kt(e):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=t?Kt(t):null,n.takeCount=this.takeCount,n.views=r?Kt(r):null,n},Dt.prototype.reverse=function(){if(this.filtered){var e=new Dt(this);e.dir=-1,e.filtered=!0}else(e=this.clone()).dir*=-1;return e},Dt.prototype.value=function(){var e=this.wrapped.value();if(!Wn(e))return Cr(e,this.actions);var t=this.dir,r=t<0,n=function(e,t,r){for(var n=-1,i=r?r.length:0;++n=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function a(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.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)},o.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)},o.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=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.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 o=e.length-r,s=o%n,c=Math.min(o,o-s)+r,f=0,u=r;u1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[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 h(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],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var f=1;f>>26,h=67108863&c,l=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=l;d++){var p=f-d|0;u+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[f]=0|h,c=0|u}return 0!==c?r.words[f]=0|c:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-h.length]+h+r:h+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.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=f[e],d=u[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:c[l-y.length]+y+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")},o.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},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==Buffer),this.toArrayLike(Buffer,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,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,a,c="le"===t,f=new e(o),u=this.clone();if(c){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),f[a]=s;for(;a=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},o.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},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.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;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.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<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.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 o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,y=d>>>13,b=0|s[2],v=8191&b,g=b>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],B=8191&T,C=T>>>13,P=0|s[7],O=8191&P,M=P>>>13,R=0|s[8],L=8191&R,j=R>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],W=8191&F,q=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,fe=ae>>>13,ue=0|a[8],he=8191&ue,le=ue>>>13,de=0|a[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(f+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;f=((o=Math.imul(l,z))+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(y,K)|0,o=Math.imul(y,z);var ve=(f+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,q)|0)+Math.imul(l,W)|0))<<13)|0;f=((o=o+Math.imul(l,q)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(y,W)|0,o=o+Math.imul(y,q)|0;var ge=(f+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;f=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,W)|0,i=(i=i+Math.imul(v,q)|0)+Math.imul(g,W)|0,o=o+Math.imul(g,q)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(y,G)|0,o=o+Math.imul(y,Y)|0;var me=(f+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;f=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,q)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,Z)|0;var we=(f+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,$)|0))<<13)|0;f=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,q)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,q)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;f=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(B,K),i=(i=Math.imul(B,z))+Math.imul(C,K)|0,o=Math.imul(C,z),n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,q)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,q)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Ee=(f+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(l,oe)|0))<<13)|0;f=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(O,K),i=(i=Math.imul(O,z))+Math.imul(M,K)|0,o=Math.imul(M,z),n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,q)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var Se=(f+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(l,ce)|0))<<13)|0;f=((o=o+Math.imul(l,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,q)|0)+Math.imul(M,W)|0,o=o+Math.imul(M,q)|0,n=n+Math.imul(B,G)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ce)|0,o=o+Math.imul(y,fe)|0;var ke=(f+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;f=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,q)|0)+Math.imul(j,W)|0,o=o+Math.imul(j,q)|0,n=n+Math.imul(O,G)|0,i=(i=i+Math.imul(O,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,Z)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(v,ce)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(g,ce)|0,o=o+Math.imul(g,fe)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(y,he)|0,o=o+Math.imul(y,le)|0;var Ae=(f+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(l,pe)|0))<<13)|0;f=((o=o+Math.imul(l,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(N,W),i=(i=Math.imul(N,q))+Math.imul(U,W)|0,o=Math.imul(U,q),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(g,he)|0,o=o+Math.imul(g,le)|0;var Ie=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,n=n+Math.imul(S,ce)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(k,ce)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var xe=(f+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,ye)|0)+Math.imul(g,pe)|0))<<13)|0;f=((o=o+Math.imul(g,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,se)|0,n=n+Math.imul(I,ce)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(x,ce)|0,o=o+Math.imul(x,fe)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,le)|0;var Te=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,ee))+Math.imul(U,$)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(B,ce)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(C,ce)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(I,he)|0,i=(i=i+Math.imul(I,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Be=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(N,re),i=(i=Math.imul(N,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,se)|0,n=n+Math.imul(O,ce)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(M,ce)|0,o=o+Math.imul(M,fe)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(C,he)|0,o=o+Math.imul(C,le)|0;var Ce=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,ye)|0)+Math.imul(x,pe)|0))<<13)|0;f=((o=o+Math.imul(x,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(N,oe),i=(i=Math.imul(N,se))+Math.imul(U,oe)|0,o=Math.imul(U,se),n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(j,ce)|0,o=o+Math.imul(j,fe)|0,n=n+Math.imul(O,he)|0,i=(i=i+Math.imul(O,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Pe=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(N,ce),i=(i=Math.imul(N,fe))+Math.imul(U,ce)|0,o=Math.imul(U,fe),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(j,he)|0,o=o+Math.imul(j,le)|0;var Oe=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(M,pe)|0))<<13)|0;f=((o=o+Math.imul(M,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(N,he),i=(i=Math.imul(N,le))+Math.imul(U,he)|0,o=Math.imul(U,le);var Me=(f+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ye)|0)+Math.imul(j,pe)|0))<<13)|0;f=((o=o+Math.imul(j,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863;var Re=(f+(n=Math.imul(N,pe))|0)+((8191&(i=(i=Math.imul(N,ye))+Math.imul(U,pe)|0))<<13)|0;return f=((o=Math.imul(U,ye))+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,c[0]=be,c[1]=ve,c[2]=ge,c[3]=me,c[4]=we,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=ke,c[9]=Ae,c[10]=Ie,c[11]=xe,c[12]=Te,c[13]=Be,c[14]=Ce,c[15]=Pe,c[16]=Oe,c[17]=Me,c[18]=Re,0!==f&&(c[19]=f,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(l=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?l(this,e,t):r<63?h(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,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,f=0;f=0&&(0!==u||f>=i);f--){var h=0|this.words[f];this.words[f]=u<<26-o|h>>>o,u=h&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=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<=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},o.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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,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 a,c=n.length-i.length;if("mod"!==t){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var f=0;f=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.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),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.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},o.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;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),c=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var u=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(u),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(u),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(c)):(r.isub(t),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,u=1;0==(t.words[0]&u)&&f<26;++f,u<<=1);if(f>0)for(t.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}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(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new _(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function b(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function m(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},i(v,b),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new m;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return y[e]=t,t},_.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),f=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRed(this);0!==this.pow(u,f).cmp(c);)u.redIAdd(c);for(var h=this.pow(u,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var y=d,b=0;0!==y.cmp(a);b++)y=y.redSqr();n(b=0;n--){for(var f=t.words[n],u=c-1;u>=0;u--){var h=f>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,_),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:104}],91:[function(e,t,r){var n={};function i(e,t){for(var r in e)t[r]=e[r]}t.exports=n,n.from=e("./from.js"),n.to=e("./to.js"),n.is=e("./is.js"),n.subarray=e("./subarray.js"),n.join=e("./join.js"),n.copy=e("./copy.js"),n.create=e("./create.js"),i(e("./read.js"),n),i(e("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(e,t,r){t.exports=function(e,t,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?e.length:o)===i)return;if(0===t.length||0===e.length)return;o>e.length&&(o=e.length);t.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(e){for(var t,r,n=[],i=0,o=e.length;i>>4).toString(16),r+=(15&t).toString(16);return r},utf8:function(e){return i(e)},base64:function(e){return n.fromByteArray(e)}}},{"base64-js":30,"to-utf8":350}],101:[function(e,t,r){t.exports={writeUInt8:function(e,t,r){return e[r]=t},writeInt8:function(e,t,r){return e[r]=t<0?t+256:t},writeUInt16LE:function(e,t,r){return n.get(e).setUint16(r+e.byteOffset,t,!0)},writeUInt32LE:function(e,t,r){return n.get(e).setUint32(r+e.byteOffset,t,!0)},writeInt16LE:function(e,t,r){return n.get(e).setInt16(r+e.byteOffset,t,!0)},writeInt32LE:function(e,t,r){return n.get(e).setInt32(r+e.byteOffset,t,!0)},writeFloatLE:function(e,t,r){return n.get(e).setFloat32(r+e.byteOffset,t,!0)},writeDoubleLE:function(e,t,r){return n.get(e).setFloat64(r+e.byteOffset,t,!0)},writeUInt16BE:function(e,t,r){return n.get(e).setUint16(r+e.byteOffset,t,!1)},writeUInt32BE:function(e,t,r){return n.get(e).setUint32(r+e.byteOffset,t,!1)},writeInt16BE:function(e,t,r){return n.get(e).setInt16(r+e.byteOffset,t,!1)},writeInt32BE:function(e,t,r){return n.get(e).setInt32(r+e.byteOffset,t,!1)},writeFloatBE:function(e,t,r){return n.get(e).setFloat32(r+e.byteOffset,t,!1)},writeDoubleBE:function(e,t,r){return n.get(e).setFloat64(r+e.byteOffset,t,!1)}};var n=e("./mapped.js")},{"./mapped.js":97}],102:[function(e,t,r){!function(e,r){void 0!==t&&t.exports?t.exports.browser=r():"function"==typeof define&&define.amd?define(r):this.bowser=r()}(0,function(){var e=!0;function t(t){function r(e){var r=t.match(e);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(t)&&/android/i.test(t),c=r(/edge\/(\d+(\.\d+)?)/i),f=r(/version\/(\d+(\.\d+)?)/i),u=/tablet/i.test(t),h=!u&&/[^-]mobi/i.test(t);/opera|opr/i.test(t)?n={name:"Opera",opera:e,version:f||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?(n={name:"Windows Phone",windowsphone:e},c?(n.msedge=e,n.version=c):(n.msie=e,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?n={name:"Internet Explorer",msie:e,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?n={name:"Microsoft Edge",msedge:e,version:c}:/chrome|crios|crmo/i.test(t)?n={name:"Chrome",chrome:e,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},f&&(n.version=f)):/sailfish/i.test(t)?n={name:"Sailfish",sailfish:e,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?n={name:"SeaMonkey",seamonkey:e,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(n={name:"Firefox",firefox:e,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(n.firefoxos=e)):/silk/i.test(t)?n={name:"Amazon Silk",silk:e,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:f}:/phantom/i.test(t)?n={name:"PhantomJS",phantom:e,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?n={name:"BlackBerry",blackberry:e,version:f||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(n={name:"WebOS",webos:e,version:f||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(n.touchpad=e)):n=/bada/i.test(t)?{name:"Bada",bada:e,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?{name:"Tizen",tizen:e,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||f}:/safari/i.test(t)?{name:"Safari",safari:e,version:f}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=t.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(t)?(n.name=n.name||"Webkit",n.webkit=e,!n.version&&f&&(n.version=f)):!n.opera&&/gecko\//i.test(t)&&(n.name=n.name||"Gecko",n.gecko=e,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=e,n.ios=e):n.android=e;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return u||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=e:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=e),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=e:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=e:n.x=e,n}var r=t("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(e){for(var t=0;t>>24]^u[p>>>16&255]^h[y>>>8&255]^l[255&b]^t[v++],s=f[p>>>24]^u[y>>>16&255]^h[b>>>8&255]^l[255&d]^t[v++],a=f[y>>>24]^u[b>>>16&255]^h[d>>>8&255]^l[255&p]^t[v++],c=f[b>>>24]^u[d>>>16&255]^h[p>>>8&255]^l[255&y]^t[v++],d=o,p=s,y=a,b=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[y>>>8&255]<<8|n[255&b])^t[v++],s=(n[p>>>24]<<24|n[y>>>16&255]<<16|n[b>>>8&255]<<8|n[255&d])^t[v++],a=(n[y>>>24]<<24|n[b>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[v++],c=(n[b>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&y])^t[v++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var f=a^a<<1^a<<2^a<<3^a<<4;f=f>>>8^255&f^99,r[s]=f,n[f]=s;var u=e[s],h=e[u],l=e[h],d=257*e[f]^16843008*f;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*u^16843008*s,o[0][f]=d<<24|d>>>8,o[1][f]=d<<16|d>>>16,o[2][f]=d<<8|d>>>24,o[3][f]=d,0===s?s=a=1:(s=u^e[e[e[l^u]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=n(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/t|0]<<24):t>6&&o%t==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-t]^c}for(var f=[],u=0;u>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=f},c.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},t.exports.AES=c},{"safe-buffer":322}],106:[function(e,t,r){var n=e("./aes"),Buffer=e("safe-buffer").Buffer,i=e("cipher-base"),o=e("inherits"),s=e("./ghash"),a=e("buffer-xor"),c=e("./incr32");function f(e,t,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(a);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=Buffer.concat([t,Buffer.from([0,0,0,1])]),Buffer.concat([t,Buffer.from([0,0,0,2])]);var n=new s(r),i=t.length,o=i%16;n.update(t),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,f=Buffer.alloc(8);f.writeUIntBE(a,0,8),n.update(f),e._finID=n.state;var u=Buffer.from(e._finID);return c(u),u}(this,r,f),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}o(f,i),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=Buffer.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},u.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return h(e,n.key,n.iv)},r.createDecipheriv=h},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,evp_bytestokey:237,inherits:259,"safe-buffer":322}],109:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),Buffer=e("safe-buffer").Buffer,o=e("./streamCipher"),s=e("cipher-base"),a=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new h,this._cipher=new a.AES(t),this._prev=Buffer.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return Buffer.concat(n)};var u=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=Buffer.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(u))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=Buffer.concat([this.cache,e])},h.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},h.prototype.flush=function(){for(var e=16-this.cache.length,t=Buffer.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(e){var t;for(this.cache=Buffer.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,e,0,t])),this.state},t.exports=o},{"safe-buffer":322}],111:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],112:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":130}],113:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-xor");function i(e,t,r){var i=t.length,o=n(t,e._cache);return e._cache=e._cache.slice(i),e._prev=Buffer.concat([e._prev,r?t:o]),o}r.encrypt=function(e,t,r){for(var n,o=Buffer.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=Buffer.allocUnsafe(0)),!(e._cache.length<=t.length)){o=Buffer.concat([o,i(e,t,r)]);break}n=e._cache.length,o=Buffer.concat([o,i(e,t.slice(0,n),r)]),t=t.slice(n)}return o}},{"buffer-xor":130,"safe-buffer":322}],114:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;function n(e,t,r){for(var n,o,s,a=-1,c=0;++a<8;)n=e._cipher.encryptBlock(e._prev),o=t&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,e._prev=i(e._prev,r?o:s);return c}function i(e,t){var r=e.length,n=-1,i=Buffer.allocUnsafe(e.length);for(e=Buffer.concat([e,Buffer.from([t])]);++n>7;return i}r.encrypt=function(e,t,r){for(var i=t.length,o=Buffer.allocUnsafe(i),s=-1;++so)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return f(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),n=s(r),i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function l(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(e).length;default:if(i)return n?-1:j(e).length;t=(""+t).toLowerCase(),i=!0}}function d(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function p(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var u=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+h<=r)switch(h){case 1:f<128&&(u=f);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&f)<<6|63&o)>127&&(u=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&f)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,i){if(U(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),u=0;u>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return m(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function A(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,r,n,i,o){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function P(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(e,t,r,n,o){return t=+t,r>>>=0,o||P(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function M(e,t,r,n,o){return t=+t,r>>>=0,o||P(e,0,r,8),i.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||C(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||C(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);C(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);C(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return O(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return O(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function D(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function N(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function U(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}},{"base64-js":132,ieee754:257}],132:[function(e,t,r){"use strict";r.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){for(var t,r=f(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),c=0,u=s>0?n-4:n,h=0;h>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===s&&(t=i[e.charCodeAt(h)]<<2|i[e.charCodeAt(h+1)]>>4,a[c++]=255&t);1===s&&(t=i[e.charCodeAt(h)]<<10|i[e.charCodeAt(h+1)]<<4|i[e.charCodeAt(h+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],133:[function(e,t,r){"use strict";for(var BigInteger=e("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),t.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),t.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),t.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),t.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function u(e){for(var t=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+e);if(0===n)throw new Error("Missing prefix for "+e);var a=e.slice(0,n),c=e.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=u(a),l=[],d=0;d=c.length||l.push(y)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+e);return{prefix:a,words:l}},encode:function(e,t){if(e.length+o+1+t.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=u(e=e.toLowerCase()),s=e+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=f(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&t||t>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,e>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&e),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+f.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:f.scriptType,prefix:t.prefix,hash:Buffer.from(c.slice(1))}},encode:function(e,t,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(t in s))throw new Error("Unsupported script type");return r.encode(e,r.toWords(c(t,n)))}}}).call(this,e("buffer").Buffer)},{"./base32":133,buffer:131}],135:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("stream").Transform,i=e("string_decoder").StringDecoder;function o(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(o,n),o.prototype.update=function(e,t,r){"string"==typeof e&&(e=Buffer.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},o.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},o.prototype._finalOrDigest=function(e){var t=this.__final()||Buffer.alloc(0);return e&&(t=this._toString(t,e,!0)),t},o.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new i(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=o},{inherits:259,"safe-buffer":322,stream:338,string_decoder:241}],136:[function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}void 0!==t&&(t.exports=n),n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;ir)?t=("rmd160"===e?new a:c(e)).update(t).digest():t.lengths?t=e(t):t.length>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(i=new Buffer(2))[0]=o,i[1]=n.length,this._createEncoderBuffer([i,n]);for(var a=1,c=n.length;c>=256;c>>=8)a++;(i=new Buffer(2+a))[0]=o,i[1]=128|a;c=1+a;for(var f=n.length;f>0;c--,f>>=8)i[c]=255&f;return this._createEncoderBuffer([i,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new Buffer(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var i=0;for(n=0;n=128;o>>=7)i++}var s=new Buffer(i),a=s.length-1;for(n=e.length-1;n>=0;n--){o=e[n];for(s[a--]=127&o;(o>>=7)>0;)s[a--]=128|127&o}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new Buffer(r)}if(Buffer.isBuffer(e)){var n=e.length;0===e.length&&n++;var i=new Buffer(n);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var o=e;o>=256;o>>=8)n++;for(o=(i=new Array(n)).length-1;o>=0;o--)i[o]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new Buffer(i))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0||!i.umod(e.prime1)||!i.umod(e.prime2);)i=new r(n(t));return i}t.exports=i,i.getr=o}).call(this,e("buffer").Buffer)},{"bn.js":90,buffer:131,randombytes:306}],159:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":160}],160:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],161:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],162:[function(e,t,r){(function(Buffer){var r=e("create-hash"),n=e("stream"),i=e("inherits"),o=e("./sign"),s=e("./verify"),a=e("./algorithms.json");function c(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function u(e){return new c(e)}function h(e){return new f(e)}Object.keys(a).forEach(function(e){a[e].id=new Buffer(a[e].id,"hex"),a[e.toLowerCase()]=a[e]}),i(c,n.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=o(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},i(f,n.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,r){"string"==typeof t&&(t=new Buffer(t,r)),this.end();var n=this._hash.digest();return s(t,n,e,this._signType,this._tag)},t.exports={Sign:u,Verify:h,createSign:u,createVerify:h}}).call(this,e("buffer").Buffer)},{"./algorithms.json":160,"./sign":163,"./verify":164,buffer:131,"create-hash":139,inherits:259,stream:338}],163:[function(e,t,r){(function(Buffer){var r=e("create-hmac"),n=e("browserify-rsa"),i=e("elliptic").ec,o=e("bn.js"),s=e("parse-asn1"),a=e("./curves.json");function c(e,t,n,i){if((e=new Buffer(e.toArray())).length0&&r.ishrn(n),r}function u(e,t,n){var i,o;do{for(i=new Buffer(0);8*i.length=t)throw new Error("invalid sig")}t.exports=function(e,t,a,c,f){var u=i(a);if("ec"===u.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=o[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var s=new n(i),a=r.data.subjectPrivateKey.data;return s.verify(t,e,a)}(e,t,u)}if("dsa"===u.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,n){var o=n.data.p,a=n.data.q,c=n.data.g,f=n.data.pub_key,u=i.signature.decode(e,"der"),h=u.s,l=u.r;s(h,a),s(l,a);var d=r.mont(o),p=h.invm(a);return 0===c.toRed(d).redPow(new r(t).mul(p).mod(a)).fromRed().mul(f.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(o).mod(a).cmp(l)}(e,t,u)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=Buffer.concat([f,t]);for(var h=u.modulus.byteLength(),l=[1],d=0;t.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var y=e[r],b=e[y],v=e[b],g=257*e[p]^16843008*p;s[r]=g<<24|g>>>8,a[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,f[r]=g;g=16843009*v^65537*b^257*y^16843008*r;u[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,l[p]=g<<8|g>>>24,d[p]=g,r?(r=y^e[e[e[v^y]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],y=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],f=0;f>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,f,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,h,l,d,o);r=e[t+1];e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,s,a){for(var c=this._nRounds,f=e[t]^r[0],u=e[t+1]^r[1],h=e[t+2]^r[2],l=e[t+3]^r[3],d=4,p=1;p>>24]^i[u>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],b=n[u>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&f]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[f>>>8&255]^s[255&u]^r[d++],g=n[l>>>24]^i[f>>>16&255]^o[u>>>8&255]^s[255&h]^r[d++];f=y,u=b,h=v,l=g}y=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],b=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^r[d++],g=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^r[d++];e[t]=y,e[t+1]=b,e[t+2]=v,e[t+3]=g},keySize:8});t.AES=r._createHelper(y)}(),e.AES},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],171:[function(e,t,r){var n,i;n=this,i=function(e){e.lib.Cipher||function(t){var r=e,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),f=r.algo.EvpKDF,u=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?m:v}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),h=(n.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),d=h.CBC=function(){var e=l.extend();function r(e,r,n){var i=this._iv;if(i){var o=i;this._iv=t}else o=this._prevBlock;for(var s=0;s>>2];e.sigBytes-=t}},y=(n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:d,padding:p}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode=n.call(r,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),b=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(t);else n=t;return n.toString(c)},parse:function(e){var t=c.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return y.create({ciphertext:t,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:b}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),s=i.cfg;return y.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(r.kdf={}).OpenSSL={execute:function(e,t,r,n){n||(n=o.random(8));var i=f.create({keySize:t+r}).compute(e,n),s=o.create(i.words.slice(t),4*r);return i.sigBytes=4*t,y.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,v.decrypt.call(this,e,t,i.key,n)}})}()},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],172:[function(e,t,r){var n,i;n=this,i=function(){var e=e||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={},o=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)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||c).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 o=0;o>>2]>>>24-o%4*8&255;t[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>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=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){t=t;var 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)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},f=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.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,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,f=e.min(4*c,i);if(c){for(var u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],174:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.WordArray,n=t.enc;n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,n=[],i=0;i>>1]|=e.charCodeAt(i)<<16-i%2*16;return r.create(n,2*t)}};function i(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o>>1]|=i(e.charCodeAt(o)<<16-o%2*16);return r.create(n,2*t)}}}(),e.enc.Utf16},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],175:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,f=0;f>>2]|=e[i]<<24-i%4*8;r.call(this,n,t)}else r.apply(this,arguments)}).prototype=t}}(),e.lib.WordArray},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],180:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],d=e[t+2],p=e[t+3],y=e[t+4],b=e[t+5],v=e[t+6],g=e[t+7],m=e[t+8],w=e[t+9],_=e[t+10],E=e[t+11],S=e[t+12],k=e[t+13],A=e[t+14],I=e[t+15],x=o[0],T=o[1],B=o[2],C=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=u(T=u(T=u(T=u(T=f(T=f(T=f(T=f(T,B=f(B,C=f(C,x=f(x,T,B,C,s,7,a[0]),T,B,c,12,a[1]),x,T,d,17,a[2]),C,x,p,22,a[3]),B=f(B,C=f(C,x=f(x,T,B,C,y,7,a[4]),T,B,b,12,a[5]),x,T,v,17,a[6]),C,x,g,22,a[7]),B=f(B,C=f(C,x=f(x,T,B,C,m,7,a[8]),T,B,w,12,a[9]),x,T,_,17,a[10]),C,x,E,22,a[11]),B=f(B,C=f(C,x=f(x,T,B,C,S,7,a[12]),T,B,k,12,a[13]),x,T,A,17,a[14]),C,x,I,22,a[15]),B=u(B,C=u(C,x=u(x,T,B,C,c,5,a[16]),T,B,v,9,a[17]),x,T,E,14,a[18]),C,x,s,20,a[19]),B=u(B,C=u(C,x=u(x,T,B,C,b,5,a[20]),T,B,_,9,a[21]),x,T,I,14,a[22]),C,x,y,20,a[23]),B=u(B,C=u(C,x=u(x,T,B,C,w,5,a[24]),T,B,A,9,a[25]),x,T,p,14,a[26]),C,x,m,20,a[27]),B=u(B,C=u(C,x=u(x,T,B,C,k,5,a[28]),T,B,d,9,a[29]),x,T,g,14,a[30]),C,x,S,20,a[31]),B=h(B,C=h(C,x=h(x,T,B,C,b,4,a[32]),T,B,m,11,a[33]),x,T,E,16,a[34]),C,x,A,23,a[35]),B=h(B,C=h(C,x=h(x,T,B,C,c,4,a[36]),T,B,y,11,a[37]),x,T,g,16,a[38]),C,x,_,23,a[39]),B=h(B,C=h(C,x=h(x,T,B,C,k,4,a[40]),T,B,s,11,a[41]),x,T,p,16,a[42]),C,x,v,23,a[43]),B=h(B,C=h(C,x=h(x,T,B,C,w,4,a[44]),T,B,S,11,a[45]),x,T,I,16,a[46]),C,x,d,23,a[47]),B=l(B,C=l(C,x=l(x,T,B,C,s,6,a[48]),T,B,g,10,a[49]),x,T,A,15,a[50]),C,x,b,21,a[51]),B=l(B,C=l(C,x=l(x,T,B,C,S,6,a[52]),T,B,p,10,a[53]),x,T,_,15,a[54]),C,x,c,21,a[55]),B=l(B,C=l(C,x=l(x,T,B,C,m,6,a[56]),T,B,I,10,a[57]),x,T,v,15,a[58]),C,x,k,21,a[59]),B=l(B,C=l(C,x=l(x,T,B,C,y,6,a[60]),T,B,E,10,a[61]),x,T,d,15,a[62]),C,x,w,21,a[63]),o[0]=o[0]+x|0,o[1]=o[1]+T|0,o[2]=o[2]+B|0,o[3]=o[3]+C|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,f=0;f<4;f++){var u=c[f];c[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function f(e,t,r,n,i,o,s){var a=e+(t&r|~t&n)+i+s;return(a<>>32-o)+t}function u(e,t,r,n,i,o,s){var a=e+(t&n|r&~n)+i+s;return(a<>>32-o)+t}function h(e,t,r,n,i,o,s){var a=e+(t^r^n)+i+s;return(a<>>32-o)+t}function l(e,t,r,n,i,o,s){var a=e+(r^(t|~n))+i+s;return(a<>>32-o)+t}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),e.MD5},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],181:[function(e,t,r){var n,i;n=this,i=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var t=e>>16&255,r=e>>8&255,n=255&e;255===t?(t=0,255===r?(r=0,255===n?n=0:++n):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=n}else e+=1<<24;return e}var n=t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(e){0===(e[0]=r(e[0]))&&(e[1]=r(e[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],187:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso10126={pad:function(t,r){var n=4*r,i=n-t.sigBytes%n;t.concat(e.lib.WordArray.random(i-1)).concat(e.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],188:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso97971={pad:function(t,r){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,r)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],189:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],190:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){for(var t=e.words,r=e.sigBytes-1;!(t[r>>>2]>>>24-r%4*8&255);)r--;e.sigBytes=r+1}},e.pad.ZeroPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],191:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a,c;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=a.create(r.hasher,e),o=i.create(),s=i.create([1]),c=o.words,f=s.words,u=r.keySize,h=r.iterations;c.length>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],c=o[1],f=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=f>>>16|4294901760&u,l=u<<16|65535&f;n[0]^=f,n[1]^=h,n[2]^=u,n[3]^=l,n[4]^=f,n[5]^=h,n[6]^=u,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,f=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^f}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.RabbitLegacy=r._createHelper(s)}(),e.RabbitLegacy},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],193:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=[],i=[],o=[],s=t.algo.Rabbit=r.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(t){var o=t.words,s=o[0],c=o[1],f=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=f>>>16|4294901760&u,l=u<<16|65535&f;i[0]^=f,i[1]^=h,i[2]^=u,i[3]^=l,i[4]^=f,i[5]^=h,i[6]^=u,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,f=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^f}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.Rabbit=r._createHelper(s)}(),e.Rabbit},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],194:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,i=n.RC4=r.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=t[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[r],e[r]=o,n|=e[(e[t]+e[r])%256]<<24-8*i}return this._i=t,this._j=r,n}t.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});t.RC4Drop=r._createHelper(s)}(),e.RC4},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],195:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),f=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,I,x,T=this._hash.words,B=h.words,C=l.words,P=a.words,O=c.words,M=f.words,R=u.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],I=_=T[4];for(r=0;r<80;r+=1)x=o+e[t+P[r]]|0,x+=r<16?p(s,d,w)+B[0]:r<32?y(s,d,w)+B[1]:r<48?b(s,d,w)+B[2]:r<64?v(s,d,w)+B[3]:g(s,d,w)+B[4],x=(x=m(x|=0,M[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=x,x=E+e[t+O[r]]|0,x+=r<16?g(S,k,A)+C[0]:r<32?v(S,k,A)+C[1]:r<48?b(S,k,A)+C[2]:r<64?y(S,k,A)+C[3]:p(S,k,A)+C[4],x=(x=m(x|=0,R[r]))+I|0,E=I,I=A,A=m(k,10),k=S,S=x;x=T[1]+d+A|0,T[1]=T[2]+w+I|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=x},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function y(e,t,r){return e&t|~e&r}function b(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function g(e,t,r){return e^(t|~r)}function m(e,t){return e<>>32-t}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),e.RIPEMD160},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],196:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s;return r=(t=e).lib,n=r.WordArray,i=r.Hasher,o=[],s=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],f=0;f<80;f++){if(f<16)o[f]=0|e[t+f];else{var u=o[f-3]^o[f-8]^o[f-14]^o[f-16];o[f]=u<<1|u>>>31}var h=(n<<5|n>>>27)+c+o[f];h+=f<20?1518500249+(i&s|~i&a):f<40?1859775393+(i^s^a):f<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(s),t.HmacSHA1=i._createHmacHelper(s),e.SHA1},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],197:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o;return r=(t=e).lib.WordArray,n=t.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=i._doFinalize.call(this);return e.sigBytes-=4,e}}),t.SHA224=i._createHelper(o),t.HmacSHA224=i._createHmacHelper(o),e.SHA224},"object"==typeof r?t.exports=r=i(e("./core"),e("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],i):i(n.CryptoJS)},{"./core":172,"./sha256":198}],198:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(a[i]=r(t.pow(n,.5))),c[i]=r(t.pow(n,1/3)),i++),n++}();var f=[],u=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],u=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)f[d]=0|e[t+d];else{var p=f[d-15],y=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,b=f[d-2],v=(b<<15|b>>>17)^(b<<13|b>>>19)^b>>>10;f[d]=y+f[d-7]+v+f[d-16]}var g=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&h)+c[d]+f[d];l=h,h=u,u=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+u|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=o._createHelper(u),r.HmacSHA256=o._createHmacHelper(u)}(Math),e.SHA256},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],199:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],f=[],u=[];!function(){for(var e=1,t=0,r=0;r<24;r++){c[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)f[e+5*t]=t+(2*e+3*t)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,y=0;y<5;y++){d^=(T=r[l+5*y]).high,p^=T.low}var b=h[l];b.high=d,b.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],g=h[(l+1)%5],m=g.high,w=g.low;for(d=v.high^(m<<1|w>>>31),p=v.low^(w<<1|m>>>31),y=0;y<5;y++){(T=r[l+5*y]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[f[_]];A.high=d,A.low=p}var I=h[0],x=r[0];I.high=x.high,I.low=x.low;for(l=0;l<5;l++)for(y=0;y<5;y++){var T=r[_=l+5*y],B=h[_],C=h[(l+1)%5+5*y],P=h[(l+2)%5+5*y];T.high=B.high^~C.high&P.high,T.low=B.low^~C.low&P.low}T=r[0];var O=u[a];T.high^=O.high,T.low^=O.low}},_doFinalize:function(){var e=this._data,r=e.words,n=(this._nDataBytes,8*e.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(t.ceil((n+1)/o)*o>>>5)-1]|=128,e.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,f=[],u=0;u>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),f.push(d),f.push(l)}return new i.init(f,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),e.SHA3},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":172,"./x64-core":203}],200:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).x64,n=r.Word,i=r.WordArray,o=t.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=16,e}}),t.SHA384=s._createHelper(a),t.HmacSHA384=s._createHmacHelper(a),e.SHA384},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core"),e("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],i):i(n.CryptoJS)},{"./core":172,"./sha512":201,"./x64-core":203}],201:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.Hasher,n=t.x64,i=n.Word,o=n.WordArray,s=t.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],f=[];!function(){for(var e=0;e<80;e++)f[e]=a()}();var u=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],u=r[5],h=r[6],l=r[7],d=n.high,p=n.low,y=i.high,b=i.low,v=o.high,g=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=u.high,k=u.low,A=h.high,I=h.low,x=l.high,T=l.low,B=d,C=p,P=y,O=b,M=v,R=g,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=I,F=x,W=T,q=0;q<80;q++){var V=f[q];if(q<16)var G=V.high=0|e[t+2*q],Y=V.low=0|e[t+2*q+1];else{var X=f[q-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),ee=f[q-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ie=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),oe=f[q-7],se=oe.high,ae=oe.low,ce=f[q-16],fe=ce.high,ue=ce.low;G=(G=(G=Q+se+((Y=$+ae)>>>0<$>>>0?1:0))+ne+((Y=Y+ie)>>>0>>0?1:0))+fe+((Y=Y+ue)>>>0>>0?1:0);V.high=G,V.low=Y}var he,le=D&U^~D&K,de=N&H^~N&z,pe=B&P^B&M^P&M,ye=C&O^C&R^O&R,be=(B>>>28|C<<4)^(B<<30|C>>>2)^(B<<25|C>>>7),ve=(C>>>28|B<<4)^(C<<30|B>>>2)^(C<<25|B>>>7),ge=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),me=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),we=c[q],_e=we.high,Ee=we.low,Se=F+ge+((he=W+me)>>>0>>0?1:0),ke=ve+ye;F=K,W=z,K=U,z=H,U=D,H=N,D=L+(Se=(Se=(Se=Se+le+((he=he+de)>>>0>>0?1:0))+_e+((he=he+Ee)>>>0>>0?1:0))+G+((he=he+Y)>>>0>>0?1:0))+((N=j+he|0)>>>0>>0?1:0)|0,L=M,j=R,M=P,R=O,P=B,O=C,B=Se+(be+pe+(ke>>>0>>0?1:0))+((C=he+ke|0)>>>0>>0?1:0)|0}p=n.low=p+C,n.high=d+B+(p>>>0>>0?1:0),b=i.low=b+O,i.high=y+P+(b>>>0>>0?1:0),g=o.low=g+R,o.high=v+M+(g>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=u.low=k+H,u.high=S+U+(k>>>0>>0?1:0),I=h.low=I+z,h.high=A+K+(I>>>0>>0?1:0),T=l.low=T+W,l.high=x+F+(T>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});t.SHA512=r._createHelper(u),t.HmacSHA512=r._createHmacHelper(u)}(),e.SHA512},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":172,"./x64-core":203}],202:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib,n=r.WordArray,i=r.BlockCipher,o=t.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],f=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=s[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var f=i[o]=[],u=c[o];for(r=0;r<24;r++)f[r/6|0]|=t[(a[r]-1+u)%28]<<31-r%6,f[4+(r/6|0)]|=t[28+(a[r+24]-1+u)%28]<<31-r%6;f[0]=f[0]<<1|f[0]>>>31;for(r=1;r<7;r++)f[r]=f[r]>>>4*(r-1)+3;f[7]=f[7]<<5|f[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=f[c][((s^i[c])&u[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},r.enable(i())}).call(this,e("_process"))},{"./debug":205,_process:271}],205:[function(e,t,r){var n;function i(e){function t(){if(t.enabled){var e=t,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=s.r28shl(r,a),i=s.r28shl(i,a),s.pc2(r,i,e.keys,o)}},c.prototype._update=function(e,t,r,n){var i=this._desState,o=s.readUInt32BE(e,t),a=s.readUInt32BE(e,t+4);s.ip(o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,a,i.tmp,0):this._decrypt(i,o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],s.writeUInt32BE(r,o,n),s.writeUInt32BE(r,a,n+4)},c.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}s.rip(a,o,n,i)},c.prototype._decrypt=function(e,t,r,n,i){for(var o=r,a=t,c=e.keys.length-2;c>=0;c-=2){var f=e.keys[c],u=e.keys[c+1];s.expand(o,e.tmp,0),f^=e.tmp[0],u^=e.tmp[1];var h=s.substitute(f,u),l=o;o=(a^s.permute(h))>>>0,a=l}s.rip(o,a,n,i)}},{"../des":206,inherits:259,"minimalistic-assert":266}],210:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),s=o.Cipher,a=o.DES;function c(e){s.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[a.create({type:"encrypt",key:r}),a.create({type:"decrypt",key:i}),a.create({type:"encrypt",key:o})]:[a.create({type:"decrypt",key:o}),a.create({type:"encrypt",key:i}),a.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(c,s),t.exports=c,c.create=function(e){return new c(e)},c.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},c.prototype._pad=a.prototype._pad,c.prototype._unpad=a.prototype._unpad},{"../des":206,inherits:259,"minimalistic-assert":266}],211:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=t>>>a+s&1,i<<=1,i|=e>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=t>>>a+s&1,o<<=1,o|=e>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),t.cmp(c)){if(!t.cmp(f))for(;r.mod(u).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(b(p=r.shrn(1))&&b(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":265,randombytes:306}],215:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],216:[function(e,t,r){var n=e("assert"),BigInteger=e("bigi"),Point=e("./point");function i(e,t,r,n,i,o,s){this.p=e,this.a=t,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=e.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),Point.fromAffine(this,t,n)},i.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},i.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=t.pow(3).add(n.multiply(t)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},t.exports=i},{"./point":220,assert:24,bigi:34}],217:[function(e,t,r){t.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],218:[function(e,t,r){var Point=e("./point"),n=e("./curve"),i=e("./names");t.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":216,"./names":219,"./point":220}],219:[function(e,t,r){var BigInteger=e("bigi"),n=e("./curves.json"),i=e("./curve");t.exports=function(e){var t=n[e];if(!t)return null;var r=new BigInteger(t.p,16),o=new BigInteger(t.a,16),s=new BigInteger(t.b,16),a=new BigInteger(t.n,16),c=new BigInteger(t.h,16),f=new BigInteger(t.Gx,16),u=new BigInteger(t.Gy,16);return new i(r,o,s,f,u,a,c)}},{"./curve":216,"./curves.json":217,bigi:34}],220:[function(e,t,r){var n=e("assert"),Buffer=e("safe-buffer").Buffer,BigInteger=e("bigi"),i=BigInteger.valueOf(3);function Point(e,t,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=e,this.x=t,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(e,t,r){return new Point(e,t,r,BigInteger.ONE)},Point.prototype.equals=function(e){return e===this||(this.curve.isInfinity(this)?this.curve.isInfinity(e):this.curve.isInfinity(e)?this.curve.isInfinity(this):0===e.y.multiply(this.z).subtract(this.y.multiply(e.z)).mod(this.curve.p).signum()&&0===e.x.multiply(this.z).subtract(this.x.multiply(e.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var e=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,e,this.z)},Point.prototype.add=function(e){if(this.curve.isInfinity(this))return e;if(this.curve.isInfinity(e))return this;var t=this.x,r=this.y,n=e.x,o=e.y.multiply(this.z).subtract(r.multiply(e.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(t.multiply(e.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),f=t.multiply(a),u=o.square().multiply(this.z),h=u.subtract(f.shiftLeft(1)).multiply(e.z).subtract(c).multiply(s).mod(this.curve.p),l=f.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(u.multiply(o)).multiply(e.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(e.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var e=this.x,t=this.y,r=t.multiply(this.z).mod(this.curve.p),n=r.multiply(t).mod(this.curve.p),o=this.curve.a,s=e.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),f=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,f)},Point.prototype.multiply=function(e){if(this.curve.isInfinity(this))return this;if(0===e.signum())return this.curve.infinity;for(var t=e,r=t.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=t.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var s=e.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(t)),--n}return i},Point.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var t,r=this.affineX,n=this.affineY,i=this.curve.pLength;return e?(t=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((t=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(t,1+i)),r.toBuffer(i).copy(t,1),t},Point.decodeFrom=function(e,t){var r,i=t.readUInt8(0),o=4!==i,s=Math.floor((e.p.bitLength()+7)/8),a=BigInteger.fromBuffer(t.slice(1,1+s));if(o){n.equal(t.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=e.pointFromX(c,a)}else{n.equal(t.length,1+s+s,"Invalid sequence length");var f=BigInteger.fromBuffer(t.slice(1+s));r=Point.fromAffine(e,a,f)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},t.exports=Point},{assert:24,bigi:34,"safe-buffer":322}],221:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":236,"./elliptic/curve":224,"./elliptic/curves":227,"./elliptic/ec":228,"./elliptic/eddsa":231,"./elliptic/utils":235,brorand:103}],222:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,s=i.getJSF,a=i.assert;function c(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=c;t--)f=(f<<1)+n[t];s.push(f)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(c=0;c=0;f--){for(t=0;f>=0&&0===s[f];f--)t++;if(f>=0&&t++,c=c.dblp(t),f<0)break;var u=s[f];a(0!==u),c="affine"===e.type?u>0?c.mixedAdd(i[u-1>>1]):c.mixedAdd(i[-u-1>>1].neg()):u>0?c.add(i[u-1>>1]):c.add(i[-u-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,f=this._wnafT3,u=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===a[d]&&1===a[p]){var y=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(y[1]=t[d].add(t[p]),y[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(y[1]=t[d].toJ().mixedAdd(t[p]),y[2]=t[d].add(t[p].neg())):(y[1]=t[d].toJ().mixedAdd(t[p]),y[2]=t[d].toJ().mixedAdd(t[p].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[d],r[p]);u=Math.max(v[0].length,u),f[d]=new Array(u),f[p]=new Array(u);for(var g=0;g=0;h--){for(var S=0;h>=0;){var k=!0;for(g=0;g=0&&S++,_=_.dblp(S),h<0)break;for(g=0;g0?A=c[g][I-1>>1]:I<0&&(A=c[g][-I-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},f.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),s=o.redSub(r),a=n.redSub(t),c=i.redMul(s),f=o.redMul(a),u=i.redMul(a),h=s.redMul(o);return this.curve.point(c,f,h,u)},Point.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(f=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(f.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),c=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(c),t=s.redMul(f.redSub(o)),r=s.redMul(c)}}else{var f=i.redAdd(o);a=this.curve._mulC(this.z).redSqr(),c=f.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(f)).redMul(c),t=this.curve._mulC(f).redMul(i.redISub(o)),r=f.redMul(c)}return this.curve.point(e,t,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(t),f=o.redMul(s),u=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(f,u,l,h)},Point.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),s=this.y.redMul(e.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),f=i.redAdd(a),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(u);return this.curve.twisted?(t=n.redMul(f).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(f)):(t=n.redMul(f).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(f)),this.curve.point(h,t,r)},Point.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],224:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":222,"./edwards":223,"./mont":225,"./short":226}],225:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),s=n.base,a=e("../../elliptic").utils;function c(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(c,s),t.exports=c,c.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(Point,s.BasePoint),c.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},c.prototype.point=function(e,t){return new Point(this,e,t)},c.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1]||e.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),s=i.redMul(n),a=t.z.redMul(o.redAdd(s).redSqr()),c=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],226:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),s=e("inherits"),a=n.base,c=i.utils.assert;function f(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(f,a),t.exports=f,f.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],c(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},f.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},f.prototype._getEndoBasis=function(e){for(var t,r,n,i,s,a,c,f,u,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),y=new o(0),b=new o(0),v=new o(1),g=0;0!==l.cmpn(0);){var m=d.div(l);f=d.sub(m.mul(l)),u=b.sub(m.mul(p));var w=v.sub(m.mul(y));if(!n&&f.cmp(h)<0)t=c.neg(),r=p,n=f.neg(),i=u;else if(n&&2==++g)break;c=f,d=l,l=f,b=p,p=u,v=y,y=w}s=f.neg(),a=u;var _=n.sqr().add(i.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},f.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:c.add(f).neg()}},f.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},f.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},f.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Point.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(u,a.BasePoint),f.prototype.jpoint=function(e,t,r){return new u(this,e,t,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=a.redSqr(),u=f.redMul(a),h=n.redMul(f),l=c.redSqr().redIAdd(u).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(u)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},u.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),u=r.redMul(c),h=a.redSqr().redIAdd(f).redISub(u).redISub(u),l=a.redMul(u.redISub(h)).redISub(i.redMul(f)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},u.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],227:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),s=e("../elliptic"),a=s.utils.assert;function c(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":221,"./precomputed/secp256k1":234,"hash.js":244}],228:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),s=o.utils.assert,a=e("./key"),c=e("./signature");function f(e){if(!(this instanceof f))return new f(e);"string"==typeof e&&(s(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=f,f.prototype.keyPair=function(e){return new a(this,e)},f.prototype.keyFromPrivate=function(e,t){return a.fromPrivate(this,e,t)},f.prototype.keyFromPublic=function(e,t){return a.fromPublic(this,e,t)},f.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}},f.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},f.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:f,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var y=p.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var v=d.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(v=v.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),g^=1),new c({r:b,s:v,recoveryParam:g})}}}}}},f.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,f=s.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},f.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),f=t.r,u=t.s,h=1&r,l=r>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");f=l?this.curve.pointFromX(f.add(this.curve.n),h):this.curve.pointFromX(f,h);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),y=u.mul(d).umod(o);return this.g.mulAdd(p,f,y)},f.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":221,"./key":229,"./signature":230,"bn.js":90,"hmac-drbg":256}],229:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":221,"bn.js":90}],230:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var c=a(e,r);if(e.length!==c+r.place)return!1;var f=e.slice(r.place,c+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===f[0]&&128&f[1]&&(f=f.slice(1)),this.r=new n(s),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var o=n.concat(r),s=[48];return f(s,o.length),s=s.concat(o),i.encode(s,e)}},{"../../elliptic":221,"bn.js":90}],231:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,s=o.assert,a=o.parseBytes,c=e("./key"),f=e("./signature");function u(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof u))return new u(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=u,u.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},u.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},u.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,c=1;c0||t.cmpn(-i)>0;){var o,s,a,c=e.andln(3)+n&3,f=t.andln(3)+i&3;3===c&&(c=-1),3===f&&(f=-1),o=0==(1&c)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==f?c:-c,r[0].push(o),s=0==(1&f)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==c?f:-f,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":90,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],236:[function(e,t,r){t.exports={_from:"elliptic@^6.2.3",_id:"elliptic@6.4.1",_inBundle:!1,_integrity:"sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.2.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.2.3",saveSpec:null,fetchSpec:"^6.2.3"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",_shasum:"c2d0b7776911b86722c632c3c06c60f2f819939a",_spec:"elliptic@^6.2.3",_where:"/work/blocktrail-sdk-nodejs/node_modules/secp256k1",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.1"}},{}],237:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,r,i){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),t&&(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var f=new n;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var u=0;if(o>0){var h=s.length-o;u=Math.min(o,c.length),c.copy(s,h,0,u),o-=u}if(u0){var l=a.length-i,d=Math.min(i,c.length-u);c.copy(a,l,u,u+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":263,"safe-buffer":322}],238:[function(e,t,r){arguments[4][104][0].apply(r,arguments)},{dup:104}],239:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,a,c,f;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(s(r=this._events[e]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(f=r.slice()).length,c=0;c0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(a=s;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],240:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,f=2147483647,u=36,h=1,l=26,d=38,p=700,y=72,b=128,v="-",g=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=u-h,S=Math.floor,k=String.fromCharCode;function A(e){throw new RangeError(_[e])}function I(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+I((e=e.replace(w,".")).split("."),t).join(".")}function T(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)}).join("")}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>E*l>>1;n+=u)e=S(e/E);return S(n+(E+1)*e/(e+d))}function O(e){var t,r,n,i,o,s,a,c,d,p,g,m=[],w=e.length,_=0,E=b,k=y;for((r=e.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(g=e.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:u)>=u||c>S((f-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=u)s>S(f/(p=u-d))&&A("overflow"),s*=p;k=P(_-o,t=m.length+1,0==o),S(_/t)>f-E&&A("overflow"),E+=S(_/t),_%=t,m.splice(_++,0,E)}return B(m)}function M(e){var t,r,n,i,o,s,a,c,d,p,g,m,w,_,E,I=[];for(m=(e=T(e)).length,t=b,r=0,o=y,s=0;s=t&&gS((f-r)/(w=n+1))&&A("overflow"),r+=(a-t)*w,t=a,s=0;sf&&A("overflow"),g==t){for(c=r,d=u;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=u)E=c-p,_=u-p,I.push(k(C(p+E%_,0))),c=S(E/_);I.push(k(C(c,0))),o=P(r,w,n==i),r=0,++n}++r,++t}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:B},decode:O,encode:M,toASCII:function(e){return x(e,function(e){return m.test(e)?"xn--"+M(e):e})},toUnicode:function(e){return x(e,function(e){return g.test(e)?O(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return a});else if(i&&o)if(t.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],241:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=Buffer.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(Buffer.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=a,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=u,t=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":322}],242:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i},{inherits:259,"safe-buffer":322,stream:338}],244:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":255}],255:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(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}r.inherits=i,r.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),i=0;i>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,f=t;return c+=(f=f+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,f){var u=0,h=t;return u+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,f){return t+n+o+a+f>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:259,"minimalistic-assert":266}],256:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,u=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=l,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=l,u-=8);if(0===o)o=1-f;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,c,f=8*o-i-1,u=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*y}},{}],258:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r>>1,N=[["ary",E],["bind",y],["bindKey",b],["curry",g],["curryRight",m],["flip",k],["partial",w],["partialRight",_],["rearg",S]],U="[object Arguments]",H="[object Array]",K="[object AsyncFunction]",z="[object Boolean]",F="[object Date]",W="[object DOMException]",q="[object Error]",V="[object Function]",G="[object GeneratorFunction]",Y="[object Map]",X="[object Number]",J="[object Null]",Z="[object Object]",Q="[object Proxy]",$="[object RegExp]",ee="[object Set]",te="[object String]",re="[object Symbol]",ne="[object Undefined]",ie="[object WeakMap]",oe="[object WeakSet]",se="[object ArrayBuffer]",ae="[object DataView]",ce="[object Float32Array]",fe="[object Float64Array]",ue="[object Int8Array]",he="[object Int16Array]",le="[object Int32Array]",de="[object Uint8Array]",pe="[object Uint8ClampedArray]",ye="[object Uint16Array]",be="[object Uint32Array]",ve=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,me=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,Ee=RegExp(we.source),Se=RegExp(_e.source),ke=/<%-([\s\S]+?)%>/g,Ae=/<%([\s\S]+?)%>/g,Ie=/<%=([\s\S]+?)%>/g,xe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Te=/^\w*$/,Be=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ce=/[\\^$.*+?()[\]{}|]/g,Pe=RegExp(Ce.source),Oe=/^\s+|\s+$/g,Me=/^\s+/,Re=/\s+$/,Le=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,je=/\{\n\/\* \[wrapped with (.+)\] \*/,De=/,? & /,Ne=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ue=/\\(\\)?/g,He=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ke=/\w*$/,ze=/^[-+]0x[0-9a-f]+$/i,Fe=/^0b[01]+$/i,We=/^\[object .+?Constructor\]$/,qe=/^0o[0-7]+$/i,Ve=/^(?:0|[1-9]\d*)$/,Ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,Xe=/['\n\r\u2028\u2029\\]/g,Je="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qe="[\\ud800-\\udfff]",$e="["+Ze+"]",et="["+Je+"]",tt="\\d+",rt="[\\u2700-\\u27bf]",nt="[a-z\\xdf-\\xf6\\xf8-\\xff]",it="[^\\ud800-\\udfff"+Ze+tt+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ot="\\ud83c[\\udffb-\\udfff]",st="[^\\ud800-\\udfff]",at="(?:\\ud83c[\\udde6-\\uddff]){2}",ct="[\\ud800-\\udbff][\\udc00-\\udfff]",ft="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ut="(?:"+nt+"|"+it+")",ht="(?:"+ft+"|"+it+")",lt="(?:"+et+"|"+ot+")"+"?",dt="[\\ufe0e\\ufe0f]?"+lt+("(?:\\u200d(?:"+[st,at,ct].join("|")+")[\\ufe0e\\ufe0f]?"+lt+")*"),pt="(?:"+[rt,at,ct].join("|")+")"+dt,yt="(?:"+[st+et+"?",et,at,ct,Qe].join("|")+")",bt=RegExp("['’]","g"),vt=RegExp(et,"g"),gt=RegExp(ot+"(?="+ot+")|"+yt+dt,"g"),mt=RegExp([ft+"?"+nt+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[$e,ft,"$"].join("|")+")",ht+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[$e,ft+ut,"$"].join("|")+")",ft+"?"+ut+"+(?:['’](?:d|ll|m|re|s|t|ve))?",ft+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt,pt].join("|"),"g"),wt=RegExp("[\\u200d\\ud800-\\udfff"+Je+"\\ufe0e\\ufe0f]"),_t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],St=-1,kt={};kt[ce]=kt[fe]=kt[ue]=kt[he]=kt[le]=kt[de]=kt[pe]=kt[ye]=kt[be]=!0,kt[U]=kt[H]=kt[se]=kt[z]=kt[ae]=kt[F]=kt[q]=kt[V]=kt[Y]=kt[X]=kt[Z]=kt[$]=kt[ee]=kt[te]=kt[ie]=!1;var At={};At[U]=At[H]=At[se]=At[ae]=At[z]=At[F]=At[ce]=At[fe]=At[ue]=At[he]=At[le]=At[Y]=At[X]=At[Z]=At[$]=At[ee]=At[te]=At[re]=At[de]=At[pe]=At[ye]=At[be]=!0,At[q]=At[V]=At[ie]=!1;var It={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xt=parseFloat,Tt=parseInt,Bt="object"==typeof e&&e&&e.Object===Object&&e,Ct="object"==typeof self&&self&&self.Object===Object&&self,Pt=Bt||Ct||Function("return this")(),Ot="object"==typeof r&&r&&!r.nodeType&&r,Mt=Ot&&"object"==typeof t&&t&&!t.nodeType&&t,Rt=Mt&&Mt.exports===Ot,Lt=Rt&&Bt.process,jt=function(){try{var e=Mt&&Mt.require&&Mt.require("util").types;return e||Lt&&Lt.binding&&Lt.binding("util")}catch(e){}}(),Dt=jt&&jt.isArrayBuffer,Nt=jt&&jt.isDate,Ut=jt&&jt.isMap,Ht=jt&&jt.isRegExp,Kt=jt&&jt.isSet,zt=jt&&jt.isTypedArray;function Ft(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Wt(e,t,r,n){for(var i=-1,o=null==e?0:e.length;++i-1}function Jt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n-1;);return r}function gr(e,t){for(var r=e.length;r--&&or(t,e[r],0)>-1;);return r}var mr=ur({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),wr=ur({"&":"&","<":"<",">":">",'"':""","'":"'"});function _r(e){return"\\"+It[e]}function Er(e){return wt.test(e)}function Sr(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function kr(e,t){return function(r){return e(t(r))}}function Ar(e,t){for(var r=-1,n=e.length,i=0,o=[];++r",""":'"',"'":"'"});var Pr=function e(t){var r,Je=(t=null==t?Pt:Pr.defaults(Pt.Object(),t,Pr.pick(Pt,Et))).Array,Ze=t.Date,Qe=t.Error,$e=t.Function,et=t.Math,tt=t.Object,rt=t.RegExp,nt=t.String,it=t.TypeError,ot=Je.prototype,st=$e.prototype,at=tt.prototype,ct=t["__core-js_shared__"],ft=st.toString,ut=at.hasOwnProperty,ht=0,lt=(r=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",dt=at.toString,pt=ft.call(tt),yt=Pt._,gt=rt("^"+ft.call(ut).replace(Ce,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Rt?t.Buffer:n,wt=t.Symbol,It=t.Uint8Array,Bt=Buffer?Buffer.allocUnsafe:n,Ct=kr(tt.getPrototypeOf,tt),Ot=tt.create,Mt=at.propertyIsEnumerable,Lt=ot.splice,jt=wt?wt.isConcatSpreadable:n,rr=wt?wt.iterator:n,ur=wt?wt.toStringTag:n,Or=function(){try{var e=No(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),Mr=t.clearTimeout!==Pt.clearTimeout&&t.clearTimeout,Rr=Ze&&Ze.now!==Pt.Date.now&&Ze.now,Lr=t.setTimeout!==Pt.setTimeout&&t.setTimeout,jr=et.ceil,Dr=et.floor,Nr=tt.getOwnPropertySymbols,Ur=Buffer?Buffer.isBuffer:n,Hr=t.isFinite,Kr=ot.join,zr=kr(tt.keys,tt),Fr=et.max,Wr=et.min,qr=Ze.now,Vr=t.parseInt,Gr=et.random,Yr=ot.reverse,Xr=No(t,"DataView"),Jr=No(t,"Map"),Zr=No(t,"Promise"),Qr=No(t,"Set"),$r=No(t,"WeakMap"),en=No(tt,"create"),tn=$r&&new $r,rn={},nn=us(Xr),on=us(Jr),sn=us(Zr),an=us(Qr),cn=us($r),fn=wt?wt.prototype:n,un=fn?fn.valueOf:n,hn=fn?fn.toString:n;function ln(e){if(xa(e)&&!ba(e)&&!(e instanceof bn)){if(e instanceof yn)return e;if(ut.call(e,"__wrapped__"))return hs(e)}return new yn(e)}var dn=function(){function e(){}return function(t){if(!Ia(t))return{};if(Ot)return Ot(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function pn(){}function yn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function bn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=L,this.__views__=[]}function vn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Rn(e,t,r,i,o,s){var a,c=t&u,f=t&h,d=t&l;if(r&&(a=o?r(e,i,o,s):r(e)),a!==n)return a;if(!Ia(e))return e;var p=ba(e);if(p){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ut.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!c)return to(e,a)}else{var y=Ko(e),b=y==V||y==G;if(wa(e))return Xi(e,c);if(y==Z||y==U||b&&!o){if(a=f||b?{}:Fo(e),!c)return f?function(e,t){return ro(e,Ho(e),t)}(e,function(e,t){return e&&ro(t,ic(t),e)}(a,e)):function(e,t){return ro(e,Uo(e),t)}(e,Cn(a,e))}else{if(!At[y])return o?e:{};a=function(e,t,r){var n,i,o,s=e.constructor;switch(t){case se:return Ji(e);case z:case F:return new s(+e);case ae:return function(e,t){var r=t?Ji(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case ce:case fe:case ue:case he:case le:case de:case pe:case ye:case be:return Zi(e,r);case Y:return new s;case X:case te:return new s(e);case $:return(o=new(i=e).constructor(i.source,Ke.exec(i))).lastIndex=i.lastIndex,o;case ee:return new s;case re:return n=e,un?tt(un.call(n)):{}}}(e,y,c)}}s||(s=new _n);var v=s.get(e);if(v)return v;if(s.set(e,a),Oa(e))return e.forEach(function(n){a.add(Rn(n,t,r,n,e,s))}),a;if(Ta(e))return e.forEach(function(n,i){a.set(i,Rn(n,t,r,i,e,s))}),a;var g=p?n:(d?f?Po:Co:f?ic:nc)(e);return qt(g||e,function(n,i){g&&(n=e[i=n]),xn(a,i,Rn(n,t,r,i,e,s))}),a}function Ln(e,t,r){var i=r.length;if(null==e)return!i;for(e=tt(e);i--;){var o=r[i],s=t[o],a=e[o];if(a===n&&!(o in e)||!s(a))return!1}return!0}function jn(e,t,r){if("function"!=typeof e)throw new it(s);return ns(function(){e.apply(n,r)},t)}function Dn(e,t,r,n){var o=-1,s=Xt,a=!0,c=e.length,f=[],u=t.length;if(!c)return f;r&&(t=Zt(t,pr(r))),n?(s=Jt,a=!1):t.length>=i&&(s=br,a=!1,t=new wn(t));e:for(;++o-1},gn.prototype.set=function(e,t){var r=this.__data__,n=Tn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},mn.prototype.clear=function(){this.size=0,this.__data__={hash:new vn,map:new(Jr||gn),string:new vn}},mn.prototype.delete=function(e){var t=jo(this,e).delete(e);return this.size-=t?1:0,t},mn.prototype.get=function(e){return jo(this,e).get(e)},mn.prototype.has=function(e){return jo(this,e).has(e)},mn.prototype.set=function(e,t){var r=jo(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(e){return this.__data__.set(e,a),this},wn.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.clear=function(){this.__data__=new gn,this.size=0},_n.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},_n.prototype.get=function(e){return this.__data__.get(e)},_n.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.set=function(e,t){var r=this.__data__;if(r instanceof gn){var n=r.__data__;if(!Jr||n.length0&&r(a)?t>1?Fn(a,t-1,r,n,i):Qt(i,a):n||(i[i.length]=a)}return i}var Wn=so(),qn=so(!0);function Vn(e,t){return e&&Wn(e,t,nc)}function Gn(e,t){return e&&qn(e,t,nc)}function Yn(e,t){return Yt(t,function(t){return Sa(e[t])})}function Xn(e,t){for(var r=0,i=(t=qi(t,e)).length;null!=e&&rt}function $n(e,t){return null!=e&&ut.call(e,t)}function ei(e,t){return null!=e&&t in tt(e)}function ti(e,t,r){for(var i=r?Jt:Xt,o=e[0].length,s=e.length,a=s,c=Je(s),f=1/0,u=[];a--;){var h=e[a];a&&t&&(h=Zt(h,pr(t))),f=Wr(h.length,f),c[a]=!r&&(t||o>=120&&h.length>=120)?new wn(a&&h):n}h=e[0];var l=-1,d=c[0];e:for(;++l=a)return c;var f=r[n];return c*("desc"==f?-1:1)}}return e.index-t.index}(e,t,r)})}function vi(e,t,r){for(var n=-1,i=t.length,o={};++n-1;)a!==e&&Lt.call(a,c,1),Lt.call(e,c,1);return e}function mi(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;qo(i)?Lt.call(e,i,1):Di(e,i)}}return e}function wi(e,t){return e+Dr(Gr()*(t-e+1))}function _i(e,t){var r="";if(!e||t<1||t>O)return r;do{t%2&&(r+=e),(t=Dr(t/2))&&(e+=e)}while(t);return r}function Ei(e,t){return is($o(e,t,Bc),e+"")}function Si(e){return Sn(lc(e))}function ki(e,t){var r=lc(e);return as(r,Mn(t,0,r.length))}function Ai(e,t,r,i){if(!Ia(e))return e;for(var o=-1,s=(t=qi(t,e)).length,a=s-1,c=e;null!=c&&++oi?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Je(i);++n>>1,s=e[o];null!==s&&!Ra(s)&&(r?s<=t:s=i){var u=t?null:Eo(e);if(u)return Ir(u);a=!1,o=br,f=new wn}else f=t?[]:c;e:for(;++n=i?e:Bi(e,t,r)}var Yi=Mr||function(e){return Pt.clearTimeout(e)};function Xi(e,t){if(t)return e.slice();var r=e.length,n=Bt?Bt(r):new e.constructor(r);return e.copy(n),n}function Ji(e){var t=new e.constructor(e.byteLength);return new It(t).set(new It(e)),t}function Zi(e,t){var r=t?Ji(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Qi(e,t){if(e!==t){var r=e!==n,i=null===e,o=e==e,s=Ra(e),a=t!==n,c=null===t,f=t==t,u=Ra(t);if(!c&&!u&&!s&&e>t||s&&a&&f&&!c&&!u||i&&a&&f||!r&&f||!o)return 1;if(!i&&!s&&!u&&e1?r[o-1]:n,a=o>2?r[2]:n;for(s=e.length>3&&"function"==typeof s?(o--,s):n,a&&Vo(r[0],r[1],a)&&(s=o<3?n:s,o=1),t=tt(t);++i-1?o[s?t[a]:a]:n}}function ho(e){return Bo(function(t){var r=t.length,i=r,o=yn.prototype.thru;for(e&&t.reverse();i--;){var a=t[i];if("function"!=typeof a)throw new it(s);if(o&&!c&&"wrapper"==Mo(a))var c=new yn([],!0)}for(i=c?i:r;++i1&&g.reverse(),h&&fc))return!1;var u=s.get(e);if(u&&s.get(t))return u==t;var h=-1,l=!0,y=r&p?new wn:n;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(Le,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return qt(N,function(r){var n="_."+r[0];t&r[1]&&!Xt(e,n)&&e.push(n)}),e.sort()}(function(e){var t=e.match(je);return t?t[1].split(De):[]}(n),r)))}function ss(e){var t=0,r=0;return function(){var i=qr(),o=T-(i-r);if(r=i,o>0){if(++t>=x)return arguments[0]}else t=0;return e.apply(n,arguments)}}function as(e,t){var r=-1,i=e.length,o=i-1;for(t=t===n?i:t;++r1?e[t-1]:n;return Ps(e,r="function"==typeof r?(e.pop(),r):n)});function Ns(e){var t=ln(e);return t.__chain__=!0,t}function Us(e,t){return t(e)}var Hs=Bo(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,o=function(t){return On(t,e)};return!(t>1||this.__actions__.length)&&i instanceof bn&&qo(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:Us,args:[o],thisArg:n}),new yn(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e})):this.thru(o)});var Ks=no(function(e,t,r){ut.call(e,r)?++e[r]:Pn(e,r,1)});var zs=uo(ys),Fs=uo(bs);function Ws(e,t){return(ba(e)?qt:Nn)(e,Lo(t,3))}function qs(e,t){return(ba(e)?Vt:Un)(e,Lo(t,3))}var Vs=no(function(e,t,r){ut.call(e,r)?e[r].push(t):Pn(e,r,[t])});var Gs=Ei(function(e,t,r){var n=-1,i="function"==typeof t,o=ga(e)?Je(e.length):[];return Nn(e,function(e){o[++n]=i?Ft(t,e,r):ri(e,t,r)}),o}),Ys=no(function(e,t,r){Pn(e,r,t)});function Xs(e,t){return(ba(e)?Zt:hi)(e,Lo(t,3))}var Js=no(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var Zs=Ei(function(e,t){if(null==e)return[];var r=t.length;return r>1&&Vo(e,t[0],t[1])?t=[]:r>2&&Vo(t[0],t[1],t[2])&&(t=[t[0]]),bi(e,Fn(t,1),[])}),Qs=Rr||function(){return Pt.Date.now()};function $s(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,ko(e,E,n,n,n,n,t)}function ea(e,t){var r;if("function"!=typeof t)throw new it(s);return e=Ha(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var ta=Ei(function(e,t,r){var n=y;if(r.length){var i=Ar(r,Ro(ta));n|=w}return ko(e,n,t,r,i)}),ra=Ei(function(e,t,r){var n=y|b;if(r.length){var i=Ar(r,Ro(ra));n|=w}return ko(t,n,e,r,i)});function na(e,t,r){var i,o,a,c,f,u,h=0,l=!1,d=!1,p=!0;if("function"!=typeof e)throw new it(s);function y(t){var r=i,s=o;return i=o=n,h=t,c=e.apply(s,r)}function b(e){var r=e-u;return u===n||r>=t||r<0||d&&e-h>=a}function v(){var e=Qs();if(b(e))return g(e);f=ns(v,function(e){var r=t-(e-u);return d?Wr(r,a-(e-h)):r}(e))}function g(e){return f=n,p&&i?y(e):(i=o=n,c)}function m(){var e=Qs(),r=b(e);if(i=arguments,o=this,u=e,r){if(f===n)return function(e){return h=e,f=ns(v,t),l?y(e):c}(u);if(d)return f=ns(v,t),y(u)}return f===n&&(f=ns(v,t)),c}return t=za(t)||0,Ia(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Fr(za(r.maxWait)||0,t):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){f!==n&&Yi(f),h=0,i=u=o=f=n},m.flush=function(){return f===n?c:g(Qs())},m}var ia=Ei(function(e,t){return jn(e,1,t)}),oa=Ei(function(e,t,r){return jn(e,za(t)||0,r)});function sa(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new it(s);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(sa.Cache||mn),r}function aa(e){if("function"!=typeof e)throw new it(s);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}sa.Cache=mn;var ca=Vi(function(e,t){var r=(t=1==t.length&&ba(t[0])?Zt(t[0],pr(Lo())):Zt(Fn(t,1),pr(Lo()))).length;return Ei(function(n){for(var i=-1,o=Wr(n.length,r);++i=t}),ya=ni(function(){return arguments}())?ni:function(e){return xa(e)&&ut.call(e,"callee")&&!Mt.call(e,"callee")},ba=Je.isArray,va=Dt?pr(Dt):function(e){return xa(e)&&Zn(e)==se};function ga(e){return null!=e&&Aa(e.length)&&!Sa(e)}function ma(e){return xa(e)&&ga(e)}var wa=Ur||zc,_a=Nt?pr(Nt):function(e){return xa(e)&&Zn(e)==F};function Ea(e){if(!xa(e))return!1;var t=Zn(e);return t==q||t==W||"string"==typeof e.message&&"string"==typeof e.name&&!Ca(e)}function Sa(e){if(!Ia(e))return!1;var t=Zn(e);return t==V||t==G||t==K||t==Q}function ka(e){return"number"==typeof e&&e==Ha(e)}function Aa(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=O}function Ia(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xa(e){return null!=e&&"object"==typeof e}var Ta=Ut?pr(Ut):function(e){return xa(e)&&Ko(e)==Y};function Ba(e){return"number"==typeof e||xa(e)&&Zn(e)==X}function Ca(e){if(!xa(e)||Zn(e)!=Z)return!1;var t=Ct(e);if(null===t)return!0;var r=ut.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var Pa=Ht?pr(Ht):function(e){return xa(e)&&Zn(e)==$};var Oa=Kt?pr(Kt):function(e){return xa(e)&&Ko(e)==ee};function Ma(e){return"string"==typeof e||!ba(e)&&xa(e)&&Zn(e)==te}function Ra(e){return"symbol"==typeof e||xa(e)&&Zn(e)==re}var La=zt?pr(zt):function(e){return xa(e)&&Aa(e.length)&&!!kt[Zn(e)]};var ja=mo(ui),Da=mo(function(e,t){return e<=t});function Na(e){if(!e)return[];if(ga(e))return Ma(e)?Br(e):to(e);if(rr&&e[rr])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[rr]());var t=Ko(e);return(t==Y?Sr:t==ee?Ir:lc)(e)}function Ua(e){return e?(e=za(e))===P||e===-P?(e<0?-1:1)*M:e==e?e:0:0===e?e:0}function Ha(e){var t=Ua(e),r=t%1;return t==t?r?t-r:t:0}function Ka(e){return e?Mn(Ha(e),0,L):0}function za(e){if("number"==typeof e)return e;if(Ra(e))return R;if(Ia(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ia(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Oe,"");var r=Fe.test(e);return r||qe.test(e)?Tt(e.slice(2),r?2:8):ze.test(e)?R:+e}function Fa(e){return ro(e,ic(e))}function Wa(e){return null==e?"":Li(e)}var qa=io(function(e,t){if(Jo(t)||ga(t))ro(t,nc(t),e);else for(var r in t)ut.call(t,r)&&xn(e,r,t[r])}),Va=io(function(e,t){ro(t,ic(t),e)}),Ga=io(function(e,t,r,n){ro(t,ic(t),e,n)}),Ya=io(function(e,t,r,n){ro(t,nc(t),e,n)}),Xa=Bo(On);var Ja=Ei(function(e,t){e=tt(e);var r=-1,i=t.length,o=i>2?t[2]:n;for(o&&Vo(t[0],t[1],o)&&(i=1);++r1),t}),ro(e,Po(e),r),n&&(r=Rn(r,u|h|l,xo));for(var i=t.length;i--;)Di(r,t[i]);return r});var cc=Bo(function(e,t){return null==e?{}:function(e,t){return vi(e,t,function(t,r){return $a(e,r)})}(e,t)});function fc(e,t){if(null==e)return{};var r=Zt(Po(e),function(e){return[e]});return t=Lo(t),vi(e,r,function(e,r){return t(e,r[0])})}var uc=So(nc),hc=So(ic);function lc(e){return null==e?[]:yr(e,nc(e))}var dc=co(function(e,t,r){return t=t.toLowerCase(),e+(r?pc(t):t)});function pc(e){return Ec(Wa(e).toLowerCase())}function yc(e){return(e=Wa(e))&&e.replace(Ge,mr).replace(vt,"")}var bc=co(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),vc=co(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),gc=ao("toLowerCase");var mc=co(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()});var wc=co(function(e,t,r){return e+(r?" ":"")+Ec(t)});var _c=co(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),Ec=ao("toUpperCase");function Sc(e,t,r){return e=Wa(e),(t=r?n:t)===n?function(e){return _t.test(e)}(e)?function(e){return e.match(mt)||[]}(e):function(e){return e.match(Ne)||[]}(e):e.match(t)||[]}var kc=Ei(function(e,t){try{return Ft(e,n,t)}catch(e){return Ea(e)?e:new Qe(e)}}),Ac=Bo(function(e,t){return qt(t,function(t){t=fs(t),Pn(e,t,ta(e[t],e))}),e});function Ic(e){return function(){return e}}var xc=ho(),Tc=ho(!0);function Bc(e){return e}function Cc(e){return ai("function"==typeof e?e:Rn(e,u))}var Pc=Ei(function(e,t){return function(r){return ri(r,e,t)}}),Oc=Ei(function(e,t){return function(r){return ri(e,r,t)}});function Mc(e,t,r){var n=nc(t),i=Yn(t,n);null!=r||Ia(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Yn(t,nc(t)));var o=!(Ia(r)&&"chain"in r&&!r.chain),s=Sa(e);return qt(i,function(r){var n=t[r];e[r]=n,s&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=to(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Qt([this.value()],arguments))})}),e}function Rc(){}var Lc=bo(Zt),jc=bo(Gt),Dc=bo(tr);function Nc(e){return Go(e)?fr(fs(e)):function(e){return function(t){return Xn(t,e)}}(e)}var Uc=go(),Hc=go(!0);function Kc(){return[]}function zc(){return!1}var Fc=yo(function(e,t){return e+t},0),Wc=_o("ceil"),qc=yo(function(e,t){return e/t},1),Vc=_o("floor");var Gc,Yc=yo(function(e,t){return e*t},1),Xc=_o("round"),Jc=yo(function(e,t){return e-t},0);return ln.after=function(e,t){if("function"!=typeof t)throw new it(s);return e=Ha(e),function(){if(--e<1)return t.apply(this,arguments)}},ln.ary=$s,ln.assign=qa,ln.assignIn=Va,ln.assignInWith=Ga,ln.assignWith=Ya,ln.at=Xa,ln.before=ea,ln.bind=ta,ln.bindAll=Ac,ln.bindKey=ra,ln.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ba(e)?e:[e]},ln.chain=Ns,ln.chunk=function(e,t,r){t=(r?Vo(e,t,r):t===n)?1:Fr(Ha(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,s=0,a=Je(jr(i/t));oo?0:o+r),(i=i===n||i>o?o:Ha(i))<0&&(i+=o),i=r>i?0:Ka(i);r>>0)?(e=Wa(e))&&("string"==typeof t||null!=t&&!Pa(t))&&!(t=Li(t))&&Er(e)?Gi(Br(e),0,r):e.split(t,r):[]},ln.spread=function(e,t){if("function"!=typeof e)throw new it(s);return t=null==t?0:Fr(Ha(t),0),Ei(function(r){var n=r[t],i=Gi(r,0,t);return n&&Qt(i,n),Ft(e,this,i)})},ln.tail=function(e){var t=null==e?0:e.length;return t?Bi(e,1,t):[]},ln.take=function(e,t,r){return e&&e.length?Bi(e,0,(t=r||t===n?1:Ha(t))<0?0:t):[]},ln.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?Bi(e,(t=i-(t=r||t===n?1:Ha(t)))<0?0:t,i):[]},ln.takeRightWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3),!1,!0):[]},ln.takeWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3)):[]},ln.tap=function(e,t){return t(e),e},ln.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new it(s);return Ia(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),na(e,t,{leading:n,maxWait:t,trailing:i})},ln.thru=Us,ln.toArray=Na,ln.toPairs=uc,ln.toPairsIn=hc,ln.toPath=function(e){return ba(e)?Zt(e,fs):Ra(e)?[e]:to(cs(Wa(e)))},ln.toPlainObject=Fa,ln.transform=function(e,t,r){var n=ba(e),i=n||wa(e)||La(e);if(t=Lo(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:Ia(e)&&Sa(o)?dn(Ct(e)):{}}return(i?qt:Vn)(e,function(e,n,i){return t(r,e,n,i)}),r},ln.unary=function(e){return $s(e,1)},ln.union=xs,ln.unionBy=Ts,ln.unionWith=Bs,ln.uniq=function(e){return e&&e.length?ji(e):[]},ln.uniqBy=function(e,t){return e&&e.length?ji(e,Lo(t,2)):[]},ln.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?ji(e,n,t):[]},ln.unset=function(e,t){return null==e||Di(e,t)},ln.unzip=Cs,ln.unzipWith=Ps,ln.update=function(e,t,r){return null==e?e:Ni(e,t,Wi(r))},ln.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:Ni(e,t,Wi(r),i)},ln.values=lc,ln.valuesIn=function(e){return null==e?[]:yr(e,ic(e))},ln.without=Os,ln.words=Sc,ln.wrap=function(e,t){return fa(Wi(t),e)},ln.xor=Ms,ln.xorBy=Rs,ln.xorWith=Ls,ln.zip=js,ln.zipObject=function(e,t){return zi(e||[],t||[],xn)},ln.zipObjectDeep=function(e,t){return zi(e||[],t||[],Ai)},ln.zipWith=Ds,ln.entries=uc,ln.entriesIn=hc,ln.extend=Va,ln.extendWith=Ga,Mc(ln,ln),ln.add=Fc,ln.attempt=kc,ln.camelCase=dc,ln.capitalize=pc,ln.ceil=Wc,ln.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=za(r))==r?r:0),t!==n&&(t=(t=za(t))==t?t:0),Mn(za(e),t,r)},ln.clone=function(e){return Rn(e,l)},ln.cloneDeep=function(e){return Rn(e,u|l)},ln.cloneDeepWith=function(e,t){return Rn(e,u|l,t="function"==typeof t?t:n)},ln.cloneWith=function(e,t){return Rn(e,l,t="function"==typeof t?t:n)},ln.conformsTo=function(e,t){return null==t||Ln(e,t,nc(t))},ln.deburr=yc,ln.defaultTo=function(e,t){return null==e||e!=e?t:e},ln.divide=qc,ln.endsWith=function(e,t,r){e=Wa(e),t=Li(t);var i=e.length,o=r=r===n?i:Mn(Ha(r),0,i);return(r-=t.length)>=0&&e.slice(r,o)==t},ln.eq=la,ln.escape=function(e){return(e=Wa(e))&&Se.test(e)?e.replace(_e,wr):e},ln.escapeRegExp=function(e){return(e=Wa(e))&&Pe.test(e)?e.replace(Ce,"\\$&"):e},ln.every=function(e,t,r){var i=ba(e)?Gt:Hn;return r&&Vo(e,t,r)&&(t=n),i(e,Lo(t,3))},ln.find=zs,ln.findIndex=ys,ln.findKey=function(e,t){return nr(e,Lo(t,3),Vn)},ln.findLast=Fs,ln.findLastIndex=bs,ln.findLastKey=function(e,t){return nr(e,Lo(t,3),Gn)},ln.floor=Vc,ln.forEach=Ws,ln.forEachRight=qs,ln.forIn=function(e,t){return null==e?e:Wn(e,Lo(t,3),ic)},ln.forInRight=function(e,t){return null==e?e:qn(e,Lo(t,3),ic)},ln.forOwn=function(e,t){return e&&Vn(e,Lo(t,3))},ln.forOwnRight=function(e,t){return e&&Gn(e,Lo(t,3))},ln.get=Qa,ln.gt=da,ln.gte=pa,ln.has=function(e,t){return null!=e&&zo(e,t,$n)},ln.hasIn=$a,ln.head=gs,ln.identity=Bc,ln.includes=function(e,t,r,n){e=ga(e)?e:lc(e),r=r&&!n?Ha(r):0;var i=e.length;return r<0&&(r=Fr(i+r,0)),Ma(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&or(e,t,r)>-1},ln.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:Ha(r);return i<0&&(i=Fr(n+i,0)),or(e,t,i)},ln.inRange=function(e,t,r){return t=Ua(t),r===n?(r=t,t=0):r=Ua(r),function(e,t,r){return e>=Wr(t,r)&&e=-O&&e<=O},ln.isSet=Oa,ln.isString=Ma,ln.isSymbol=Ra,ln.isTypedArray=La,ln.isUndefined=function(e){return e===n},ln.isWeakMap=function(e){return xa(e)&&Ko(e)==ie},ln.isWeakSet=function(e){return xa(e)&&Zn(e)==oe},ln.join=function(e,t){return null==e?"":Kr.call(e,t)},ln.kebabCase=bc,ln.last=Es,ln.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Ha(r))<0?Fr(i+o,0):Wr(o,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,o):ir(e,ar,o,!0)},ln.lowerCase=vc,ln.lowerFirst=gc,ln.lt=ja,ln.lte=Da,ln.max=function(e){return e&&e.length?Kn(e,Bc,Qn):n},ln.maxBy=function(e,t){return e&&e.length?Kn(e,Lo(t,2),Qn):n},ln.mean=function(e){return cr(e,Bc)},ln.meanBy=function(e,t){return cr(e,Lo(t,2))},ln.min=function(e){return e&&e.length?Kn(e,Bc,ui):n},ln.minBy=function(e,t){return e&&e.length?Kn(e,Lo(t,2),ui):n},ln.stubArray=Kc,ln.stubFalse=zc,ln.stubObject=function(){return{}},ln.stubString=function(){return""},ln.stubTrue=function(){return!0},ln.multiply=Yc,ln.nth=function(e,t){return e&&e.length?yi(e,Ha(t)):n},ln.noConflict=function(){return Pt._===this&&(Pt._=yt),this},ln.noop=Rc,ln.now=Qs,ln.pad=function(e,t,r){e=Wa(e);var n=(t=Ha(t))?Tr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return vo(Dr(i),r)+e+vo(jr(i),r)},ln.padEnd=function(e,t,r){e=Wa(e);var n=(t=Ha(t))?Tr(e):0;return t&&nt){var i=e;e=t,t=i}if(r||e%1||t%1){var o=Gr();return Wr(e+o*(t-e+xt("1e-"+((o+"").length-1))),t)}return wi(e,t)},ln.reduce=function(e,t,r){var n=ba(e)?$t:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Nn)},ln.reduceRight=function(e,t,r){var n=ba(e)?er:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Un)},ln.repeat=function(e,t,r){return t=(r?Vo(e,t,r):t===n)?1:Ha(t),_i(Wa(e),t)},ln.replace=function(){var e=arguments,t=Wa(e[0]);return e.length<3?t:t.replace(e[1],e[2])},ln.result=function(e,t,r){var i=-1,o=(t=qi(t,e)).length;for(o||(o=1,e=n);++iO)return[];var r=L,n=Wr(e,L);t=Lo(t),e-=L;for(var i=dr(n,t);++r=s)return e;var c=r-Tr(i);if(c<1)return i;var f=a?Gi(a,0,c).join(""):e.slice(0,c);if(o===n)return f+i;if(a&&(c+=f.length-c),Pa(o)){if(e.slice(c).search(o)){var u,h=f;for(o.global||(o=rt(o.source,Wa(Ke.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var l=u.index;f=f.slice(0,l===n?c:l)}}else if(e.indexOf(Li(o),c)!=c){var d=f.lastIndexOf(o);d>-1&&(f=f.slice(0,d))}return f+i},ln.unescape=function(e){return(e=Wa(e))&&Ee.test(e)?e.replace(we,Cr):e},ln.uniqueId=function(e){var t=++ht;return Wa(e)+t},ln.upperCase=_c,ln.upperFirst=Ec,ln.each=Ws,ln.eachRight=qs,ln.first=gs,Mc(ln,(Gc={},Vn(ln,function(e,t){ut.call(ln.prototype,t)||(Gc[t]=e)}),Gc),{chain:!1}),ln.VERSION="4.17.11",qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){ln[e].placeholder=ln}),qt(["drop","take"],function(e,t){bn.prototype[e]=function(r){r=r===n?1:Fr(Ha(r),0);var i=this.__filtered__&&!t?new bn(this):this.clone();return i.__filtered__?i.__takeCount__=Wr(r,i.__takeCount__):i.__views__.push({size:Wr(r,L),type:e+(i.__dir__<0?"Right":"")}),i},bn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),qt(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r==B||3==r;bn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Lo(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),qt(["head","last"],function(e,t){var r="take"+(t?"Right":"");bn.prototype[e]=function(){return this[r](1).value()[0]}}),qt(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");bn.prototype[e]=function(){return this.__filtered__?new bn(this):this[r](1)}}),bn.prototype.compact=function(){return this.filter(Bc)},bn.prototype.find=function(e){return this.filter(e).head()},bn.prototype.findLast=function(e){return this.reverse().find(e)},bn.prototype.invokeMap=Ei(function(e,t){return"function"==typeof e?new bn(this):this.map(function(r){return ri(r,e,t)})}),bn.prototype.reject=function(e){return this.filter(aa(Lo(e)))},bn.prototype.slice=function(e,t){e=Ha(e);var r=this;return r.__filtered__&&(e>0||t<0)?new bn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=Ha(t))<0?r.dropRight(-t):r.take(t-e)),r)},bn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},bn.prototype.toArray=function(){return this.take(L)},Vn(bn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=ln[i?"take"+("last"==t?"Right":""):t],s=i||/^find/.test(t);o&&(ln.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof bn,f=a[0],u=c||ba(t),h=function(e){var t=o.apply(ln,Qt([e],a));return i&&l?t[0]:t};u&&r&&"function"==typeof f&&1!=f.length&&(c=u=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,y=c&&!d;if(!s&&u){t=y?t:new bn(this);var b=e.apply(t,a);return b.__actions__.push({func:Us,args:[h],thisArg:n}),new yn(b,l)}return p&&y?e.apply(this,a):(b=this.thru(h),p?i?b.value()[0]:b.value():b)})}),qt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ot[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);ln.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(ba(i)?i:[],e)}return this[r](function(r){return t.apply(ba(r)?r:[],e)})}}),Vn(bn.prototype,function(e,t){var r=ln[t];if(r){var n=r.name+"";(rn[n]||(rn[n]=[])).push({name:t,func:r})}}),rn[lo(n,b).name]=[{name:"wrapper",func:n}],bn.prototype.clone=function(){var e=new bn(this.__wrapped__);return e.__actions__=to(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=to(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=to(this.__views__),e},bn.prototype.reverse=function(){if(this.__filtered__){var e=new bn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},bn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=ba(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},ln.prototype.plant=function(e){for(var t,r=this;r instanceof pn;){var i=hs(r);i.__index__=0,i.__values__=n,t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},ln.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof bn){var t=e;return this.__actions__.length&&(t=new bn(this)),(t=t.reverse()).__actions__.push({func:Us,args:[Is],thisArg:n}),new yn(t,this.__chain__)}return this.thru(Is)},ln.prototype.toJSON=ln.prototype.valueOf=ln.prototype.value=function(){return Hi(this.__wrapped__,this.__actions__)},ln.prototype.first=ln.prototype.head,rr&&(ln.prototype[rr]=function(){return this}),ln}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Pt._=Pr,define(function(){return Pr})):Mt?((Mt.exports=Pr)._=Pr,Ot._=Pr):Pt._=Pr}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],263:[function(e,t,r){"use strict";var n=e("inherits"),i=e("hash-base"),Buffer=e("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(e,t){return e<>>32-t}function c(e,t,r,n,i,o,s){return a(e+(t&r|~t&n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return a(e+(t&n|r&~n)+i+o|0,s)+t|0}function u(e,t,r,n,i,o,s){return a(e+(t^r^n)+i+o|0,s)+t|0}function h(e,t,r,n,i,o,s){return a(e+(r^(t|~n))+i+o|0,s)+t|0}n(s,i),s.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=u(n=u(n=u(n=u(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),s,r,e[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),s,r,e[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),s,r,e[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),s,r,e[15],1236535329,22),i=f(i,s=f(s,r=f(r,n,i,s,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),s,r,e[0],3921069994,20),i=f(i,s=f(s,r=f(r,n,i,s,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),s,r,e[4],3889429448,20),i=f(i,s=f(s,r=f(r,n,i,s,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),s,r,e[8],1163531501,20),i=f(i,s=f(s,r=f(r,n,i,s,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),s,r,e[12],2368359562,20),i=u(i,s=u(s,r=u(r,n,i,s,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),s,r,e[14],4259657740,23),i=u(i,s=u(s,r=u(r,n,i,s,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),s,r,e[10],3200236656,23),i=u(i,s=u(s,r=u(r,n,i,s,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),s,r,e[6],76029189,23),i=u(i,s=u(s,r=u(r,n,i,s,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),s,r,e[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),s,r,e[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),s,r,e[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),s,r,e[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=s},{"hash-base":243,inherits:259,"safe-buffer":322}],264:[function(e,t,r){(function(Buffer){t.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var r=e.length,n=e.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),s=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var f=e.shrn(c),u=a.toRed(o);t>0;t--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(f);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var d=1;d0;t--){var u=this._randrange(new n(2),s),h=e.gcd(u);if(0!==h.cmpn(1))return h;var l=u.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],268:[function(e,t,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(e,t,r){if(!(e0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===f&&!1===isNaN(e))return t.long?c(r=e,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],269:[function(e,t,r){(function(Buffer){var t=e("create-hmac"),n=Math.pow(2,30)-1;function i(e,r,i,o,s){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(i<0)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(o<0||o>n)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(e)||(e=new Buffer(e,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,f,u=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=u;d++){l.writeUInt32BE(d,r.length);var p=t(s,e).update(l).digest();a||(a=p.length,f=new Buffer(a),c=o-((u=Math.ceil(o/a))-1)*a),p.copy(f,0,0,a);for(var y=1;y1)for(var r=1;rd||new s(t).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?f(new s(t),l):a(t,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===u)return function(e,t){var r=e.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==t[0])throw new Error("decryption error");var a=t.slice(1,s+1),f=t.slice(s+1),u=o(a,i(f,s)),h=o(f,i(u,r-s-1));if(function(e,t){e=Buffer.from(e),t=Buffer.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var s=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,h,r);if(3===u)return h;throw new Error("unknown padding")}},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"safe-buffer":322}],295:[function(e,t,r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),s=e("./mgf"),a=e("./xor"),c=e("bn.js"),f=e("./withPublic"),u=e("browserify-rsa"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t,r){var h;h=e.padding?e.padding:r?1:4;var l,d=n(e);if(4===h)l=function(e,t){var r=e.modulus.byteLength(),n=t.length,f=o("sha1").update(Buffer.alloc(0)).digest(),u=f.length,h=2*u;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-u-1,p=i(u),y=a(Buffer.concat([f,l,Buffer.alloc(1,1),t],d),s(p,d)),b=a(p,s(y,u));return new c(Buffer.concat([Buffer.alloc(1),b,y],r))}(d,t);else if(1===h)l=function(e,t,r){var n,o=t.length,s=e.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(e){var t,r=Buffer.allocUnsafe(e),n=0,o=i(2*e),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?u(l,d):f(l,d)}},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,randombytes:306,"safe-buffer":322}],296:[function(e,t,r){var n=e("bn.js"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t){return Buffer.from(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":322}],297:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++ne.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],299:[function(e,t,r){(function(e,n){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof r)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else Q=e()}(function(){"use strict";var t=!1;try{throw new Error}catch(e){t=!!e.stack}var r,i=S(),o=function(){},s=function(){var t={task:void 0,next:null},r=t,i=!1,o=void 0,a=!1;function c(){for(;t.next;){var e=(t=t.next).task;t.task=void 0;var r=t.domain;r&&(t.domain=void 0,r.enter());try{e()}catch(e){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),e;setTimeout(function(){throw e},0)}r&&r.exit()}i=!1}if(s=function(t){r=r.next={task:t,domain:a&&e.domain,next:null},i||(i=!0,o())},void 0!==e&&e.nextTick)a=!0,o=function(){e.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var f=new MessageChannel;f.port1.onmessage=function(){o=u,f.port1.onmessage=c,c()};var u=function(){f.port2.postMessage(0)};o=function(){setTimeout(c,0),u()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(e){return function(){return a.apply(e,arguments)}}var f,u=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(t)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=_(e[0].indexOf("@")>0?e[1]:e[2]);if(!n)return;return r=n[0],n[1]}}function k(e){return P(e)?e:O(e)?(t=e,r=A(),s(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):K(e);var t,r}function A(){var e,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(t,i,o){var a=u(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){e.promiseDispatch.apply(e,a)})},o.valueOf=function(){if(r)return o;var t=C(e);return P(t)&&(e=t),t},o.inspect=function(){return e?e.inspect():{state:"pending"}},k.longStackSupport&&t)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1)}function a(t){e=t,o.source=t,h(r,function(e,r){s(function(){t.promiseDispatch.apply(t,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(t){e||a(k(t))},i.fulfill=function(t){e||a(K(t))},i.reject=function(t){e||a(H(t))},i.notify=function(t){e||h(n,function(e,r){s(function(){r(t)})},void 0)},i}function I(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=A();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function x(e){return I(function(t,r){for(var n=0,i=e.length;n2?e.resolve(u(arguments,1)):e.resolve(r)}},k.Promise=I,k.promise=I,I.race=x,I.all=W,I.reject=H,I.resolve=k,k.passByCopy=function(e){return e},T.prototype.passByCopy=function(){return this},k.join=function(e,t){return k(e).join(t)},T.prototype.join=function(e){return k([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},k.race=x,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(e,t,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return H(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){w(e,n);try{return t(e)}catch(e){return H(e)}}return H(e)}(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(n=!0,!k.onerror)throw e;k.onerror(e)}n||i.notify(t)}]),i.promise},k.when=B,T.prototype.thenResolve=function(e){return this.then(function(){return e})},k.thenResolve=function(e,t){return k(e).thenResolve(t)},T.prototype.thenReject=function(e){return this.then(function(){throw e})},k.thenReject=function(e,t){return k(e).thenReject(t)},k.nearer=C,k.isPromise=P,k.isPromiseAlike=O,k.isPending=function(e){return P(e)&&"pending"===e.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(e){return!P(e)||"fulfilled"===e.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(e){return P(e)&&"rejected"===e.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var M,R,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(e){var t=T({when:function(t){return t&&function(e){if(N){var t=l(D,e);-1!==t&&(D.splice(t,1),j.splice(t,1))}}(this),t?t(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,t){N&&(D.push(e),t&&void 0!==t.stack?j.push(t.stack):j.push("(no stack) "+t))}(t,e),t}function K(e){return T({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return b(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function z(e,t,r){return k(e).spread(t,r)}function F(e,t,r){return k(e).dispatch(t,r)}function W(e){return B(e,function(e){var t=0,r=A();return h(e,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,B(i,function(n){e[o]=n,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:o,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function q(e){return B(e,function(e){return e=d(e,k),B(W(d(e,function(e){return B(e,o,o)})),function(){return e})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(e){return T({isDef:function(){}},function(t,r){return F(e,t,r)},function(){return k(e).inspect()})},k.spread=z,T.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},k.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=r[e](t)}catch(e){return H(e)}return o.done?o.value:B(o.value,n,i)}try{o=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===v(e)||e instanceof f}(e)?e.value:H(e)}return B(o,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}},k.spawn=function(e){k.done(k.async(e)())},k.return=function(e){throw new f(e)},k.promised=function(e){return function(){return z([this,W(arguments)],function(t,r){return e.apply(t,r)})}},k.dispatch=F,T.prototype.dispatch=function(e,t){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},k.get=function(e,t){return k(e).dispatch("get",[t])},T.prototype.get=function(e){return this.dispatch("get",[e])},k.set=function(e,t,r){return k(e).dispatch("set",[t,r])},T.prototype.set=function(e,t){return this.dispatch("set",[e,t])},k.del=k.delete=function(e,t){return k(e).dispatch("delete",[t])},T.prototype.del=T.prototype.delete=function(e){return this.dispatch("delete",[e])},k.mapply=k.post=function(e,t,r){return k(e).dispatch("post",[t,r])},T.prototype.mapply=T.prototype.post=function(e,t){return this.dispatch("post",[e,t])},k.send=k.mcall=k.invoke=function(e,t){return k(e).dispatch("post",[t,u(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(e){return this.dispatch("post",[e,u(arguments,1)])},k.fapply=function(e,t){return k(e).dispatch("apply",[void 0,t])},T.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},k.try=k.fcall=function(e){return k(e).dispatch("apply",[void 0,u(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,u(arguments)])},k.fbind=function(e){var t=k(e),r=u(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(u(arguments))])}},T.prototype.fbind=function(){var e=this,t=u(arguments);return function(){return e.dispatch("apply",[this,t.concat(u(arguments))])}},k.keys=function(e){return k(e).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=W,T.prototype.all=function(){return W(this)},k.allResolved=(M=q,R="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(R+" is deprecated, use "+L+" instead.",new Error("").stack),M.apply(M,arguments)}),T.prototype.allResolved=function(){return q(this)},k.allSettled=function(e){return k(e).allSettled()},T.prototype.allSettled=function(){return this.then(function(e){return W(d(e,function(e){function t(){return e.inspect()}return(e=k(e)).then(t,t)}))})},k.fail=k.catch=function(e,t){return k(e).then(void 0,t)},T.prototype.fail=T.prototype.catch=function(e){return this.then(void 0,e)},k.progress=function(e,t){return k(e).then(void 0,void 0,t)},T.prototype.progress=function(e){return this.then(void 0,void 0,e)},k.fin=k.finally=function(e,t){return k(e).finally(t)},T.prototype.fin=T.prototype.finally=function(e){return e=k(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},k.done=function(e,t,r,n){return k(e).done(t,r,n)},T.prototype.done=function(t,r,n){var i=function(e){s(function(){if(w(e,o),!k.onerror)throw e;k.onerror(e)})},o=t||r||n?this.then(t,r,n):this;"object"==typeof e&&e&&e.domain&&(i=e.domain.bind(i)),o.then(void 0,i)},k.timeout=function(e,t,r){return k(e).timeout(t,r)},T.prototype.timeout=function(e,t){var r=A(),n=setTimeout(function(){r.reject(new Error(t||"Timed out after "+e+" ms"))},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},k.delay=function(e,t){return void 0===t&&(t=e,e=void 0),k(e).delay(t)},T.prototype.delay=function(e){return this.then(function(t){var r=A();return setTimeout(function(){r.resolve(t)},e),r.promise})},k.nfapply=function(e,t){return k(e).nfapply(t)},T.prototype.nfapply=function(e){var t=A(),r=u(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},k.nfcall=function(e){var t=u(arguments,1);return k(e).nfapply(t)},T.prototype.nfcall=function(){var e=u(arguments),t=A();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},k.nfbind=k.denodeify=function(e){var t=u(arguments,1);return function(){var r=t.concat(u(arguments)),n=A();return r.push(n.makeNodeResolver()),k(e).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var e=u(arguments);return e.unshift(this),k.denodeify.apply(void 0,e)},k.nbind=function(e,t){var r=u(arguments,2);return function(){var n=r.concat(u(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return e.apply(t,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var e=u(arguments,0);return e.unshift(this),k.nbind.apply(void 0,e)},k.nmapply=k.npost=function(e,t,r){return k(e).npost(t,r)},T.prototype.nmapply=T.prototype.npost=function(e,t){var r=u(t||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[e,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(e,t){var r=u(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(e).dispatch("post",[t,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(e){var t=u(arguments,1),r=A();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},k.nodeify=function(e,t){return k(e).nodeify(t)},T.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){s(function(){e(null,t)})},function(t){s(function(){e(t)})})};var V=S();return k})}).call(this,e("_process"),e("timers").setImmediate)},{_process:271,timers:349}],300:[function(e,t,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],301:[function(e,t,r){var n=e("bops"),i=e("./qrcode.js"),o=e("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(e,t,r,n){var o,s,a,c=Array.prototype.slice.call(arguments);if(n=c.pop(),e=c.shift(),t=c.shift(),r=c.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(t,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(e,r,n,i){t=r,o=n,s=e,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var f=new i.QRCode(o,a),u=this.scale||4,h=e.getContext("2d"),l=0;f.addData(t),f.make();var d=this.marginWidth(),p=d;l=this.dataWidth(f)+2*d,this.resetCanvas(e,h,l);for(var y=0,b=f.getModuleCount();y2&&(n=arguments[2]),this.QRVersion(e,n,(o||{}).version,function(t,r,i,o){e=r,level=i,error=t,n=o}),level){try{var s,a=new i.QRCode(level,n),c=(this.scale,0),f=0;a.addData(e),a.make(),c=this.dataWidth(a,1),s=new this.Array(c*c);for(var u=0,h=a.getModuleCount();ue&&e>0&&(e=this.scale*this.marginScaleFactor),e},dataWidth:function(e,t){return e.getModuleCount()*(t||this.scale||4)},resetCanvas:function(e,t,r){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.style.height=e.height=r,e.style.width=e.width=r,this.color.light?(t.fillStyle=this.color.light,t.fillRect(0,0,e.width,e.height)):t.clearRect(0,0,e.width,e.height)}}},{"./qrcapacitytable.js":300,"./qrcode.js":302,bops:91}],302:[function(e,t,r){var n=e("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(e){this.mode=a.MODE_8BIT_BYTE,this.data=e;this.parsedData=n.from(e)}o.prototype={addData:function(e){var t=new s(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(e<0||this.moduleCount<=e||t<0||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var n=-1;n<=7;n++)t+n<=-1||this.moduleCount<=t+n||(this.modules[e+r][t+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=v.getLostPoint(this);(0==r||e>n)&&(e=n,t=r)}return t},setupTimingPattern:function(){for(var e=8;e>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!e&&1==(t>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,n=v.getBCHTypeInfo(r),i=0;i<15;i++){var o=!e&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!e&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var c=!1;o>>i&1)),v.getMask(t,n,s-a)&&(c=!c),this.modules[n][s-a]=c,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(e,t,r){for(var n=_.getRSBlocks(e,t),i=new E,s=0;s8*c)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*c+")");for(i.getLengthInBits()+4<=8*c&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*c||(i.put(o.PAD0,8),i.getLengthInBits()>=8*c));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(e,t){for(var r=0,n=0,o=0,s=new i(t.length),a=new i(t.length),c=0;c=0?d.get(p):0}}var y=0;for(h=0;h=0;)t^=v.G15<=0;)t^=v.G18<>>=1;return t},getPatternPosition:function(e){return v.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case f:return(t+r)%2==0;case u:return t%2==0;case h:return r%3==0;case l:return(t+r)%3==0;case d:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case p:return t*r%2+t*r%3==0;case y:return(t*r%2+t*r%3)%2==0;case b:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)e-=255;return g.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)g.EXP_TABLE[m]=1<>>7-e%8&1)},put:function(e,t){for(var r=0;r>>t-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}}},{bops:91}],303:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var f=e.length;c>0&&f>c&&(f=c);for(var u=0;u=0?(h=y.substr(0,b),l=y.substr(b+1)):(h=y,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],304:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var o=new n.Uint8Array(e);e>0&&i.getRandomValues(o);var s=Buffer.from(o.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:271,"safe-buffer":322}],307:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),s=e("randombytes"),Buffer=o.Buffer,a=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function u(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>a||e>t)throw new RangeError("offset out of range")}function h(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>a)throw new RangeError("buffer too small")}function l(e,r,n,i){if(t.browser){var o=e.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return s(n).copy(e,r),e;s(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return u(t,e.length),h(r,t,e.length),l(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');u(t,e.length),void 0===r&&(r=e.length-t);return h(r,t,e.length),l(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:271,randombytes:306,"safe-buffer":322}],308:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":309}],309:[function(e,t,r){"use strict";var n=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),f=0;f0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):A(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=_?e=_:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(l("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(k,e):k(e))}function k(e){l("emit readable"),e.emit("readable"),B(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(O,t,e))}function O(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function M(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?P(this):S(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&P(this),null;var n,i=t.needReadable;return l("need readable",i),(0===t.length||t.length-e0?C(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&P(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?u:m;function f(t,r){l("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),e.removeListener("close",v),e.removeListener("finish",g),e.removeListener("drain",h),e.removeListener("error",b),e.removeListener("unpipe",f),n.removeListener("end",u),n.removeListener("end",m),n.removeListener("data",y),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function u(){l("onend"),e.end()}o.endEmitted?i.nextTick(c):n.once("end",c),e.on("unpipe",f);var h=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,B(e))}}(n);e.on("drain",h);var d=!1;var p=!1;function y(t){l("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==M(o.pipes,e))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function b(t){l("onerror",t),m(),e.removeListener("error",b),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",g),m()}function g(){l("onfinish"),e.removeListener("close",v),m()}function m(){l("unpipe"),n.unpipe(e)}return n.on("data",y),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",b),e.once("close",v),e.once("finish",g),e.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=b;var f=e("core-util-is");f.inherits=e("inherits");var u={deprecate:e("util-deprecate")},h=e("./internal/streams/stream"),Buffer=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function y(){}function b(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,f=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(f||0===f)?f:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?c(m,e,r,s,i):m(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(t){if(a=a||e("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(t);this._writableState=new b(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function g(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function m(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,g(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,u=r.encoding,h=r.callback;if(g(e,t,!1,t.objectMode?1:f.length,f,u,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}f.inherits(v,h),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===v&&(e&&e._writableState instanceof b)}})):d=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(e)&&(e=function(e){return Buffer.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=y),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":309,"./internal/streams/destroy":315,"./internal/streams/stream":316,_process:271,"core-util-is":137,inherits:259,"process-nextick-args":270,"safe-buffer":322,timers:349,"util-deprecate":358}],314:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,t.copy(r,n),s+=o.data.length,o=o.next;return i},e}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":322,util:104}],315:[function(e,t,r){"use strict";var n=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":270}],316:[function(e,t,r){t.exports=e("events").EventEmitter},{events:239}],317:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":318}],318:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":309,"./lib/_stream_passthrough.js":310,"./lib/_stream_readable.js":311,"./lib/_stream_transform.js":312,"./lib/_stream_writable.js":313}],319:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":318}],320:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":313}],321:[function(e,t,r){"use strict";var Buffer=e("buffer").Buffer,n=e("inherits"),i=e("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],u=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(e,t){return e<>>32-t}function p(e,t,r,n,i,o,s,a){return d(e+(t^r^n)+o+s|0,a)+i|0}function y(e,t,r,n,i,o,s,a){return d(e+(t&r|~t&n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return d(e+((t|~r)^n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return d(e+(t&n|r&~n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return d(e+(t^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var I,x;A<16?(I=p(r,n,i,l,m,e[s[A]],u[0],c[A]),x=g(w,_,E,S,k,e[a[A]],h[0],f[A])):A<32?(I=y(r,n,i,l,m,e[s[A]],u[1],c[A]),x=v(w,_,E,S,k,e[a[A]],h[1],f[A])):A<48?(I=b(r,n,i,l,m,e[s[A]],u[2],c[A]),x=b(w,_,E,S,k,e[a[A]],h[2],f[A])):A<64?(I=v(r,n,i,l,m,e[s[A]],u[3],c[A]),x=y(w,_,E,S,k,e[a[A]],h[3],f[A])):(I=g(r,n,i,l,m,e[s[A]],u[4],c[A]),x=p(w,_,E,S,k,e[a[A]],h[4],f[A])),r=m,m=l,l=d(i,10),i=n,n=I,w=k,k=S,S=d(E,10),E=_,_=x}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=l},{buffer:131,"hash-base":243,inherits:259}],322:[function(e,t,r){var n=e("buffer"),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?t.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:131}],323:[function(e,t,r){"use strict";t.exports=e("./lib")(e("./lib/elliptic"))},{"./lib":327,"./lib/elliptic":326}],324:[function(e,t,r){(function(Buffer){"use strict";var e=Object.prototype.toString;r.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},r.isBoolean=function(t,r){if("[object Boolean]"!==e.call(t))throw TypeError(r)},r.isBuffer=function(e,t){if(!Buffer.isBuffer(e))throw TypeError(t)},r.isFunction=function(t,r){if("[object Function]"!==e.call(t))throw TypeError(r)},r.isNumber=function(t,r){if("[object Number]"!==e.call(t))throw TypeError(r)},r.isObject=function(t,r){if("[object Object]"!==e.call(t))throw TypeError(r)},r.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},r.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},r.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},r.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":260}],325:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var n=Buffer.from(r?i:o);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[i]&&!(128&t[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),e.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(t.slice(i),o.slice(a))},r.signatureImport=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(e);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(e){return}return i.r.copy(t,32-i.r.length),i.s.copy(r,32-i.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var o=e[i++];if(!(128&o&&(i+=o-128)>n)&&2===e[i++]){var s=e[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+e[i]}if(!(s>n-i)){var a=i;if(i+=s,2===e[i++]){var c=e[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+e[i]}if(!(c>n-i)){var f=i;for(i+=c;s>0&&0===e[a];s-=1,a+=1);if(!(s>32)){var u=e.slice(a,a+s);for(u.copy(t,32-u.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var h=e.slice(f,f+c);return h.copy(r,32-h.length),{r:t,s:r}}}}}}}}}},{bip66:40,"safe-buffer":322}],326:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("create-hash"),i=e("bn.js"),o=e("elliptic").ec,s=e("../messages.json"),a=new o("secp256k1"),c=a.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new i(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new i(t),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new i(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new i(e);return t.isZero()?Buffer.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(e){var t=new i(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(c.g.mul(t).add(n.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(e);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new i(t).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new i(e.r);t.cmp(c.n)>=0&&(t=new i(0));var r=new i(e.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([t.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(e,t,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(e,t,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var f=new i(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var u=a.sign(e,t,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([u.r.toArrayLike(Buffer,"be",32),u.s.toArrayLike(Buffer,"be",32)]),recovery:u.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},o=new i(n.r),u=new i(n.s);if(o.cmp(c.n)>=0||u.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===u.cmp(a.nh)||o.isZero()||u.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,n){var o={r:t.slice(0,32),s:t.slice(32,64)},f=new i(o.r),u=new i(o.s);if(f.cmp(c.n)>=0||u.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||u.isZero())throw new Error;var h=a.recoverPubKey(e,o,r);return Buffer.from(h.encode(!0,n))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var i=r.ecdhUnsafe(e,t,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(t);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":328,"bn.js":90,"create-hash":139,elliptic:221,"safe-buffer":322}],327:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function s(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=e.privateKeyExport(t,r);return i.privateKeyExport(t,a,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":322}],330:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,s,a)+u+r[l]+o[d];u=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],332:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function u(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),y=c(n)+u(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],333:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=a},{"./hash":329,"./sha256":334,inherits:259,"safe-buffer":322}],334:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function l(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,y=0|this._g,b=0|this._h,v=0;v<16;++v)r[v]=e.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((t=r[v-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var g=0;g<64;++g){var m=b+h(d)+c(d,p,y)+o[g]+r[g]|0,w=u(n)+f(n,i,s)|0;b=y,y=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],335:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=a},{"./hash":329,"./sha512":336,inherits:259,"safe-buffer":322}],336:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function l(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function b(e,t){return e>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,I=0|this._gl,x=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var B=t[T-30],C=t[T-30+1],P=l(B,C),O=d(C,B),M=p(B=t[T-4],C=t[T-4+1]),R=y(C,B),L=t[T-14],j=t[T-14+1],D=t[T-32],N=t[T-32+1],U=O+j|0,H=P+L+b(U,O)|0;H=(H=H+M+b(U=U+R|0,R)|0)+D+b(U=U+N|0,N)|0,t[T]=H,t[T+1]=U}for(var K=0;K<160;K+=2){H=t[K],U=t[K+1];var z=f(r,n,i),F=f(w,_,E),W=u(r,w),q=u(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],J=c(a,v,g),Z=c(k,A,I),Q=x+G|0,$=m+V+b(Q,x)|0;$=($=($=$+J+b(Q=Q+Z|0,Z)|0)+Y+b(Q=Q+X|0,X)|0)+H+b(Q=Q+U|0,U)|0;var ee=q+F|0,te=W+z+b(ee,q)|0;m=g,x=I,g=v,I=A,v=a,A=k,a=s+$+b(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+te+b(w=Q+ee|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+I|0,this._hl=this._hl+x|0,this._ah=this._ah+r+b(this._al,w)|0,this._bh=this._bh+n+b(this._bl,_)|0,this._ch=this._ch+i+b(this._cl,E)|0,this._dh=this._dh+s+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,k)|0,this._fh=this._fh+v+b(this._fl,A)|0,this._gh=this._gh+g+b(this._gl,I)|0,this._hh=this._hh+m+b(this._hl,x)|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],337:[function(e,t,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};function i(e,t,r){if(4!==t.length)throw new n.exception.invalid("invalid aes block size");var i=e.c[r],o=t[0]^i[0],s=t[r?3:1]^i[1],a=t[2]^i[2];t=t[r?1:3]^i[3];var c,f,u,h,l=i.length/4-2,d=4,p=[0,0,0,0];e=(c=e.j[r])[0];var y=c[1],b=c[2],v=c[3],g=c[4];for(h=0;h>>24]^y[s>>16&255]^b[a>>8&255]^v[255&t]^i[d],f=e[s>>>24]^y[a>>16&255]^b[t>>8&255]^v[255&o]^i[d+1],u=e[a>>>24]^y[t>>16&255]^b[o>>8&255]^v[255&s]^i[d+2],t=e[t>>>24]^y[o>>16&255]^b[s>>8&255]^v[255&a]^i[d+3],d+=4,o=c,s=f,a=u;for(h=0;4>h;h++)p[r?3&-h:h]=g[o>>>24]<<24^g[s>>16&255]<<16^g[a>>8&255]<<8^g[255&t]^i[d++],c=o,o=s,s=a,a=t,t=c;return p}n.cipher.aes=function(e){this.j[0][0][0]||this.m();var t,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(t=e.length)&&6!==t&&8!==t)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==e%t&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(e){return i(this,e,0)},decrypt:function(e){return i(this,e,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var e,t,r,n,i,o,s,a=this.j[0],c=this.j[1],f=a[4],u=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!f[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,f[t]=o,u[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},n.bitArray={bitSlice:function(e,t,r){return e=n.bitArray.v(e.slice(t/32),32-(31&t)).slice(1),void 0===r?e:n.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(n.bitArray.bitLength(e)!==n.bitArray.bitLength(t))return!1;var r,i=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=n.bitArray.getPartial(o),i.push(n.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},n.codec.utf8String={fromBits:function(e){var t,r,i="",o=n.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],i=0;for(t=0;tn;i++){for(r=!0,t=2;t*t<=i;t++)if(0==i%t){r=!1;break}r&&(8>n&&(this.i[n]=e(Math.pow(i,.5))),this.c[n]=e(Math.pow(i,1/3)),n++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?r=e[t]:(r=e[t+1&15],n=e[t+14&15],r=e[15&t]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+e[15&t]+e[t+9&15]|0),r=r+d+(u>>>6^u>>>11^u>>>25^u<<26^u<<21^u<<7)+(l^u&(h^l))+o[t],d=l,l=h,h=u,u=f+r|0,f=c,c=a,s=r+((a=s)&c^f&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+f|0,i[4]=i[4]+u|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(e){this.c[0]||this.m(),e?(this.f=e.f.slice(0),this.b=e.b.slice(0),this.a=e.a):this.reset()},n.hash.sha512.hash=function(e){return(new n.hash.sha512).update(e).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(e){"string"==typeof e&&(e=n.codec.utf8String.toBits(e));var t,r=this.b=n.bitArray.concat(this.b,e);if(t=this.a,9007199254740991<(e=this.a=t+n.bitArray.bitLength(e)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(r.splice(0,32));return this},finalize:function(){var e,t=this.b,r=this.f;for(e=(t=n.bitArray.concat(t,[n.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.a/4294967296)),t.push(0|this.a);t.length;)this.g(t.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=e(Math.pow(o,.5)),this.i[2*i+1]=t(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=e(Math.pow(o,1/3)),this.c[2*i+1]=t(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7],p=i[8],y=i[9],b=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=e[E]}else n=e;E=s;var S=a,k=c,A=f,I=u,x=h,T=l,B=d,C=p,P=y,O=b,M=v,R=g,L=m,j=w,D=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((H=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(e-7)],z=n[2*(e-16)],F=n[2*(e-16)+1];t=t+K+((r=N+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=H)>>>0>>0?1:0),t+=z+((r+=F)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;K=C&O^~C&R;var W=P&M^~P&L,q=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];N=(N=(N=(N=j+((P<<18|C>>>14)^(P<<14|C>>>18)^(C<<23|P>>>9))+((U=D+((C<<18|P>>>14)^(C<<14|P>>>18)^(P<<23|C>>>9)))>>>0>>0?1:0))+(K+((U=U+W)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+H+((r=F+q)>>>0>>0?1:0),j=R,D=L,R=O,L=M,O=C,M=P,C=T+N+((P=B+U|0)>>>0>>0?1:0)|0,T=I,B=x,I=k,x=A,k=E,A=S,E=N+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,f=i[3]=f+A|0,i[2]=c+k+(f>>>0
>>0?1:0)|0,h=i[5]=h+x|0,i[4]=u+I+(h>>>0>>0?1:0)|0,d=i[7]=d+B|0,i[6]=l+T+(d>>>0>>0?1:0)|0,y=i[9]=y+P|0,i[8]=p+C+(y>>>0

>>0?1:0)|0,v=i[11]=v+M|0,i[10]=b+O+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+R+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(e,t,r,i,o){var s=t.slice(0);return t=n.bitArray,i=i||[],e=n.mode.gcm.s(!0,e,s,i,r,o||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,o){var s=t.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(t=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(t=s,s=[]),e=n.mode.gcm.s(!1,e,s,i,r,o),!a.equal(e.tag,t))throw new n.exception.corrupt("gcm: tag doesn't match");return e.data},A:function(e,t){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=t.slice(0),r=0;128>r;r++){for((i=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(e,t,r){var i,o=r.length;for(t=t.slice(0),i=0;io&&(e=t.hash(e)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),e=new(o=o||n.misc.hmac)(e);var s,a,c,f,u=[],h=n.bitArray;for(f=1;32*u.length<(i||1);f++){for(o=s=e.encrypt(h.concat(t,[f])),a=1;a>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":322}],340:[function(e,t,r){t.exports=function(t){return t.signer=t.signer||e("./lib/signer-hmac-only"),e("./lib/index")(t)}},{"./lib/index":341,"./lib/signer-hmac-only":342}],341:[function(e,t,r){var n=e("util").format;function i(e,t){return e.get?e.get(t):e.getHeader(t)}function o(e){this.name="MissingHeaderError",this.message=e,this.stack=(new Error).stack}function s(e){this.name="InvalidAlgorithmError",this.message=e,this.stack=(new Error).stack}o.prototype=new Error,s.prototype=new Error;var a={"rsa-sha1":!0,"rsa-sha256":!0,"rsa-sha512":!0,"dsa-sha1":!0,"hmac-sha1":!0,"hmac-sha256":!0,"hmac-sha512":!0},c='Signature keyId="%s",algorithm="%s",headers="%s",signature="%s"';function f(e){var t=e.match(/^(?:(.*?):\/\/?)?\/?(?:[^\/\.]+\.)*?([^\/\.]+)\.?([^\/]*)(?:([^?]*)?(?:\?(‌​[^#]*))?)?(.*)?/);return!!t&&t[4]+(t[6]||"")}function u(e){return parseInt(e,10)<10&&(e="0"+e),e}function h(e,t){var r,h;if(t.headers||(t.headers=["date"]),i(e,"Date")||-1===t.headers.indexOf("date")||e.set("Date",["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][(r=new Date).getUTCDay()]+", "+u(r.getUTCDate())+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.getUTCMonth()]+" "+r.getUTCFullYear()+" "+u(r.getUTCHours())+":"+u(r.getUTCMinutes())+":"+u(r.getUTCSeconds())+" GMT"),t.algorithm||(t.algorithm="rsa-sha256"),t.httpVersion||(t.httpVersion="1.1"),t.algorithm=t.algorithm.toLowerCase(),!a[t.algorithm])throw new s(t.algorithm+" is not supported");var l,d="";for(h=0;h=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||u.serialize[i?i.split(";")[0]:""];!o&&y(i)&&(o=u.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&t.setRequestHeader(s,this.header[s]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},u.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(e){c.prototype[e.toLowerCase()]=function(t,r){var n=new u.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,u.get=function(e,t,r){var n=u("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},u.head=function(e,t,r){var n=u("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},u.options=function(e,t,r){var n=u("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.del=g,u.delete=g,u.patch=function(e,t,r){var n=u("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.post=function(e,t,r){var n=u("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.put=function(e,t,r){var n=u("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},{"./agent-base":343,"./is-object":345,"./request-base":346,"./response-base":347,"component-emitter":136}],345:[function(e,t,r){"use strict";t.exports=function(e){return null!==e&&"object"==typeof e}},{}],346:[function(e,t,r){"use strict";var n=e("./is-object");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(e){return this._parser=e,this},i.prototype.responseType=function(e){return this._responseType=e,this},i.prototype.serialize=function(e){return this._serializer=e,this},i.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},i.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~o.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(e,t){r.end(function(r,n){r?t(r):e(n)})})}return this._fullfilledPromise.then(e,t)},i.prototype.catch=function(e){return this.then(void 0,e)},i.prototype.use=function(e){return e(this),this},i.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},i.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},i.prototype.get=function(e){return this._header[e.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(e,t){if(n(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},i.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},i.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var i in t)this.field(e,t[i]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},i.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},i.prototype.redirects=function(e){return this._maxRedirects=e,this},i.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(e){var t=n(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&n(this._data))for(var i in e)this._data[i]=e[i];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},i.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":345}],347:[function(e,t,r){"use strict";var n=e("./utils");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.get=function(e){return this.header[e.toLowerCase()]},i.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=n.type(t);var r=n.params(t);for(var i in r)this[i]=r[i];this.links={};try{e.link&&(this.links=n.parseLinks(e.link))}catch(e){}},i.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},{"./utils":348}],348:[function(e,t,r){"use strict";r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e},{})},r.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},{}],349:[function(e,t,r){(function(t,n){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function f(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new f(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new f(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e.close()},f.prototype.unref=f.prototype.ref=function(){},f.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r.setImmediate="function"==typeof t?t:function(e){var t=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(n?e.apply(null,n):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":271,timers:349}],350:[function(e,t,r){t.exports=function(e,t,r){t=void 0===t?0:t,r=void 0===r?e.length:r;var s,u,h=0,l=0;i.length=n.length=0;for(;h>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-h&&e<=h&&Math.floor(e)===e},Range:function(e,t,n){function i(r,i){return n(r,i)&&r>e&&r>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=h&&Math.floor(e)===e}};for(var d in l)l[d].toJSON=function(e){return e}.bind(null,d);t.exports=l}).call(this,{isBuffer:e("../is-buffer/index.js")})},{"../is-buffer/index.js":260,"./errors":351,"./native":354}],353:[function(e,t,r){var n=e("./errors"),i=e("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,f=n.getValueTypeName,u={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==t.minLength&&r.lengtht.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every(function(t,r){try{return l(e,t,n)}catch(e){throw c(e,r)}})))))}return e=h(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=h(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&l(t,o,n)}catch(e){throw c(e,o,"key")}try{var s=r[o];l(e,s,n)}catch(e){throw c(e,o)}}return!0}return e=h(e),t&&(t=h(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=h(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t){l(t[n],e[n],r)}}catch(e){throw c(e,n)}if(r)for(n in e)if(!t[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.some(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.every(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===f(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return!i.Nil(t)&&(!i.Nil(t.length)&&((!r||t.length===e.length)&&e.every(function(e,n){try{return l(e,t[n],r)}catch(e){throw c(e,n)}})))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function h(e){if(i.String(e))return"?"===e[0]?u.maybe(e.slice(1)):i[e]||u.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return u.arrayOf(e[0])}return u.object(e)}return i.Function(e)?e:u.value(e)}function l(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return l(h(e),t,r)}for(var d in u.oneOf=u.anyOf,i)l[d]=i[d];for(d in u)l[d]=u[d];var p=e("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},{"./errors":351,"./extra":352,"./native":354}],354:[function(e,t,r){var n={Array:function(e){return null!==e&&void 0!==e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return void 0===e||null===e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(e){return e}.bind(null,i);t.exports=n},{}],355:[function(e,t,r){!function(e){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,f=21,u=28,h=f*u,l=c*h,d=function(e,t){this.codepoint=e,this.feature=t},p={},y=[],b=0;b<=255;++b)y[b]=0;var v=[function(e,t,n){return t<60||13311>8&255]>n&&(p[t]=i),i},function(e,t,r){return r?e(t,r):new d(t,null)},function(e,t,r){var n;if(t=55296&&e<=56319},d.isLowSurrogate=function(e){return e>=56320&&e<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var e=this.codepoint-65536;return String.fromCharCode(Math.floor(e/1024)+55296,e%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(e){if(this.prepFeature(),!this.feature[2])return null;var t=this.feature[2][e.codepoint];return t?d.fromCharCode(t):null};var g=function(e){this.str=e,this.cursor=0};g.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=e)break}this.resBuf.splice(r,0,t)}while(0!==e);return this.resBuf.shift()};var _=function(e){this.it=e,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var e=this.it.next();if(!e){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=e.getCanonicalClass(),this.procBuf.push(e);else{var t=this.procBuf[0].getComposite(e),r=e.getCanonicalClass();t&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(f),h=["%","/","?",";","#"].concat(u),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},b={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=e("querystring");function m(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?M+="x":M+=O[R];if(!M.match(d)){var j=C.slice(0,x),D=C.slice(x+1),N=O.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!y[E])for(x=0,P=u.length;x0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],I=(r.host||e.host||S.length>1)&&("."===A||".."===A)||""===A,x=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),x++):x&&(S.splice(T,1),x--);if(!_&&!E)for(;x--;x)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var B,C=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=C?"":S.length?S.shift():"",(B=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift()));return(_=_||r.host&&S.length)&&!C&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":357,punycode:240,querystring:305}],357:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],358:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],359:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],360:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":359,_process:271,dup:27,inherits:259}],361:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=9007199254740991;function i(e){if(e<0||e>n||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}t.exports={encode:function e(t,r,n){if(i(t),r||(r=Buffer.allocUnsafe(o(t))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),t<253?(r.writeUInt8(t,n),e.bytes=1):t<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(t,n+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(t,n+1),e.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(t>>>0,n+1),r.writeUInt32LE(t/4294967296|0,n+5),e.bytes=9),r},decode:function e(t,r){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=t.readUInt8(r);if(n<253)return e.bytes=1,n;if(253===n)return e.bytes=3,t.readUInt16LE(r+1);if(254===n)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var o=t.readUInt32LE(r+1),s=4294967296*t.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":322}],362:[function(e,t,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;t.exports=function(e,t){for(var r,a=Object.keys(o),c=0,f=a.length;c>18&63,r=o>>12&63,n=o>>6&63,i=63&o,h[c++]=a[e]+a[r]+a[n]+a[i]}while(u>16&255,r=s>>8&255,n=255&s,f[c++]=64===i?String.fromCharCode(e):64===o?String.fromCharCode(e,r):String.fromCharCode(e,r,n)}while(u>"),z("/XObject <<"),N.publish("putXobjectDict"),z(">>")},V=function(){!function(){var t,e;for(t in M)M.hasOwnProperty(t)&&((e=M[t]).objectNumber=F(),z("<>"),z("endobj"))}(),N.publish("putResources"),T[2]=m,z("2 0 obj"),z("<<"),W(),z(">>"),z("endobj"),N.publish("postPutResources")},G=function(t,e,r){void 0===B[e]&&(B[e]={}),B[e][r]=t},Y=function(t,r,n,i){var o="F"+(e(M)+1).toString(10),s=M[o]={id:o,PostScriptName:t,fontName:r,fontStyle:n,encoding:i,metadata:{}};return G(o,r,n),N.publish("addFont",s),o},X=function(t,e){return function(t,e){var r,n,i,o,s,a,c,f,h;if(void 0===e&&(e={}),i=e.sourceEncoding?i:"Unicode",s=e.outputEncoding,(e.autoencode||s)&&M[u].metadata&&M[u].metadata[i]&&M[u].metadata[i].encoding&&(o=M[u].metadata[i].encoding,!s&&M[u].encoding&&(s=M[u].encoding),!s&&o.codePages&&(s=o.codePages[0]),"string"==typeof s&&(s=o[s]),s)){for(c=!1,a=[],r=0,n=t.length;r>8&&(c=!0);t=a.join("")}for(r=t.length;void 0===c&&0!==r;)t.charCodeAt(r-1)>>8&&(c=!0),r--;if(c){for(a=e.noBOM?[]:[254,255],r=0,n=t.length;r>8)>>8)throw new Error("Character at position "+r.toString(10)+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(h),a.push(f-(h<<8))}return String.fromCharCode.apply(void 0,a)}return t}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},J=function(){x=!0,A[++k]=[],z(U(C*h)+" w"),z(S),0!==L&&z(L.toString(10)+" J"),0!==j&&z(j.toString(10)+" j"),N.publish("addPage",{pageNumber:k})},Z=function(t,e){var r;void 0===t&&(t=M[u].fontName),void 0===e&&(e=M[u].fontStyle);try{r=B[t][e]}catch(t){r=void 0}if(!r)throw new Error("Unable to look up font label for font '"+t+"', '"+e+"'. Refer to getFontList() for available fonts.");return r},Q=function(){x=!1,I=2,v=[],T=[],z("%PDF-1.3"),function(){var t,e,r,n,i,o;for(p=f*h,b=c*h,t=1;t<=k;t++){if(F(),z("<>"),z("endobj"),e=A[t].join("\n"),F(),w){for(r=[],n=0;n>8&255,o>>16&255,o>>24&255])],e="",r)r.hasOwnProperty(n)&&(e+=String.fromCharCode.apply(null,r[n]));z("<>")}else z("<>");q(e),z("endobj")}for(T[1]=m,z("1 0 obj"),z("<>"),z("endobj")}(),V(),F(),z("<<"),function(){z("/Producer (jsPDF "+r.version+")"),O.title&&z("/Title ("+X(O.title)+")"),O.subject&&z("/Subject ("+X(O.subject)+")"),O.author&&z("/Author ("+X(O.author)+")"),O.keywords&&z("/Keywords ("+X(O.keywords)+")"),O.creator&&z("/Creator ("+X(O.creator)+")");var t=new Date;z("/CreationDate (D:"+[t.getFullYear(),K(t.getMonth()+1),K(t.getDate()),K(t.getHours()),K(t.getMinutes()),K(t.getSeconds())].join("")+")")}(),z(">>"),z("endobj"),F(),z("<<"),z("/Type /Catalog"),z("/Pages 1 0 R"),z("/OpenAction [3 0 R /FitH null]"),z("/PageLayout /OneColumn"),N.publish("putCatalog"),z(">>"),z("endobj");var t,e,n,i=m;for(z("xref"),z("0 "+(I+1)),z("0000000000 65535 f "),t=1;t<=I;t++)z((e=T[t],void 0,((n=e.toFixed(0)).length<10?new Array(11-n.length).join("0")+n:n)+" 00000 n "));return z("trailer"),z("<<"),z("/Size "+(I+1)),z("/Root "+I+" 0 R"),z("/Info "+(I-1)+" 0 R"),z(">>"),z("startxref"),z(i),z("%%EOF"),x=!0,v.join("\n")},$=function(t){var e="S";return"F"===t?e="f":"FD"!==t&&"DF"!==t||(e="B"),e},tt=function(){var t,e,r,n;for(e=(t=Q()).length,r=new Uint8Array(new ArrayBuffer(e)),n=0;nc&&(l=f,f=c,c=l);else{if("l"!==n&&"landscape"!==n)throw"Invalid orientation: "+n;n="l",c>f&&(l=f,f=c,c=l)}for(d in D.internal={pdfEscape:X,getStyle:$,getFont:function(){return M[Z.apply(D,arguments)]},getFontSize:function(){return P},getLineHeight:function(){return P*R},btoa:btoa,write:function(t,e,r,n){z(1===arguments.length?t:Array.prototype.join.call(arguments," "))},getCoordinateString:function(t){return U(t*h)},getVerticalCoordinateString:function(t){return U((c-t)*h)},collections:{},newObject:F,putStream:q,events:N,scaleFactor:h,pageSize:{width:f,height:c},output:function(t,e){return et(t,e)},getNumberOfPages:function(){return A.length-1},pages:A},D.addPage=function(){return J(),this},D.text=function(t,e,r,n,i){if("number"==typeof t){var o=r;r=e,e=t,t=o}"string"==typeof t&&t.match(/[\n\r]/)&&(t=t.split(/\r\n|\r|\n/g)),"number"==typeof n&&(i=n,n=null);var s="",a="Td";if(i){i*=Math.PI/180;var f=Math.cos(i),l=Math.sin(i);s=[U(f),U(l),U(-1*l),U(f),""].join(" "),a="Tm"}if("noBOM"in(n=n||{})||(n.noBOM=!0),"autoencode"in n||(n.autoencode=!0),"string"==typeof t)t=X(t,n);else{if(!(t instanceof Array))throw new Error('Type of text must be string or Array. "'+t+'" is not recognized.');for(var d=t.concat(),p=[],b=d.length;b--;)p.push(X(d.shift(),n));t=p.join(") Tj\nT* (")}return z("BT\n/"+u+" "+P+" Tf\n"+P*R+" TL\n"+E+"\n"+s+U(e*h)+" "+U((c-r)*h)+" "+a+"\n("+t+") Tj\nET"),this},D.line=function(t,e,r,n){return z(U(t*h)+" "+U((c-e)*h)+" m "+U(r*h)+" "+U((c-n)*h)+" l S"),this},D.lines=function(t,e,r,n,i,o){var s,a,u,f,l,d,p,b,y,g,v,m,w;for("number"==typeof t&&(s=t,a=e,t=r,e=s,r=a),i=$(i),n=void 0===n?[1,1]:n,z(H(e*h)+" "+H((c-r)*h)+" m "),u=n[0],f=n[1],d=t.length,m=e,w=r,l=0;l>16&255,e=i>>8&255,r=255&i}return E=0===t&&0===e&&0===r||void 0===e?H(t/255)+" g":[H(t/255),H(e/255),H(r/255),"rg"].join(" "),this},D.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},D.setLineCap=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line cap style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=e,z(e.toString(10)+" J"),this},D.setLineJoin=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line join style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return j=e,z(e.toString(10)+" j"),this},D.output=et,D.save=function(t){D.output("save",t)},r.API)r.API.hasOwnProperty(d)&&("events"===d&&r.API.events.length?function(t,e){var r,n,i;for(i=e.length-1;-1!==i;i--)r=e[i][0],n=e[i][1],t.subscribe.apply(t,[r].concat("function"==typeof n?[n]:n))}(N,r.API.events):D[d]=r.API[d]);return function(){var t,e,r,n,i=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"]];for(t=0,e=i.length;tn&&(i.push(t.slice(u,o)),a=0,u=o),a+=e[o],o++;return u!==o&&i.push(t.slice(u,o)),i}),i=function(t,i,o){o||(o={});var s,a,u,c,f,h=e(" ",o)[0],l=t.split(" "),d=[],p=[d],b=o.textIndent||0,y=0,g=0;for(u=0,c=l.length;ui){if(g>i){for(f=n(s,a,i-(b+y),i),d.push(f.shift()),d=[f.pop()];f.length;)p.push([f.shift()]);g=r(a.slice(s.length-d[0].length))}else d=[s];p.push(d),b=g,y=h}else d.push(s),b+=y+g,y=h;var v=[];for(u=0,c=p.length;u>"),"trns"in t&&t.trns.constructor==Array){for(var o="",s=0,a=t.trns.length;s>"),i(t.data),n("endobj"),"smask"in t){var u="/Predictor 15 /Colors 1 /BitsPerComponent "+t.bpc+" /Columns "+t.w,c={w:t.w,h:t.h,cs:"DeviceGray",bpc:t.bpc,dp:u,data:t.smask};"f"in t&&(c.f=t.f),r.call(this,c)}t.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+t.pal.length+">>"),i(this.arrayBufferToBinaryString(new Uint8Array(t.pal))),n("endobj"))},n=function(){var t=this.internal.collections.addImage_images;for(var e in t)r.call(this,t[e])},i=function(){var t,e=this.internal.collections.addImage_images,r=this.internal.write;for(var n in e)r("/I"+(t=e[n]).i,t.n,"0","R")},o=function(t,e){return t||e||(t=-96,e=-96),t<0&&(t=-1*info.w*72/t/this.internal.scaleFactor),e<0&&(e=-1*info.h*72/e/this.internal.scaleFactor),0===t&&(t=e*info.w/info.h),0===e&&(e=t*info.h/info.w),[t,e]};t.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},t.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},t.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},t.isString=function(t){return"string"==typeof t},t.extractInfoFromBase64DataURI=function(t){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(t)},t.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},t.isArrayBuffer=function(t){return!!this.supportsArrayBuffer()&&t instanceof ArrayBuffer},t.isArrayBufferView=function(t){return!!this.supportsArrayBuffer()&&(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)},t.binaryStringToUint8Array=function(t){for(var e=t.length,r=new Uint8Array(e),n=0;n>18]+n[(258048&e)>>12]+n[(4032&e)>>6]+n[63&e];return 1==s?r+=n[(252&(e=i[a]))>>2]+n[(3&e)<<4]+"==":2==s&&(r+=n[(64512&(e=i[a]<<8|i[a+1]))>>10]+n[(1008&e)>>4]+n[(15&e)<<2]+"="),r},t.createImageInfo=function(t,e,r,n,i,o,s,a,u,c,f,h){var l={alias:a,w:e,h:r,cs:n,bpc:i,i:s,data:t};return o&&(l.f=o),u&&(l.dp=u),c&&(l.trns=c),f&&(l.pal=f),h&&(l.smask=h),l},t.addImage=function(r,s,a,u,c,f,h,l){if("number"==typeof s){var d=f;f=c,c=u,u=a,a=s,s=d||"jpeg"}var p,b,y,g,v,m=function(){var t=this.internal.collections.addImage_images;return t||(this.internal.collections.addImage_images=t={},this.internal.events.subscribe("putResources",n),this.internal.events.subscribe("putXobjectDict",i)),t}.call(this);if((y=l)&&"string"==typeof y&&(y=y.toUpperCase()),l=y in t.image_compression?y:t.image_compression.NONE,s=s.toLowerCase(),function(t){return void 0===t||null===t}(h)&&(h=void 0),"object"==typeof(g=r)&&1===g.nodeType&&(r=function(t,e){var r=document.createElement("canvas");r.width=t.clientWidth||t.width,r.height=t.clientHeight||t.height;var n=r.getContext("2d");if(!n)throw"addImage requires canvas to be supported by browser.";return n.drawImage(t,0,0,r.width,r.height),r.toDataURL("png"==e?"image/png":"image/jpeg")}(r,s)),this.isString(r)){var w=this.extractInfoFromBase64DataURI(r);w?(s=w[2],r=atob(w[3]),this.supportsArrayBuffer()&&(b=r,r=this.binaryStringToUint8Array(r))):255!==r.charCodeAt(0)&&(p=function(t,e){var r;if(e)for(var n in e)if(t===e[n].alias){r=e[n];break}return r}(r,m))}if(v=s,-1===e.indexOf(v))throw new Error("addImage currently only supports formats "+e+", not '"+s+"'");if(function(e){return"function"!=typeof t["process"+e.toUpperCase()]}(s))throw new Error("please ensure that the plugin for '"+s+"' support is added");var _=function(t){var e=0;return t&&(e=Object.keys?Object.keys(t).length:function(t){var e=0;for(var r in t)t.hasOwnProperty(r)&&e++;return e}(t)),e}(m),E=p;if(E||(E=this["process"+s.toUpperCase()](r,_,h,l,b)),!E)throw new Error("An unkwown error occurred whilst processing the image");return function(t,e,r,n,i,s,a){var u=o(r,n),c=this.internal.getCoordinateString,f=this.internal.getVerticalCoordinateString;r=u[0],n=u[1],a[s]=i,this.internal.write("q",c(r),"0 0",c(n),c(t),f(e+n),"cm /I"+i.i,"Do Q")}.call(this,a,u,c,f,E,_,m),this};var s=function(t,e){return t.subarray(e,e+4)};t.processJPEG=function(t,e,r,n,i){var o,a=this.color_spaces.DEVICE_RGB,u=this.decode.DCT_DECODE;return this.isString(t)?(o=function(t){var e;if(255===!t.charCodeAt(0)||216===!t.charCodeAt(1)||255===!t.charCodeAt(2)||224===!t.charCodeAt(3)||!t.charCodeAt(6)==="J".charCodeAt(0)||!t.charCodeAt(7)==="F".charCodeAt(0)||!t.charCodeAt(8)==="I".charCodeAt(0)||!t.charCodeAt(9)==="F".charCodeAt(0)||0===!t.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var r=256*t.charCodeAt(4)+t.charCodeAt(5),n=4,i=t.length;n7)return{width:((e=s(t,i+5))[2]<<8)+e[3],height:(e[0]<<8)+e[1]};i+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")}(t),t=i||this.arrayBufferToBinaryString(t),this.createImageInfo(t,o.width,o.height,a,8,u,e,r)):null)},t.processJPG=function(t,e,r,n,i){return this.processJPEG(t,e,r,n,i)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(t){"use strict";var e=t.document,r=t.URL||t.webkitURL||t,n=e.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in n,o=t.webkitRequestFileSystem,s=t.requestFileSystem||o||t.mozRequestFileSystem,a=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},u=0,c=[],f=function(t,e,r){for(var n=(e=[].concat(e)).length;n--;){var i=t["on"+e[n]];if("function"==typeof i)try{i.call(t,r||t)}catch(t){a(t)}}},h=function(r,a){var h,l,d,p,b,y=this,g=r.type,v=!1,m=function(){var e=(t.URL||t.webkitURL||t).createObjectURL(r);return c.push(e),e},w=function(){f(y,"writestart progress write writeend".split(" "))},_=function(){!v&&h||(h=m()),l&&(l.location.href=h),y.readyState=y.DONE,w()},E=function(t){return function(){if(y.readyState!==y.DONE)return t.apply(this,arguments)}},S={create:!0,exclusive:!1};if(y.readyState=y.INIT,a||(a="download"),i&&(h=m(),n.href=h,n.download=a,p=n,(b=e.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,t,0,0,0,0,0,!1,!1,!1,!1,0,null),p.dispatchEvent(b)))return y.readyState=y.DONE,void w();t.chrome&&g&&"application/octet-stream"!==g&&(d=r.slice||r.webkitSlice,r=d.call(r,0,r.size,"application/octet-stream"),v=!0),o&&"download"!==a&&(a+=".download"),l="application/octet-stream"===g||o?t:t.open(),s?(u+=r.size,s(t.TEMPORARY,u,E(function(t){t.root.getDirectory("saved",S,E(function(t){var e=function(){t.getFile(a,S,E(function(t){t.createWriter(E(function(e){e.onwriteend=function(e){l.location.href=t.toURL(),c.push(t),y.readyState=y.DONE,f(y,"writeend",e)},e.onerror=function(){var t=e.error;t.code!==t.ABORT_ERR&&_()},"writestart progress write abort".split(" ").forEach(function(t){e["on"+t]=y["on"+t]}),e.write(r),y.abort=function(){e.abort(),y.readyState=y.DONE},y.readyState=y.WRITING}),_)}),_)};t.getFile(a,{create:!1},E(function(t){t.remove(),e()}),E(function(t){t.code===t.NOT_FOUND_ERR?e():_()}))}),_)}),_)):_()},l=h.prototype;return l.abort=function(){this.readyState=this.DONE,f(this,"abort")},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,t.addEventListener("unload",function(){for(var t=c.length;t--;){var e=c[t];"string"==typeof e?r.revokeObjectURL(e):e.remove()}c.length=0},!1),function(t,e){return new h(t,e)}}(self);!function(t){"use strict";var e=function(){var t="function"==typeof Deflater;if(!t)throw new Error("requires deflate.js for compression");return t},r=function(e,r,s,h){var l=5,d=u;switch(h){case t.image_compression.FAST:l=3,d=a;break;case t.image_compression.MEDIUM:l=6,d=c;break;case t.image_compression.SLOW:l=9,d=f}e=o(e,r,s,d);var p=new Uint8Array(n(l)),b=i(e),y=new Deflater(l),g=y.append(e),v=y.flush(),m=p.length+g.length+v.length,w=new Uint8Array(m+4);return w.set(p),w.set(g,p.length),w.set(v,p.length+g.length),w[m++]=b>>>24&255,w[m++]=b>>>16&255,w[m++]=b>>>8&255,w[m++]=255&b,t.arrayBufferToBinaryString(w)},n=function(t,e){var r=Math.LOG2E*Math.log(32768)-8<<4|8,n=r<<8;return n|=Math.min(3,(e-1&255)>>1)<<6,n|=0,[r,255&(n+=31-n%31)]},i=function(t,e){for(var r,n=1,i=0,o=t.length,s=0;o>0;){o-=r=o>e?e:o;do{i+=n+=t[s++]}while(--r);n%=65521,i%=65521}return(i<<16|n)>>>0},o=function(t,e,r,n){for(var i,o,s,a=t.length/e,u=new Uint8Array(t.length+a),c=l(),f=0;f>>1)&255;return o},f=function(t,e,r){var n,i,o,s,a=[],u=0,c=t.length;for(a[0]=4;u>>g&255,g+=u.bits;w[E]=k>>>g&255}if(16===u.bits){v=(M=new Uint32Array(u.decodePixels().buffer)).length,m=new Uint8Array(v*(32/u.pixelBitlength)*u.colors),w=new Uint8Array(v*(32/u.pixelBitlength));for(var k,A=u.colors>1,I=(E=0,S=0,0);E>>0&255,A&&(m[S++]=k>>>16&255,k=M[E++],m[S++]=k>>>0&255),w[I++]=k>>>16&255;y=8}s!==t.image_compression.NONE&&e()?(n=r(m,u.width*u.colors,u.colors,s),d=r(w,u.width,1,s)):(n=m,d=w,b=null)}if(3===u.colorType&&(p=this.color_spaces.INDEXED,l=u.palette,u.transparency.indexed)){var x=u.transparency.indexed,T=0;for(E=0,v=x.length;En&&(r=n)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(e,r)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,r){for(var n=t+e;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,r)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),FlateStream=function(){var t=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),e=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),n=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function o(t){throw new Error(t)}function s(t){var e=0,r=t[e++],n=t[e++];-1!=r&&-1!=n||o("Invalid header in flate stream"),8!=(15&r)&&o("Unknown compression method in flate stream"),((r<<8)+n)%31!=0&&o("Bad FCHECK in flate stream"),32&n&&o("FDICT bit set in flate stream"),this.bytes=t,this.bytesPos=e,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}return s.prototype=Object.create(DecodeStream.prototype),s.prototype.getBits=function(t){for(var e,r=this.codeSize,n=this.codeBuf,i=this.bytes,s=this.bytesPos;r>t,this.codeSize=r-=t,this.bytesPos=s,e},s.prototype.getCode=function(t){for(var e=t[0],r=t[1],n=this.codeSize,i=this.codeBuf,s=this.bytes,a=this.bytesPos;n>16,h=65535&c;return(0==n||n>f,this.codeSize=n-f,this.bytesPos=a,h},s.prototype.generateHuffmanTable=function(t){for(var e=t.length,r=0,n=0;nr&&(r=t[n]);for(var i=1<>=1;for(n=f;n0;)e[p++]=i}var a=this.getBits(3);if(1&a&&(this.eof=!0),0!=(a>>=1)){var u,c;if(1==a)u=n,c=i;else if(2==a){for(var f=this.getBits(5)+257,h=this.getBits(5)+1,l=this.getBits(4)+4,d=Array(t.length),p=0;p=w&&(w=(C=this.ensureBuffer(_+1)).length),C[_++]=E;else{if(256==E)return void(this.bufferLength=_);var S=(E=e[E-=257])>>16;S>0&&(S=this.getBits(S));y=(65535&E)+S;E=this.getCode(c),(S=(E=r[E])>>16)>0&&(S=this.getBits(S));var k=(65535&E)+S;_+y>=w&&(w=(C=this.ensureBuffer(_+y)).length);for(var A=0;Ae;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((f=n-this.transparency.indexed.length)>0)for(d=0;0<=f?df;0<=f?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":a=(h=this.read(e)).indexOf(0),u=String.fromCharCode.apply(String,h.slice(0,a)),this.text[u]=String.fromCharCode.apply(String,h.slice(a+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return n.load=function(t,e,r){var i;return"function"==typeof e&&(r=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new n(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof r?r(t):void 0},i.send(null)},0,1,2,0,1,n.prototype.read=function(t){var e,r;for(r=[],e=0;0<=t?et;0<=t?++e:--e)r.push(this.data[this.pos++]);return r},n.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.decodePixels=function(t){var e,r,n,i,o,s,a,u,c,f,h,l,d,p,b,y,g,v,m,w,_,E,S;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new FlateStream(t)).getBytes(),y=(l=this.pixelBitlength/8)*this.width,d=new Uint8Array(y*this.height),s=t.length,b=0,p=0,r=0;p1&&r/i0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=g.AES.encrypt(t.secret,t.passphrase).toString(g.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=g.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(g.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=g.AES.encrypt(t.secret,t.recoverySecret).toString(g.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,g,v,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=g,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function g(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(g,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,g=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?g.splice(r.random(0,g.length),0,n):g.push(n)}t()},function(t){g.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new u.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&g(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&g(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=g,l.ok=v,l.equal=function(t,e,r){t!=e&&g(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&g(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||g(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||g(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&g(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&g(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&g(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&g(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||g(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!g(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return g(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),x(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function g(t){return"string"==typeof t}function v(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=g,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),I[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(g),o.filterSeries=p(g),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(c,v),v.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,g,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,g=t.t-1,v=!0,m=new BigInteger;for(i=l(t[g])-1;g>=0;){for(i>=u?b=t[g]>>i-u&c:(b=(t[g]&(1<0&&(b|=t[g-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--g),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;g>=0&&0==(t[g]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^g[u>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^g[e>>8&255]^v[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var g=t("./templates");for(var v in g)e.exports[v]=g[v]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),g=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:g};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function g(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,v=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!g(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),v&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,g,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,g=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(g=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,g=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,g=u,v=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,g=u=h.P2PKH,v=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}g===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=g,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!g(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,g="...",v=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",I="[object Array]",x="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",q="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,J=RegExp(Y.source),Z=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[F]=yt[q]=!0,yt[A]=yt[I]=yt[L]=yt[x]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var gt={};gt[A]=gt[I]=gt[L]=gt[x]=gt[T]=gt[j]=gt[D]=gt[N]=gt[U]=gt[H]=gt[P]=gt[C]=gt[R]=gt[O]=gt[K]=gt[z]=gt[F]=gt[q]=!0,gt[M]=gt[B]=gt["[object Map]"]=gt["[object Set]"]=gt["[object WeakMap]"]=!1;var vt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,It=Et[typeof e]&&e&&!e.nodeType&&e,xt=At&&It&&"object"==typeof t&&t;!xt||xt.global!==xt&&xt.window!==xt&&xt.self!==xt||(kt=xt);var Tt=It&&It.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function qt(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!qn(t)){if(t instanceof Le)return t;if(Zt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=xe,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ge(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Jr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function Fr(t,e,i,o,s,p,y,g,v,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,I=!E&&Kr(t),x=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=qt(b,T);if((f-=M.length)=(e=+e)||!ve(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var g=e&u;if(!g&&!Yn(t))throw new It(S);var v=i?i.length:0;if(v||(e&=~(l|d),i=o=null),v-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!g&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],g=(l?t:e)[8],v=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=v)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Zt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Zt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Zr(n)&&(qn(t)||i.nonEnumArgs&&Fn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Zt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=qn(t)?Fe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(qn(t)?qe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(qn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?ze(t,e):sr(t,Rr(e,r,3))}function In(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var xn=Dr(function(t,e,r){Zt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(qn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=xe;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new It(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function g(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),g=n<=0||n>l;g?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return g&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(g=!0,s=t.apply(u,i)),!g||c||o||(i=u=null),s}return g.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},g}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!Fe(t,Yn))throw new It(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new It(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function Fn(t){return Zr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var qn=ye||function(t){return zt(t)&&Zr(t.length)&&$t.call(t)==I||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ve(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Jn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Zn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Jn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Zr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return gr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Zr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Zr(e)&&(qn(t)||je.nonEnumArgs&&Fn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=vn,Oe.chunk=function(t,e,n){e=(n?Jr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Jr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Jr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Zr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return Ir(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Zt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=Fn,Oe.isArray=qn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==x||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Zr(e)&&(qn(t)||ti(t)||Fn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?vr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Zt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Zn(t)&&t!=+t},Oe.isNative=Jn,Oe.isNull=function(t){return null===t},Oe.isNumber=Zn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=Ii,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ve(e))return t;var i=(e-n)/2,o=se(i);return(r=qr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&qr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+qr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Jr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Zr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=gi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Jr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Ze)).imports),i.imports,Ze),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=vi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Jr(t,e,r)&&(e=null);var n=y,i=g;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||qn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=xt[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!qn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[g++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[g++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[g++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[g++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[g++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[g++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[g++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[g++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):g(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},i(I,A),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],g=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,c[r]=v;v=16843009*g^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[g^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],g=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=g,l=v}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],g=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:g}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},g=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=g.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,g.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],g=t[e+6],v=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],I=t[e+15],x=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,x=c(x,T,M,B,s,7,a[0]),T,M,u,12,a[1]),x,T,d,17,a[2]),B,x,p,22,a[3]),M=c(M,B=c(B,x=c(x,T,M,B,b,7,a[4]),T,M,y,12,a[5]),x,T,g,17,a[6]),B,x,v,22,a[7]),M=c(M,B=c(B,x=c(x,T,M,B,m,7,a[8]),T,M,w,12,a[9]),x,T,_,17,a[10]),B,x,E,22,a[11]),M=c(M,B=c(B,x=c(x,T,M,B,S,7,a[12]),T,M,k,12,a[13]),x,T,A,17,a[14]),B,x,I,22,a[15]),M=f(M,B=f(B,x=f(x,T,M,B,u,5,a[16]),T,M,g,9,a[17]),x,T,E,14,a[18]),B,x,s,20,a[19]),M=f(M,B=f(B,x=f(x,T,M,B,y,5,a[20]),T,M,_,9,a[21]),x,T,I,14,a[22]),B,x,b,20,a[23]),M=f(M,B=f(B,x=f(x,T,M,B,w,5,a[24]),T,M,A,9,a[25]),x,T,p,14,a[26]),B,x,m,20,a[27]),M=f(M,B=f(B,x=f(x,T,M,B,k,5,a[28]),T,M,d,9,a[29]),x,T,v,14,a[30]),B,x,S,20,a[31]),M=h(M,B=h(B,x=h(x,T,M,B,y,4,a[32]),T,M,m,11,a[33]),x,T,E,16,a[34]),B,x,A,23,a[35]),M=h(M,B=h(B,x=h(x,T,M,B,u,4,a[36]),T,M,b,11,a[37]),x,T,v,16,a[38]),B,x,_,23,a[39]),M=h(M,B=h(B,x=h(x,T,M,B,k,4,a[40]),T,M,s,11,a[41]),x,T,p,16,a[42]),B,x,g,23,a[43]),M=h(M,B=h(B,x=h(x,T,M,B,w,4,a[44]),T,M,S,11,a[45]),x,T,I,16,a[46]),B,x,d,23,a[47]),M=l(M,B=l(B,x=l(x,T,M,B,s,6,a[48]),T,M,v,10,a[49]),x,T,A,15,a[50]),B,x,y,21,a[51]),M=l(M,B=l(B,x=l(x,T,M,B,S,6,a[52]),T,M,p,10,a[53]),x,T,_,15,a[54]),B,x,u,21,a[55]),M=l(M,B=l(B,x=l(x,T,M,B,m,6,a[56]),T,M,I,10,a[57]),x,T,g,15,a[58]),B,x,k,21,a[59]),M=l(M,B=l(B,x=l(x,T,M,B,b,6,a[60]),T,M,E,10,a[61]),x,T,d,15,a[62]),B,x,w,21,a[63]),o[0]=o[0]+x|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,I,x,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],I=_=T[4];for(r=0;r<80;r+=1)x=o+t[e+P[r]]|0,x+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?g(s,d,w)+M[3]:v(s,d,w)+M[4],x=(x=m(x|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=x,x=E+t[e+C[r]]|0,x+=r<16?v(S,k,A)+B[0]:r<32?g(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],x=(x=m(x|=0,O[r]))+I|0,E=I,I=A,A=m(k,10),k=S,S=x;x=T[1]+d+A|0,T[1]=T[2]+w+I|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=x},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function g(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+g+c[d-16]}var v=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var g=h[(l+4)%5],v=h[(l+1)%5],m=v.high,w=v.low;for(d=g.high^(m<<1|w>>>31),p=g.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var I=h[0],x=r[0];I.high=x.high,I.low=x.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,g=o.high,v=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,I=h.low,x=l.high,T=l.low,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=I,F=x,q=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),gt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),vt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=F+vt+((ht=q+mt)>>>0>>0?1:0),kt=gt+bt;F=K,q=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0
>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),v=o.low=v+O,o.high=g+R+(v>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),I=h.low=I+z,h.high=A+K+(I>>>0>>0?1:0),T=l.low=T+q,l.high=x+F+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&g(p)&&g(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var g=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(g[1]=e[b].add(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].add(e[y].neg())):(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][I-1>>1]:I<0&&(c=h[u][-I-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),g=new i(1),v=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=g.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,g=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var g=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(g=g.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new f({r:y,s:g,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,g="-",v=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function I(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function x(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+I((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,v,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(g))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,v,m,w,_,E,I=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),v==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,I.push(k(B(p+E%_,0))),u=S(E/_);I.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return x(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return x(t,function(t){return v.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(I,t,e))}function I(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",g),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",v),m()}function v(){l("onfinish"),t.removeListener("close",g),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",g),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;g.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(e){if(a=a||t("./_stream_duplex"),!(d.call(g,this)||this instanceof a))return new g(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(g,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===g&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),g.prototype.destroy=p.destroy,g.prototype._undestroy=p.undestroy,g.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,g=2,v=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,I=30,x="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",g],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",F="[object Boolean]",q="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",J="[object Number]",Z="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",gt="[object Uint32Array]",vt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,It=/<%([\s\S]+?)%>/g,xt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,Ft=/^[-+]0x[0-9a-f]+$/i,qt=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Zt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Zt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ge=RegExp("['’]","g"),ve=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Zt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[gt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[F]=Ae[ut]=Ae[q]=Ae[V]=Ae[G]=Ae[X]=Ae[J]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var Ie={};Ie[H]=Ie[K]=Ie[at]=Ie[ut]=Ie[F]=Ie[q]=Ie[ct]=Ie[ft]=Ie[ht]=Ie[lt]=Ie[dt]=Ie[X]=Ie[J]=Ie[Q]=Ie[tt]=Ie[et]=Ie[rt]=Ie[nt]=Ie[pt]=Ie[bt]=Ie[yt]=Ie[gt]=!0,Ie[V]=Ie[G]=Ie[ot]=!1;var xe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,Fe=De&&De.isTypedArray;function qe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Ze(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+xe[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Ir(t,e){return function(r){return t(e(r))}}function xr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Zt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,xe=Buffer?Buffer.allocUnsafe:n,Be=Ir(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Zt&&Zt.now!==Ce.Date.now&&Zt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,Fr=oe.join,qr=Ir(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Zt.now,Yr=e.parseInt,Xr=te.random,Jr=oe.reverse,Zr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Zr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof gn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new gn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=Fo(t),y=b==G||b==Y;if(Ea(t))return Zi(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!Ie[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case F:case q:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case gt:return $i(t,r);case X:return new s;case J:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var g=s.get(t);if(g)return g;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Je,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Ze,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Jn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Zn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Ze:Je,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function Ii(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function xi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Ji=Lr||function(t){return Ce.clearTimeout(t)};function Zi(t,e){if(e)return t.slice();var r=t.length,n=xe?xe(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=gn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new gn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Je(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new gn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Fs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var qs=lo(gs),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(va(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?qe(e,t,r):ii(t,e,r)}),o}),Js=oo(function(t,e,r){Rn(t,r,e)});function Zs(t,e){return(va(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,Io(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=xr(r,jo(na));n|=_}return Io(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|g;if(r.length){var i=xr(r,jo(ia));n|=_}return Io(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function g(){var t=ta();if(y(t))return v(t);c=os(g,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(g,e),l?b(t):u}(f);if(d)return Ji(c),c=os(g,e),b(f)}return c===n&&(c=os(g,e)),u}return e=qa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(qa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Ji(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:v(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,qa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ga=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},va=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&xa(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||qu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==q};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function Ia(t){return"number"==typeof t&&t==za(t)}function xa(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&Fo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==J}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&Fo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=Fe?yr(Fe):function(t){return Ma(t)&&xa(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=Fo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=qa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function Fa(t){return t?Ln(za(t),0,j):0}function qa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=qt.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):Ft.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Ja=so(function(t,e,r,n){io(e,ou(e),t,n)}),Za=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:gr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function gu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var Iu=ki(function(t,e){try{return qe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),xu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Jn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Jn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=vo(Qe),Nu=vo(Ye),Uu=vo(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Zn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function Fu(){return[]}function qu(){return!1}var Wu=go(function(t,e){return t+e},0),Vu=So("ceil"),Gu=go(function(t,e){return t/e},1),Yu=So("floor");var Xu,Ju=go(function(t,e){return t*e},1),Zu=So("round"),Qu=go(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Ja,pn.at=Za,pn.before=ra,pn.bind=na,pn.bindAll=xu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:Fa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),qe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return va(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:gr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return qi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return qi(t||[],e||[],xi)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=Iu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=qa(r))==r?r:0),e!==n&&(e=(e=qa(e))==e?e:0),Ln(qa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=gu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=qs,pn.findIndex=gs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&qo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&Fo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":Fr.call(t,e)},pn.kebabCase=vu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?Fn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?Fn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),li):n},pn.stubArray=Fu,pn.stubFalse=qu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Ju,pn.nth=function(t,e){return t&&t.length?gi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Pu)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ca(Do(t)))},vn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof vn,c=a[0],f=u||va(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new gn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,g).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new gn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function I(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function x(t){return I(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=I,k.promise=I,I.race=x,I.all=q,I.reject=H,I.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=x,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function F(t,e,r){return k(t).dispatch(e,r)}function q(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(q(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return F(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===g(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,q(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=F,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=q,T.prototype.all=function(){return q(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return q(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=g.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=g.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),g.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=g.G15<=0;)e^=g.G18<>>=1;return e},getPatternPosition:function(t){return g.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return v.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)v.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):I(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?I(t,s,e,!1):P(t,s)):I(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var I,x;A<16?(I=p(r,n,i,l,m,t[s[A]],f[0],u[A]),x=v(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(I=b(r,n,i,l,m,t[s[A]],f[1],u[A]),x=g(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(I=y(r,n,i,l,m,t[s[A]],f[2],u[A]),x=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(I=g(r,n,i,l,m,t[s[A]],f[3],u[A]),x=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(I=v(r,n,i,l,m,t[s[A]],f[4],u[A]),x=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=I,w=k,k=S,S=d(E,10),E=_,_=x}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,g=0;g<16;++g)r[g]=t.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((e=r[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[g-7]+l(r[g-15])+r[g-16];for(var v=0;v<64;++v){var m=y+h(d)+u(d,p,b)+o[v]+r[v]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,g=0|this._fh,v=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,I=0|this._gl,x=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),F=c(w,_,E),q=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],J=u(a,g,v),Z=u(k,A,I),Q=x+G|0,$=m+V+y(Q,x)|0;$=($=($=$+J+y(Q=Q+Z|0,Z)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+F|0,et=q+z+y(tt,W)|0;m=v,x=I,v=g,I=A,g=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+I|0,this._hl=this._hl+x|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+g+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,I)|0,this._hh=this._hh+m+y(this._hl,x)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],g=u[3],v=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^g[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^g[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^g[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^g[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var g=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,x),D=B.slice(x+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(x=0,P=f.length;x0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],I=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,x=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),x++):x&&(S.splice(T,1),x--);if(!_&&!E)for(;x--;x)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u 300) { + // max inputs length + chunk = 300; + } else { + chunk = utxoArray.length; + } + for (i=0,j=utxoArray.length; i= 255) throw new TypeError('Alphabet too long') - - const BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) - - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - - if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') +// @ts-ignore +var _Buffer = require('safe-buffer').Buffer +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } BASE_MAP[xc] = i } - - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { - if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') - if (source.length === 0) return '' - - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length while (pbegin !== pend && source[pbegin] === 0) { pbegin++ zeroes++ } - - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - - // Process the bytes. + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. while (pbegin !== pend) { - let carry = source[pbegin] - - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (256 * b58[it]) >>> 0 - b58[it] = (carry % BASE) >>> 0 + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 carry = (carry / BASE) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i pbegin++ } - - // Skip leading zeroes in base58 result. - let it = size - length - while (it !== size && b58[it] === 0) { - it++ + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ } - - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } return str } - function decodeUnsafe (source) { - if (typeof source !== 'string') throw new TypeError('Expected String') - if (source.length === 0) return Buffer.alloc(0) - - let psz = 0 - - // Skip leading spaces. - if (source[psz] === ' ') return - - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return _Buffer.alloc(0) } + var psz = 0 + // Skip leading spaces. + if (source[psz] === ' ') { return } + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 while (source[psz] === LEADER) { zeroes++ psz++ } - - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - - // Process the characters. + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. while (source[psz]) { - // Decode character - let carry = BASE_MAP[source.charCodeAt(psz)] - - // Invalid character - if (carry === 255) return - - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (BASE * b256[it]) >>> 0 - b256[it] = (carry % 256) >>> 0 + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 carry = (carry / 256) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i psz++ } - - // Skip trailing spaces. - if (source[psz] === ' ') return - - // Skip leading zeroes in b256. - let it = size - length - while (it !== size && b256[it] === 0) { - it++ + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ } - - const vch = Buffer.allocUnsafe(zeroes + (size - it)) + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) vch.fill(0x00, 0, zeroes) - - let j = zeroes - while (it !== size) { - vch[j++] = b256[it++] + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] } - return vch } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) return buffer - + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } throw new Error('Non-base' + BASE + ' character') } - return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } +module.exports = base -},{"safe-buffer":322}],30:[function(require,module,exports){ +},{"safe-buffer":345}],30:[function(require,module,exports){ (function (exports) { 'use strict'; @@ -11775,7 +11908,7 @@ BigInteger.valueOf = nbv module.exports = BigInteger },{"../package.json":35}],33:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ // FIXME: Kind of a weird way to throw exceptions, consider removing var assert = require('assert') var BigInteger = require('./bigi') @@ -11868,8 +12001,8 @@ BigInteger.prototype.toHex = function(size) { return this.toBuffer(size).toString('hex') } -}).call(this,require("buffer").Buffer) -},{"./bigi":32,"assert":24,"buffer":131}],34:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./bigi":32,"assert":24,"buffer":130}],34:[function(require,module,exports){ var BigInteger = require('./bigi') //addons @@ -11878,21 +12011,27 @@ require('./convert') module.exports = BigInteger },{"./bigi":32,"./convert":33}],35:[function(require,module,exports){ module.exports={ - "_from": "bigi@^1.4.0", + "_args": [ + [ + "bigi@1.4.2", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] + ], + "_from": "bigi@1.4.2", "_id": "bigi@1.4.2", "_inBundle": false, "_integrity": "sha1-nGZalfiLiwj8Bc/XMfVhhZ1yWCU=", "_location": "/bigi", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "bigi@^1.4.0", + "raw": "bigi@1.4.2", "name": "bigi", "escapedName": "bigi", - "rawSpec": "^1.4.0", + "rawSpec": "1.4.2", "saveSpec": null, - "fetchSpec": "^1.4.0" + "fetchSpec": "1.4.2" }, "_requiredBy": [ "/bitcoinjs-lib", @@ -11900,15 +12039,12 @@ module.exports={ "/ecurve" ], "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", - "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825", - "_spec": "bigi@^1.4.0", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/bitcoinjs-lib", + "_spec": "1.4.2", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", "bugs": { "url": "https://github.com/cryptocoinjs/bigi/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Big integers.", "devDependencies": { "coveralls": "^2.11.2", @@ -11965,7 +12101,7 @@ module.exports={ } },{}],36:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ var bip39 = require('./lib/index') var sjcl = require('./sjcl') var assert = require('assert') @@ -12005,9 +12141,9 @@ module.exports = { validateMnemonic: bip39.validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"./lib/index":37,"./sjcl":38,"assert":24,"buffer":131}],37:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/index":37,"./sjcl":38,"assert":24,"buffer":130}],37:[function(require,module,exports){ +(function (Buffer){(function (){ var assert = require('assert') var createHash = require('create-hash') var randomBytes = require('randombytes') @@ -12138,8 +12274,8 @@ module.exports = { validateMnemonic: validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"../wordlists/en.json":39,"assert":24,"buffer":131,"create-hash":139,"randombytes":306,"unorm":355}],38:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"../wordlists/en.json":39,"assert":24,"buffer":130,"create-hash":138,"randombytes":327,"unorm":378}],38:[function(require,module,exports){ "use strict";function q(a){throw a;}var u=void 0,v=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl}); sjcl.cipher.aes=function(a){this.o[0][0][0]||this.t();var b,c,d,e,f=this.o[0][4],g=this.o[1];b=a.length;var h=1;4!==b&&(6!==b&&8!==b)&&q(new sjcl.exception.invalid("invalid aes key size"));this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& @@ -12202,7 +12338,7 @@ b.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&b.ct instanceof ArrayBuffer?sjcl q(new sjcl.exception.invalid("json decode: this isn't json!")),null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(d[4]):unescape(d[4]):null!=d[5]&&(b[d[2]]="true"===d[5]);return b},h:function(a,b,c){a===u&&(a={});if(b===u)return a;for(var d in b)b.hasOwnProperty(d)&&(c&&(a[d]!==u&&a[d]!==b[d])&&q(new sjcl.exception.invalid("required parameter overridden")),a[d]=b[d]);return a},la:function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&& a[d]!==b[d]&&(c[d]=a[d]);return c},ka:function(a,b){var c={},d;for(d=0;d {serialized scriptPubKey script} @@ -16543,7 +16679,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":53,"safe-buffer":322,"typeforce":353}],68:[function(require,module,exports){ +},{"../../script":53,"safe-buffer":345,"typeforce":376}],68:[function(require,module,exports){ // OP_HASH160 {scriptHash} OP_EQUAL var bscript = require('../../script') @@ -16579,7 +16715,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],69:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],69:[function(require,module,exports){ module.exports = { output: require('./output') } @@ -16628,7 +16764,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":322,"typeforce":353}],71:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,"typeforce":376}],71:[function(require,module,exports){ arguments[4][56][0].apply(exports,arguments) },{"./input":72,"./output":73,"dup":56}],72:[function(require,module,exports){ // {signature} {pubKey} @@ -16676,7 +16812,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":53,"typeforce":353}],73:[function(require,module,exports){ +},{"../../script":53,"typeforce":376}],73:[function(require,module,exports){ // OP_0 {pubKeyHash} var bscript = require('../../script') @@ -16711,7 +16847,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],74:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],74:[function(require,module,exports){ arguments[4][56][0].apply(exports,arguments) },{"./input":75,"./output":76,"dup":56}],75:[function(require,module,exports){ // {signature} {pubKey} @@ -16759,7 +16895,7 @@ module.exports = { encode: encode } -},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":353}],77:[function(require,module,exports){ +},{"../../script":53,"../../types":79,"bitcoin-ops":41,"typeforce":376}],77:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var bcrypto = require('./crypto') @@ -17309,7 +17445,7 @@ Transaction.prototype.setWitness = function (index, witness) { module.exports = Transaction -},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,"typeforce":353,"varuint-bitcoin":361}],78:[function(require,module,exports){ +},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,"typeforce":376,"varuint-bitcoin":382}],78:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var baddress = require('./address') @@ -18128,7 +18264,7 @@ TransactionBuilder.prototype.__overMaximumFees = function (bytes) { module.exports = TransactionBuilder -},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,"typeforce":353}],79:[function(require,module,exports){ +},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,"typeforce":376}],79:[function(require,module,exports){ var typeforce = require('typeforce') var UINT31_MAX = Math.pow(2, 31) - 1 @@ -18183,8 +18319,8 @@ for (var typeName in typeforce) { module.exports = types -},{"typeforce":353}],80:[function(require,module,exports){ -(function (Buffer){ +},{"typeforce":376}],80:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') var bufferEquals = require('buffer-equals') var createHash = require('create-hash') @@ -18255,8 +18391,8 @@ module.exports = { verify: verify } -}).call(this,require("buffer").Buffer) -},{"bs58check":83,"buffer":131,"buffer-equals":128,"create-hash":139,"secp256k1":323,"varuint-bitcoin":361}],81:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":83,"buffer":130,"buffer-equals":127,"create-hash":138,"secp256k1":347,"varuint-bitcoin":382}],81:[function(require,module,exports){ // base-x encoding // Forked from https://github.com/cryptocoinjs/bs58 // Originally written by Mike Hearn for BitcoinJ @@ -18351,7 +18487,7 @@ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' module.exports = basex(ALPHABET) },{"base-x":81}],83:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ 'use strict' var base58 = require('bs58') @@ -18412,9 +18548,9 @@ module.exports = { decodeRaw: decodeUnsafe } -}).call(this,require("buffer").Buffer) -},{"bs58":82,"buffer":131,"create-hash":139}],84:[function(require,module,exports){ -(function (__dirname){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58":82,"buffer":130,"create-hash":138}],84:[function(require,module,exports){ +(function (__dirname){(function (){ var async = require('async'); var _ = require('lodash'); var fs = require('fs'); @@ -18809,8 +18945,8 @@ BackupGenerator.prototype.generatePDF = function(callback) { module.exports = BackupGenerator; -}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib") -},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,"async":28,"bowser":102,"fs":238,"lodash":89}],85:[function(require,module,exports){ +}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib") +},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,"async":28,"bowser":102,"fs":240,"lodash":89}],85:[function(require,module,exports){ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs" + "4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNr" + @@ -19470,11 +19606,11 @@ QrCode.prototype.toDataURL = function(text, options, cb) { module.exports = new QrCode(); -},{"qrcode-canvas":301}],88:[function(require,module,exports){ +},{"qrcode-canvas":322}],88:[function(require,module,exports){ exports = module.exports = require('./lib/backup_generator'); },{"./lib/backup_generator":84}],89:[function(require,module,exports){ -(function (global){ +(function (global){(function (){ /** * @license * lodash 3.1.0 (Custom Build) @@ -30300,7 +30436,7 @@ exports = module.exports = require('./lib/backup_generator'); } }.call(this)); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],90:[function(require,module,exports){ (function (module, exports) { 'use strict'; @@ -30354,7 +30490,11 @@ exports = module.exports = require('./lib/backup_generator'); var Buffer; try { - Buffer = require('buffer').Buffer; + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } } catch (e) { } @@ -30395,23 +30535,19 @@ exports = module.exports = require('./lib/backup_generator'); var start = 0; if (number[0] === '-') { start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { this.negative = 1; } - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } }; BN.prototype._initNumber = function _initNumber (number, base, endian) { @@ -30487,31 +30623,29 @@ exports = module.exports = require('./lib/backup_generator'); return this.strip(); }; - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // 'A' - 'F' + if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + // '0' - '9' + } else { + return (c - 48) & 0xf; + } + } - // '0' - '9' - } else { - r |= c & 0xf; - } + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } return r; } - BN.prototype._parseHex = function _parseHex (number, start) { + BN.prototype._parseHex = function _parseHex (number, start, endian) { // Create possibly bigger array to ensure that it fits the number this.length = Math.ceil((number.length - start) / 6); this.words = new Array(this.length); @@ -30519,25 +30653,38 @@ exports = module.exports = require('./lib/backup_generator'); this.words[i] = 0; } - var j, w; - // Scan 24-bit chunks and add them to the number + // 24-bits chunks var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } } + this.strip(); }; @@ -30608,6 +30755,8 @@ exports = module.exports = require('./lib/backup_generator'); this._iaddn(word); } } + + this.strip(); }; BN.prototype.copy = function copy (dest) { @@ -33276,7 +33425,13 @@ exports = module.exports = require('./lib/backup_generator'); } else if (cmp > 0) { r.isub(this.p); } else { - r.strip(); + if (r.strip !== undefined) { + // r is BN v4 instance + r.strip(); + } else { + // r is BN v5 instance + r._strip(); + } } return r; @@ -33730,7 +33885,7 @@ exports = module.exports = require('./lib/backup_generator'); }; })(typeof module === 'undefined' || module, this); -},{"buffer":104}],91:[function(require,module,exports){ +},{"buffer":239}],91:[function(require,module,exports){ var proto = {} module.exports = proto @@ -34070,7 +34225,7 @@ function to_base64(buf) { } -},{"base64-js":30,"to-utf8":350}],101:[function(require,module,exports){ +},{"base64-js":30,"to-utf8":373}],101:[function(require,module,exports){ module.exports = { writeUInt8: write_uint8 , writeInt8: write_int8 @@ -34503,9 +34658,7 @@ if (typeof self === 'object') { } } -},{"crypto":104}],104:[function(require,module,exports){ - -},{}],105:[function(require,module,exports){ +},{"crypto":239}],104:[function(require,module,exports){ // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js @@ -34735,7 +34888,7 @@ AES.prototype.scrub = function () { module.exports.AES = AES -},{"safe-buffer":322}],106:[function(require,module,exports){ +},{"safe-buffer":345}],105:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -34854,7 +35007,7 @@ StreamCipher.prototype.setAAD = function setAAD (buf) { module.exports = StreamCipher -},{"./aes":105,"./ghash":110,"./incr32":111,"buffer-xor":130,"cipher-base":135,"inherits":259,"safe-buffer":322}],107:[function(require,module,exports){ +},{"./aes":104,"./ghash":109,"./incr32":110,"buffer-xor":129,"cipher-base":134,"inherits":279,"safe-buffer":345}],106:[function(require,module,exports){ var ciphers = require('./encrypter') var deciphers = require('./decrypter') var modes = require('./modes/list.json') @@ -34869,7 +35022,7 @@ exports.createDecipher = exports.Decipher = deciphers.createDecipher exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"./decrypter":108,"./encrypter":109,"./modes/list.json":119}],108:[function(require,module,exports){ +},{"./decrypter":107,"./encrypter":108,"./modes/list.json":118}],107:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer var MODES = require('./modes') @@ -34995,7 +35148,7 @@ function createDecipher (suite, password) { exports.createDecipher = createDecipher exports.createDecipheriv = createDecipheriv -},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,"evp_bytestokey":237,"inherits":259,"safe-buffer":322}],109:[function(require,module,exports){ +},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,"evp_bytestokey":238,"inherits":279,"safe-buffer":345}],108:[function(require,module,exports){ var MODES = require('./modes') var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer @@ -35111,7 +35264,7 @@ function createCipher (suite, password) { exports.createCipheriv = createCipheriv exports.createCipher = createCipher -},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,"evp_bytestokey":237,"inherits":259,"safe-buffer":322}],110:[function(require,module,exports){ +},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,"evp_bytestokey":238,"inherits":279,"safe-buffer":345}],109:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var ZEROES = Buffer.alloc(16, 0) @@ -35202,7 +35355,7 @@ GHASH.prototype.final = function (abl, bl) { module.exports = GHASH -},{"safe-buffer":322}],111:[function(require,module,exports){ +},{"safe-buffer":345}],110:[function(require,module,exports){ function incr32 (iv) { var len = iv.length var item @@ -35219,7 +35372,7 @@ function incr32 (iv) { } module.exports = incr32 -},{}],112:[function(require,module,exports){ +},{}],111:[function(require,module,exports){ var xor = require('buffer-xor') exports.encrypt = function (self, block) { @@ -35238,7 +35391,7 @@ exports.decrypt = function (self, block) { return xor(out, pad) } -},{"buffer-xor":130}],113:[function(require,module,exports){ +},{"buffer-xor":129}],112:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var xor = require('buffer-xor') @@ -35273,7 +35426,7 @@ exports.encrypt = function (self, data, decrypt) { return out } -},{"buffer-xor":130,"safe-buffer":322}],114:[function(require,module,exports){ +},{"buffer-xor":129,"safe-buffer":345}],113:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -35317,7 +35470,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":322}],115:[function(require,module,exports){ +},{"safe-buffer":345}],114:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -35344,7 +35497,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":322}],116:[function(require,module,exports){ +},{"safe-buffer":345}],115:[function(require,module,exports){ var xor = require('buffer-xor') var Buffer = require('safe-buffer').Buffer var incr32 = require('../incr32') @@ -35376,7 +35529,7 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -},{"../incr32":111,"buffer-xor":130,"safe-buffer":322}],117:[function(require,module,exports){ +},{"../incr32":110,"buffer-xor":129,"safe-buffer":345}],116:[function(require,module,exports){ exports.encrypt = function (self, block) { return self._cipher.encryptBlock(block) } @@ -35385,7 +35538,7 @@ exports.decrypt = function (self, block) { return self._cipher.decryptBlock(block) } -},{}],118:[function(require,module,exports){ +},{}],117:[function(require,module,exports){ var modeModules = { ECB: require('./ecb'), CBC: require('./cbc'), @@ -35405,7 +35558,7 @@ for (var key in modes) { module.exports = modes -},{"./cbc":112,"./cfb":113,"./cfb1":114,"./cfb8":115,"./ctr":116,"./ecb":117,"./list.json":119,"./ofb":120}],119:[function(require,module,exports){ +},{"./cbc":111,"./cfb":112,"./cfb1":113,"./cfb8":114,"./ctr":115,"./ecb":116,"./list.json":118,"./ofb":119}],118:[function(require,module,exports){ module.exports={ "aes-128-ecb": { "cipher": "AES", @@ -35598,8 +35751,8 @@ module.exports={ } } -},{}],120:[function(require,module,exports){ -(function (Buffer){ +},{}],119:[function(require,module,exports){ +(function (Buffer){(function (){ var xor = require('buffer-xor') function getBlock (self) { @@ -35617,8 +35770,8 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -}).call(this,require("buffer").Buffer) -},{"buffer":131,"buffer-xor":130}],121:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130,"buffer-xor":129}],120:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -35647,7 +35800,7 @@ StreamCipher.prototype._final = function () { module.exports = StreamCipher -},{"./aes":105,"cipher-base":135,"inherits":259,"safe-buffer":322}],122:[function(require,module,exports){ +},{"./aes":104,"cipher-base":134,"inherits":279,"safe-buffer":345}],121:[function(require,module,exports){ var DES = require('browserify-des') var aes = require('browserify-aes/browser') var aesModes = require('browserify-aes/modes') @@ -35716,7 +35869,7 @@ exports.createDecipher = exports.Decipher = createDecipher exports.createDecipheriv = exports.Decipheriv = createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"browserify-aes/browser":107,"browserify-aes/modes":118,"browserify-des":123,"browserify-des/modes":124,"evp_bytestokey":237}],123:[function(require,module,exports){ +},{"browserify-aes/browser":106,"browserify-aes/modes":117,"browserify-des":122,"browserify-des/modes":123,"evp_bytestokey":238}],122:[function(require,module,exports){ var CipherBase = require('cipher-base') var des = require('des.js') var inherits = require('inherits') @@ -35768,7 +35921,7 @@ DES.prototype._final = function () { return Buffer.from(this._des.final()) } -},{"cipher-base":135,"des.js":206,"inherits":259,"safe-buffer":322}],124:[function(require,module,exports){ +},{"cipher-base":134,"des.js":207,"inherits":279,"safe-buffer":345}],123:[function(require,module,exports){ exports['des-ecb'] = { key: 8, iv: 0 @@ -35794,9 +35947,9 @@ exports['des-ede'] = { iv: 0 } -},{}],125:[function(require,module,exports){ +},{}],124:[function(require,module,exports){ arguments[4][82][0].apply(exports,arguments) -},{"base-x":29,"dup":82}],126:[function(require,module,exports){ +},{"base-x":29,"dup":82}],125:[function(require,module,exports){ 'use strict' var base58 = require('bs58') @@ -35848,7 +36001,7 @@ module.exports = function (checksumFn) { } } -},{"bs58":125,"safe-buffer":322}],127:[function(require,module,exports){ +},{"bs58":124,"safe-buffer":345}],126:[function(require,module,exports){ 'use strict' var createHash = require('create-hash') @@ -35862,8 +36015,8 @@ function sha256x2 (buffer) { module.exports = bs58checkBase(sha256x2) -},{"./base":126,"create-hash":139}],128:[function(require,module,exports){ -(function (Buffer){ +},{"./base":125,"create-hash":138}],127:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; module.exports = function (a, b) { if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { @@ -35891,9 +36044,9 @@ module.exports = function (a, b) { return true; }; -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":260}],129:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":280}],128:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function reverse (src) { var buffer = new Buffer(src.length) @@ -35905,9 +36058,9 @@ module.exports = function reverse (src) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],130:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],129:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) var buffer = new Buffer(length) @@ -35919,8 +36072,9 @@ module.exports = function xor (a, b) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],131:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],130:[function(require,module,exports){ +(function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. * @@ -37699,7 +37853,8 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":132,"ieee754":257}],132:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"base64-js":131,"buffer":130,"ieee754":278}],131:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -37767,7 +37922,8 @@ function toByteArray (b64) { ? validLen - 4 : validLen - for (var i = 0; i < len; i += 4) { + var i + for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | @@ -37826,9 +37982,7 @@ function fromByteArray (uint8) { // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } // pad the end with zeros, but make sure to not forget the extra bytes @@ -37852,7 +38006,7 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],133:[function(require,module,exports){ +},{}],132:[function(require,module,exports){ 'use strict'; var BigInteger = require('bigi'); @@ -38039,8 +38193,8 @@ function fromWords(words) { } module.exports = { decode: decode, encode: encode, toWords: toWords, fromWords: fromWords }; -},{"bigi":34}],134:[function(require,module,exports){ -(function (Buffer){ +},{"bigi":34}],133:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; /** global: Buffer */ @@ -38142,8 +38296,8 @@ function decode(address) { } module.exports = { decode: decode, encode: encode }; -}).call(this,require("buffer").Buffer) -},{"./base32":133,"buffer":131}],135:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./base32":132,"buffer":130}],134:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var StringDecoder = require('string_decoder').StringDecoder @@ -38244,7 +38398,7 @@ CipherBase.prototype._toString = function (value, enc, fin) { module.exports = CipherBase -},{"inherits":259,"safe-buffer":322,"stream":338,"string_decoder":241}],136:[function(require,module,exports){ +},{"inherits":279,"safe-buffer":345,"stream":259,"string_decoder":260}],135:[function(require,module,exports){ /** * Expose `Emitter`. @@ -38358,6 +38512,13 @@ Emitter.prototype.removeEventListener = function(event, fn){ break; } } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + return this; }; @@ -38371,9 +38532,14 @@ Emitter.prototype.removeEventListener = function(event, fn){ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) + + var args = new Array(arguments.length - 1) , callbacks = this._callbacks['$' + event]; + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { @@ -38409,8 +38575,8 @@ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; -},{}],137:[function(require,module,exports){ -(function (Buffer){ +},{}],136:[function(require,module,exports){ +(function (Buffer){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -38519,9 +38685,9 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":260}],138:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":280}],137:[function(require,module,exports){ +(function (Buffer){(function (){ var elliptic = require('elliptic') var BN = require('bn.js') @@ -38647,8 +38813,8 @@ function formatReturnValue (bn, enc, len) { } } -}).call(this,require("buffer").Buffer) -},{"bn.js":90,"buffer":131,"elliptic":221}],139:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":90,"buffer":130,"elliptic":222}],138:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var MD5 = require('md5.js') @@ -38680,14 +38846,14 @@ module.exports = function createHash (alg) { return new Hash(sha(alg)) } -},{"cipher-base":135,"inherits":259,"md5.js":263,"ripemd160":321,"sha.js":330}],140:[function(require,module,exports){ +},{"cipher-base":134,"inherits":279,"md5.js":283,"ripemd160":344,"sha.js":354}],139:[function(require,module,exports){ var MD5 = require('md5.js') module.exports = function (buffer) { return new MD5().update(buffer).digest() } -},{"md5.js":263}],141:[function(require,module,exports){ +},{"md5.js":283}],140:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Legacy = require('./legacy') @@ -38751,7 +38917,7 @@ module.exports = function createHmac (alg, key) { return new Hmac(alg, key) } -},{"./legacy":142,"cipher-base":135,"create-hash/md5":140,"inherits":259,"ripemd160":321,"safe-buffer":322,"sha.js":330}],142:[function(require,module,exports){ +},{"./legacy":141,"cipher-base":134,"create-hash/md5":139,"inherits":279,"ripemd160":344,"safe-buffer":345,"sha.js":354}],141:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Buffer = require('safe-buffer').Buffer @@ -38799,7 +38965,7 @@ Hmac.prototype._final = function () { } module.exports = Hmac -},{"cipher-base":135,"inherits":259,"safe-buffer":322}],143:[function(require,module,exports){ +},{"cipher-base":134,"inherits":279,"safe-buffer":345}],142:[function(require,module,exports){ 'use strict' exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') @@ -38898,8 +39064,10 @@ exports.constants = { 'POINT_CONVERSION_HYBRID': 6 } -},{"browserify-cipher":122,"browserify-sign":162,"browserify-sign/algos":159,"create-ecdh":138,"create-hash":139,"create-hmac":141,"diffie-hellman":212,"pbkdf2":269,"public-encrypt":272,"randombytes":306,"randomfill":307}],144:[function(require,module,exports){ -var asn1 = exports; +},{"browserify-cipher":121,"browserify-sign":163,"browserify-sign/algos":160,"create-ecdh":137,"create-hash":138,"create-hmac":140,"diffie-hellman":213,"pbkdf2":290,"public-encrypt":292,"randombytes":327,"randomfill":328}],143:[function(require,module,exports){ +'use strict'; + +const asn1 = exports; asn1.bignum = require('bn.js'); @@ -38909,11 +39077,14 @@ asn1.constants = require('./asn1/constants'); asn1.decoders = require('./asn1/decoders'); asn1.encoders = require('./asn1/encoders'); -},{"./asn1/api":145,"./asn1/base":147,"./asn1/constants":151,"./asn1/decoders":153,"./asn1/encoders":156,"bn.js":90}],145:[function(require,module,exports){ -var asn1 = require('../asn1'); -var inherits = require('inherits'); +},{"./asn1/api":144,"./asn1/base":146,"./asn1/constants":150,"./asn1/decoders":152,"./asn1/encoders":155,"bn.js":157}],144:[function(require,module,exports){ +'use strict'; -var api = exports; +const encoders = require('./encoders'); +const decoders = require('./decoders'); +const inherits = require('inherits'); + +const api = exports; api.define = function define(name, body) { return new Entity(name, body); @@ -38925,34 +39096,27 @@ function Entity(name, body) { this.decoders = {}; this.encoders = {}; -}; +} -Entity.prototype._createNamed = function createNamed(base) { - var named; - try { - named = require('vm').runInThisContext( - '(function ' + this.name + '(entity) {\n' + - ' this._initNamed(entity);\n' + - '})' - ); - } catch (e) { - named = function (entity) { - this._initNamed(entity); - }; +Entity.prototype._createNamed = function createNamed(Base) { + const name = this.name; + + function Generated(entity) { + this._initNamed(entity, name); } - inherits(named, base); - named.prototype._initNamed = function initnamed(entity) { - base.call(this, entity); + inherits(Generated, Base); + Generated.prototype._initNamed = function _initNamed(entity, name) { + Base.call(this, entity, name); }; - return new named(this); + return new Generated(this); }; Entity.prototype._getDecoder = function _getDecoder(enc) { enc = enc || 'der'; // Lazily create decoder if (!this.decoders.hasOwnProperty(enc)) - this.decoders[enc] = this._createNamed(asn1.decoders[enc]); + this.decoders[enc] = this._createNamed(decoders[enc]); return this.decoders[enc]; }; @@ -38964,7 +39128,7 @@ Entity.prototype._getEncoder = function _getEncoder(enc) { enc = enc || 'der'; // Lazily create encoder if (!this.encoders.hasOwnProperty(enc)) - this.encoders[enc] = this._createNamed(asn1.encoders[enc]); + this.encoders[enc] = this._createNamed(encoders[enc]); return this.encoders[enc]; }; @@ -38972,10 +39136,12 @@ Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { return this._getEncoder(enc).encode(data, reporter); }; -},{"../asn1":144,"inherits":259,"vm":242}],146:[function(require,module,exports){ -var inherits = require('inherits'); -var Reporter = require('../base').Reporter; -var Buffer = require('buffer').Buffer; +},{"./decoders":152,"./encoders":155,"inherits":279}],145:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Reporter = require('../base/reporter').Reporter; +const Buffer = require('safer-buffer').Buffer; function DecoderBuffer(base, options) { Reporter.call(this, options); @@ -38991,13 +39157,34 @@ function DecoderBuffer(base, options) { inherits(DecoderBuffer, Reporter); exports.DecoderBuffer = DecoderBuffer; +DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + Buffer.isBuffer(data.base) && + data.constructor.name === 'DecoderBuffer' && + typeof data.offset === 'number' && + typeof data.length === 'number' && + typeof data.save === 'function' && + typeof data.restore === 'function' && + typeof data.isEmpty === 'function' && + typeof data.readUInt8 === 'function' && + typeof data.skip === 'function' && + typeof data.raw === 'function'; + + return isCompatible; +}; + DecoderBuffer.prototype.save = function save() { return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; }; DecoderBuffer.prototype.restore = function restore(save) { // Return skipped data - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); res.offset = save.offset; res.length = this.offset; @@ -39016,13 +39203,13 @@ DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { return this.base.readUInt8(this.offset++, true); else return this.error(fail || 'DecoderBuffer overrun'); -} +}; DecoderBuffer.prototype.skip = function skip(bytes, fail) { if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun'); - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); // Share reporter state res._reporterState = this._reporterState; @@ -39031,17 +39218,17 @@ DecoderBuffer.prototype.skip = function skip(bytes, fail) { res.length = this.offset + bytes; this.offset += bytes; return res; -} +}; DecoderBuffer.prototype.raw = function raw(save) { return this.base.slice(save ? save.offset : this.offset, this.length); -} +}; function EncoderBuffer(value, reporter) { if (Array.isArray(value)) { this.length = 0; this.value = value.map(function(item) { - if (!(item instanceof EncoderBuffer)) + if (!EncoderBuffer.isEncoderBuffer(item)) item = new EncoderBuffer(item, reporter); this.length += item.length; return item; @@ -39063,9 +39250,23 @@ function EncoderBuffer(value, reporter) { } exports.EncoderBuffer = EncoderBuffer; +EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + data.constructor.name === 'EncoderBuffer' && + typeof data.length === 'number' && + typeof data.join === 'function'; + + return isCompatible; +}; + EncoderBuffer.prototype.join = function join(out, offset) { if (!out) - out = new Buffer(this.length); + out = Buffer.alloc(this.length); if (!offset) offset = 0; @@ -39090,22 +39291,26 @@ EncoderBuffer.prototype.join = function join(out, offset) { return out; }; -},{"../base":147,"buffer":131,"inherits":259}],147:[function(require,module,exports){ -var base = exports; +},{"../base/reporter":148,"inherits":279,"safer-buffer":346}],146:[function(require,module,exports){ +'use strict'; + +const base = exports; base.Reporter = require('./reporter').Reporter; base.DecoderBuffer = require('./buffer').DecoderBuffer; base.EncoderBuffer = require('./buffer').EncoderBuffer; base.Node = require('./node'); -},{"./buffer":146,"./node":148,"./reporter":149}],148:[function(require,module,exports){ -var Reporter = require('../base').Reporter; -var EncoderBuffer = require('../base').EncoderBuffer; -var DecoderBuffer = require('../base').DecoderBuffer; -var assert = require('minimalistic-assert'); +},{"./buffer":145,"./node":147,"./reporter":148}],147:[function(require,module,exports){ +'use strict'; + +const Reporter = require('../base/reporter').Reporter; +const EncoderBuffer = require('../base/buffer').EncoderBuffer; +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const assert = require('minimalistic-assert'); // Supported tags -var tags = [ +const tags = [ 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', @@ -39113,13 +39318,13 @@ var tags = [ ]; // Public methods list -var methods = [ +const methods = [ 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains' ].concat(tags); // Overrided methods list -var overrided = [ +const overrided = [ '_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', @@ -39128,10 +39333,11 @@ var overrided = [ '_encodeNull', '_encodeInt', '_encodeBool' ]; -function Node(enc, parent) { - var state = {}; +function Node(enc, parent, name) { + const state = {}; this._baseState = state; + state.name = name; state.enc = enc; state.parent = parent || null; @@ -39161,28 +39367,28 @@ function Node(enc, parent) { } module.exports = Node; -var stateProps = [ +const stateProps = [ 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains' ]; Node.prototype.clone = function clone() { - var state = this._baseState; - var cstate = {}; + const state = this._baseState; + const cstate = {}; stateProps.forEach(function(prop) { cstate[prop] = state[prop]; }); - var res = new this.constructor(cstate.parent); + const res = new this.constructor(cstate.parent); res._baseState = cstate; return res; }; Node.prototype._wrap = function wrap() { - var state = this._baseState; + const state = this._baseState; methods.forEach(function(method) { this[method] = function _wrappedMethod() { - var clone = new this.constructor(this); + const clone = new this.constructor(this); state.children.push(clone); return clone[method].apply(clone, arguments); }; @@ -39190,7 +39396,7 @@ Node.prototype._wrap = function wrap() { }; Node.prototype._init = function init(body) { - var state = this._baseState; + const state = this._baseState; assert(state.parent === null); body.call(this); @@ -39203,10 +39409,10 @@ Node.prototype._init = function init(body) { }; Node.prototype._useArgs = function useArgs(args) { - var state = this._baseState; + const state = this._baseState; // Filter children and args - var children = args.filter(function(arg) { + const children = args.filter(function(arg) { return arg instanceof this.constructor; }, this); args = args.filter(function(arg) { @@ -39229,11 +39435,11 @@ Node.prototype._useArgs = function useArgs(args) { if (typeof arg !== 'object' || arg.constructor !== Object) return arg; - var res = {}; + const res = {}; Object.keys(arg).forEach(function(key) { if (key == (key | 0)) key |= 0; - var value = arg[key]; + const value = arg[key]; res[value] = key; }); return res; @@ -39247,7 +39453,7 @@ Node.prototype._useArgs = function useArgs(args) { overrided.forEach(function(method) { Node.prototype[method] = function _overrided() { - var state = this._baseState; + const state = this._baseState; throw new Error(method + ' not implemented for encoding: ' + state.enc); }; }); @@ -39258,8 +39464,8 @@ overrided.forEach(function(method) { tags.forEach(function(tag) { Node.prototype[tag] = function _tagMethod() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); assert(state.tag === null); state.tag = tag; @@ -39272,7 +39478,7 @@ tags.forEach(function(tag) { Node.prototype.use = function use(item) { assert(item); - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.use = item; @@ -39281,7 +39487,7 @@ Node.prototype.use = function use(item) { }; Node.prototype.optional = function optional() { - var state = this._baseState; + const state = this._baseState; state.optional = true; @@ -39289,7 +39495,7 @@ Node.prototype.optional = function optional() { }; Node.prototype.def = function def(val) { - var state = this._baseState; + const state = this._baseState; assert(state['default'] === null); state['default'] = val; @@ -39299,7 +39505,7 @@ Node.prototype.def = function def(val) { }; Node.prototype.explicit = function explicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.explicit = num; @@ -39308,7 +39514,7 @@ Node.prototype.explicit = function explicit(num) { }; Node.prototype.implicit = function implicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.implicit = num; @@ -39317,8 +39523,8 @@ Node.prototype.implicit = function implicit(num) { }; Node.prototype.obj = function obj() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); state.obj = true; @@ -39329,7 +39535,7 @@ Node.prototype.obj = function obj() { }; Node.prototype.key = function key(newKey) { - var state = this._baseState; + const state = this._baseState; assert(state.key === null); state.key = newKey; @@ -39338,7 +39544,7 @@ Node.prototype.key = function key(newKey) { }; Node.prototype.any = function any() { - var state = this._baseState; + const state = this._baseState; state.any = true; @@ -39346,7 +39552,7 @@ Node.prototype.any = function any() { }; Node.prototype.choice = function choice(obj) { - var state = this._baseState; + const state = this._baseState; assert(state.choice === null); state.choice = obj; @@ -39358,7 +39564,7 @@ Node.prototype.choice = function choice(obj) { }; Node.prototype.contains = function contains(item) { - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.contains = item; @@ -39371,22 +39577,22 @@ Node.prototype.contains = function contains(item) { // Node.prototype._decode = function decode(input, options) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options)); - var result = state['default']; - var present = true; + let result = state['default']; + let present = true; - var prevKey = null; + let prevKey = null; if (state.key !== null) prevKey = input.enterKey(state.key); // Check if tag is there if (state.optional) { - var tag = null; + let tag = null; if (state.explicit !== null) tag = state.explicit; else if (state.implicit !== null) @@ -39396,7 +39602,7 @@ Node.prototype._decode = function decode(input, options) { if (tag === null && !state.any) { // Trial and Error - var save = input.save(); + const save = input.save(); try { if (state.choice === null) this._decodeGeneric(state.tag, input, options); @@ -39416,26 +39622,27 @@ Node.prototype._decode = function decode(input, options) { } // Push object on stack - var prevObj; + let prevObj; if (state.obj && present) prevObj = input.enterObject(); if (present) { // Unwrap explicit values if (state.explicit !== null) { - var explicit = this._decodeTag(input, state.explicit); + const explicit = this._decodeTag(input, state.explicit); if (input.isError(explicit)) return explicit; input = explicit; } - var start = input.offset; + const start = input.offset; // Unwrap implicit and normal values if (state.use === null && state.choice === null) { + let save; if (state.any) - var save = input.save(); - var body = this._decodeTag( + save = input.save(); + const body = this._decodeTag( input, state.implicit !== null ? state.implicit : state.tag, state.any @@ -39456,12 +39663,13 @@ Node.prototype._decode = function decode(input, options) { options.track(input.path(), input.offset, input.length, 'content'); // Select proper method for tag - if (state.any) - result = result; - else if (state.choice === null) + if (state.any) { + // no-op + } else if (state.choice === null) { result = this._decodeGeneric(state.tag, input, options); - else + } else { result = this._decodeChoice(input, options); + } if (input.isError(result)) return result; @@ -39477,9 +39685,9 @@ Node.prototype._decode = function decode(input, options) { // Decode contained/encoded by schema, only in bit or octet strings if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { - var data = new DecoderBuffer(result); + const data = new DecoderBuffer(result); result = this._getUse(state.contains, input._reporterState.obj) - ._decode(data, options); + ._decode(data, options); } } @@ -39497,7 +39705,7 @@ Node.prototype._decode = function decode(input, options) { }; Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { - var state = this._baseState; + const state = this._baseState; if (tag === 'seq' || tag === 'set') return null; @@ -39522,7 +39730,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { if (state.use !== null) { return this._getUse(state.use, input._reporterState.obj) - ._decode(input, options); + ._decode(input, options); } else { return input.error('unknown tag: ' + tag); } @@ -39530,7 +39738,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { Node.prototype._getUse = function _getUse(entity, obj) { - var state = this._baseState; + const state = this._baseState; // Create altered use decoder if implicit is set state.useDecoder = this._use(entity, obj); assert(state.useDecoder._baseState.parent === null); @@ -39543,15 +39751,15 @@ Node.prototype._getUse = function _getUse(entity, obj) { }; Node.prototype._decodeChoice = function decodeChoice(input, options) { - var state = this._baseState; - var result = null; - var match = false; + const state = this._baseState; + let result = null; + let match = false; Object.keys(state.choice).some(function(key) { - var save = input.save(); - var node = state.choice[key]; + const save = input.save(); + const node = state.choice[key]; try { - var value = node._decode(input, options); + const value = node._decode(input, options); if (input.isError(value)) return false; @@ -39579,11 +39787,11 @@ Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { }; Node.prototype._encode = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; if (state['default'] !== null && state['default'] === data) return; - var result = this._encodeValue(data, reporter, parent); + const result = this._encodeValue(data, reporter, parent); if (result === undefined) return; @@ -39594,13 +39802,13 @@ Node.prototype._encode = function encode(data, reporter, parent) { }; Node.prototype._encodeValue = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter()); - var result = null; + let result = null; // Set reporter to share it with a child class this.reporter = reporter; @@ -39608,14 +39816,14 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { // Check if data is there if (state.optional && data === undefined) { if (state['default'] !== null) - data = state['default'] + data = state['default']; else return; } // Encode children first - var content = null; - var primitive = false; + let content = null; + let primitive = false; if (state.any) { // Anything that was given is translated to buffer result = this._createEncoderBuffer(data); @@ -39631,12 +39839,12 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (child._baseState.key === null) return reporter.error('Child should have a key'); - var prevKey = reporter.enterKey(child._baseState.key); + const prevKey = reporter.enterKey(child._baseState.key); if (typeof data !== 'object') return reporter.error('Child expected, but input is not object'); - var res = child._encode(data[child._baseState.key], reporter, data); + const res = child._encode(data[child._baseState.key], reporter, data); reporter.leaveKey(prevKey); return res; @@ -39653,10 +39861,10 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array'); - var child = this.clone(); + const child = this.clone(); child._baseState.implicit = null; content = this._createEncoderBuffer(data.map(function(item) { - var state = this._baseState; + const state = this._baseState; return this._getUse(state.args[0], data)._encode(item, reporter); }, child)); @@ -39669,10 +39877,9 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { } // Encode data itself - var result; if (!state.any && state.choice === null) { - var tag = state.implicit !== null ? state.implicit : state.tag; - var cls = state.implicit === null ? 'universal' : 'context'; + const tag = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? 'universal' : 'context'; if (tag === null) { if (state.use === null) @@ -39691,20 +39898,20 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { }; Node.prototype._encodeChoice = function encodeChoice(data, reporter) { - var state = this._baseState; + const state = this._baseState; - var node = state.choice[data.type]; + const node = state.choice[data.type]; if (!node) { assert( - false, - data.type + ' not found in ' + + false, + data.type + ' not found in ' + JSON.stringify(Object.keys(state.choice))); } return node._encode(data.value, reporter); }; Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { - var state = this._baseState; + const state = this._baseState; if (/str$/.test(tag)) return this._encodeStr(data, tag); @@ -39731,11 +39938,13 @@ Node.prototype._isNumstr = function isNumstr(str) { }; Node.prototype._isPrintstr = function isPrintstr(str) { - return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); }; -},{"../base":147,"minimalistic-assert":266}],149:[function(require,module,exports){ -var inherits = require('inherits'); +},{"../base/buffer":145,"../base/reporter":148,"minimalistic-assert":286}],148:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); function Reporter(options) { this._reporterState = { @@ -39752,13 +39961,13 @@ Reporter.prototype.isError = function isError(obj) { }; Reporter.prototype.save = function save() { - var state = this._reporterState; + const state = this._reporterState; return { obj: state.obj, pathLen: state.path.length }; }; Reporter.prototype.restore = function restore(data) { - var state = this._reporterState; + const state = this._reporterState; state.obj = data.obj; state.path = state.path.slice(0, data.pathLen); @@ -39769,13 +39978,13 @@ Reporter.prototype.enterKey = function enterKey(key) { }; Reporter.prototype.exitKey = function exitKey(index) { - var state = this._reporterState; + const state = this._reporterState; state.path = state.path.slice(0, index - 1); }; Reporter.prototype.leaveKey = function leaveKey(index, key, value) { - var state = this._reporterState; + const state = this._reporterState; this.exitKey(index); if (state.obj !== null) @@ -39787,26 +39996,26 @@ Reporter.prototype.path = function path() { }; Reporter.prototype.enterObject = function enterObject() { - var state = this._reporterState; + const state = this._reporterState; - var prev = state.obj; + const prev = state.obj; state.obj = {}; return prev; }; Reporter.prototype.leaveObject = function leaveObject(prev) { - var state = this._reporterState; + const state = this._reporterState; - var now = state.obj; + const now = state.obj; state.obj = prev; return now; }; Reporter.prototype.error = function error(msg) { - var err; - var state = this._reporterState; + let err; + const state = this._reporterState; - var inherited = msg instanceof ReporterError; + const inherited = msg instanceof ReporterError; if (inherited) { err = msg; } else { @@ -39825,7 +40034,7 @@ Reporter.prototype.error = function error(msg) { }; Reporter.prototype.wrapResult = function wrapResult(result) { - var state = this._reporterState; + const state = this._reporterState; if (!state.options.partial) return result; @@ -39838,7 +40047,7 @@ Reporter.prototype.wrapResult = function wrapResult(result) { function ReporterError(path, msg) { this.path = path; this.rethrow(msg); -}; +} inherits(ReporterError, Error); ReporterError.prototype.rethrow = function rethrow(msg) { @@ -39857,8 +40066,24 @@ ReporterError.prototype.rethrow = function rethrow(msg) { return this; }; -},{"inherits":259}],150:[function(require,module,exports){ -var constants = require('../constants'); +},{"inherits":279}],149:[function(require,module,exports){ +'use strict'; + +// Helper +function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; +} exports.tagClass = { 0: 'universal', @@ -39866,7 +40091,7 @@ exports.tagClass = { 2: 'context', 3: 'private' }; -exports.tagClassByName = constants._reverse(exports.tagClass); +exports.tagClassByName = reverse(exports.tagClass); exports.tag = { 0x00: 'end', @@ -39899,21 +40124,23 @@ exports.tag = { 0x1d: 'charstr', 0x1e: 'bmpstr' }; -exports.tagByName = constants._reverse(exports.tag); +exports.tagByName = reverse(exports.tag); -},{"../constants":151}],151:[function(require,module,exports){ -var constants = exports; +},{}],150:[function(require,module,exports){ +'use strict'; + +const constants = exports; // Helper constants._reverse = function reverse(map) { - var res = {}; + const res = {}; Object.keys(map).forEach(function(key) { // Convert key to integer if it is stringified if ((key | 0) == key) key = key | 0; - var value = map[key]; + const value = map[key]; res[value] = key; }); @@ -39922,15 +40149,17 @@ constants._reverse = function reverse(map) { constants.der = require('./der'); -},{"./der":150}],152:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":149}],151:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; -var bignum = asn1.bignum; +const inherits = require('inherits'); + +const bignum = require('bn.js'); +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DERDecoder(entity) { this.enc = 'der'; @@ -39940,12 +40169,13 @@ function DERDecoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DERDecoder; DERDecoder.prototype.decode = function decode(data, options) { - if (!(data instanceof base.DecoderBuffer)) - data = new base.DecoderBuffer(data, options); + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } return this.tree._decode(data, options); }; @@ -39953,16 +40183,16 @@ DERDecoder.prototype.decode = function decode(data, options) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { if (buffer.isEmpty()) return false; - var state = buffer.save(); - var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); + const state = buffer.save(); + const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; @@ -39973,14 +40203,14 @@ DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { }; DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { - var decodedTag = derDecodeTag(buffer, - 'Failed to decode tag of "' + tag + '"'); + const decodedTag = derDecodeTag(buffer, + 'Failed to decode tag of "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; - var len = derDecodeLen(buffer, - decodedTag.primitive, - 'Failed to get length of "' + tag + '"'); + let len = derDecodeLen(buffer, + decodedTag.primitive, + 'Failed to get length of "' + tag + '"'); // Failure if (buffer.isError(len)) @@ -39997,10 +40227,10 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); // Indefinite length... find END tag - var state = buffer.save(); - var res = this._skipUntilEnd( - buffer, - 'Failed to skip indefinite length body: "' + this.tag + '"'); + const state = buffer.save(); + const res = this._skipUntilEnd( + buffer, + 'Failed to skip indefinite length body: "' + this.tag + '"'); if (buffer.isError(res)) return res; @@ -40010,17 +40240,17 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { }; DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { - while (true) { - var tag = derDecodeTag(buffer, fail); + for (;;) { + const tag = derDecodeTag(buffer, fail); if (buffer.isError(tag)) return tag; - var len = derDecodeLen(buffer, tag.primitive, fail); + const len = derDecodeLen(buffer, tag.primitive, fail); if (buffer.isError(len)) return len; - var res; + let res; if (tag.primitive || len !== null) - res = buffer.skip(len) + res = buffer.skip(len); else res = this._skipUntilEnd(buffer, fail); @@ -40034,14 +40264,14 @@ DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { }; DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, - options) { - var result = []; + options) { + const result = []; while (!buffer.isEmpty()) { - var possibleEnd = this._peekTag(buffer, 'end'); + const possibleEnd = this._peekTag(buffer, 'end'); if (buffer.isError(possibleEnd)) return possibleEnd; - var res = decoder.decode(buffer, 'der', options); + const res = decoder.decode(buffer, 'der', options); if (buffer.isError(res) && possibleEnd) break; result.push(res); @@ -40051,22 +40281,22 @@ DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { if (tag === 'bitstr') { - var unused = buffer.readUInt8(); + const unused = buffer.readUInt8(); if (buffer.isError(unused)) return unused; return { unused: unused, data: buffer.raw() }; } else if (tag === 'bmpstr') { - var raw = buffer.raw(); + const raw = buffer.raw(); if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch'); - var str = ''; - for (var i = 0; i < raw.length / 2; i++) { + let str = ''; + for (let i = 0; i < raw.length / 2; i++) { str += String.fromCharCode(raw.readUInt16BE(i * 2)); } return str; } else if (tag === 'numstr') { - var numstr = buffer.raw().toString('ascii'); + const numstr = buffer.raw().toString('ascii'); if (!this._isNumstr(numstr)) { return buffer.error('Decoding of string type: ' + 'numstr unsupported characters'); @@ -40077,7 +40307,7 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { } else if (tag === 'objDesc') { return buffer.raw(); } else if (tag === 'printstr') { - var printstr = buffer.raw().toString('ascii'); + const printstr = buffer.raw().toString('ascii'); if (!this._isPrintstr(printstr)) { return buffer.error('Decoding of string type: ' + 'printstr unsupported characters'); @@ -40091,11 +40321,12 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { }; DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { - var result; - var identifiers = []; - var ident = 0; + let result; + const identifiers = []; + let ident = 0; + let subident = 0; while (!buffer.isEmpty()) { - var subident = buffer.readUInt8(); + subident = buffer.readUInt8(); ident <<= 7; ident |= subident & 0x7f; if ((subident & 0x80) === 0) { @@ -40106,8 +40337,8 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) if (subident & 0x80) identifiers.push(ident); - var first = (identifiers[0] / 40) | 0; - var second = identifiers[0] % 40; + const first = (identifiers[0] / 40) | 0; + const second = identifiers[0] % 40; if (relative) result = identifiers; @@ -40115,7 +40346,7 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) result = [first, second].concat(identifiers.slice(1)); if (values) { - var tmp = values[result.join(' ')]; + let tmp = values[result.join(' ')]; if (tmp === undefined) tmp = values[result.join('.')]; if (tmp !== undefined) @@ -40126,21 +40357,28 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) }; DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { - var str = buffer.raw().toString(); + const str = buffer.raw().toString(); + + let year; + let mon; + let day; + let hour; + let min; + let sec; if (tag === 'gentime') { - var year = str.slice(0, 4) | 0; - var mon = str.slice(4, 6) | 0; - var day = str.slice(6, 8) | 0; - var hour = str.slice(8, 10) | 0; - var min = str.slice(10, 12) | 0; - var sec = str.slice(12, 14) | 0; + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; } else if (tag === 'utctime') { - var year = str.slice(0, 2) | 0; - var mon = str.slice(2, 4) | 0; - var day = str.slice(4, 6) | 0; - var hour = str.slice(6, 8) | 0; - var min = str.slice(8, 10) | 0; - var sec = str.slice(10, 12) | 0; + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; if (year < 70) year = 2000 + year; else @@ -40152,12 +40390,12 @@ DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { return Date.UTC(year, mon - 1, day, hour, min, sec, 0); }; -DERNode.prototype._decodeNull = function decodeNull(buffer) { +DERNode.prototype._decodeNull = function decodeNull() { return null; }; DERNode.prototype._decodeBool = function decodeBool(buffer) { - var res = buffer.readUInt8(); + const res = buffer.readUInt8(); if (buffer.isError(res)) return res; else @@ -40166,8 +40404,8 @@ DERNode.prototype._decodeBool = function decodeBool(buffer) { DERNode.prototype._decodeInt = function decodeInt(buffer, values) { // Bigint, return as it is (assume big endian) - var raw = buffer.raw(); - var res = new bignum(raw); + const raw = buffer.raw(); + let res = new bignum(raw); if (values) res = values[res.toString(10)] || res; @@ -40184,16 +40422,16 @@ DERNode.prototype._use = function use(entity, obj) { // Utility methods function derDecodeTag(buf, fail) { - var tag = buf.readUInt8(fail); + let tag = buf.readUInt8(fail); if (buf.isError(tag)) return tag; - var cls = der.tagClass[tag >> 6]; - var primitive = (tag & 0x20) === 0; + const cls = der.tagClass[tag >> 6]; + const primitive = (tag & 0x20) === 0; // Multi-octet tag - load if ((tag & 0x1f) === 0x1f) { - var oct = tag; + let oct = tag; tag = 0; while ((oct & 0x80) === 0x80) { oct = buf.readUInt8(fail); @@ -40206,7 +40444,7 @@ function derDecodeTag(buf, fail) { } else { tag &= 0x1f; } - var tagStr = der.tag[tag]; + const tagStr = der.tag[tag]; return { cls: cls, @@ -40217,7 +40455,7 @@ function derDecodeTag(buf, fail) { } function derDecodeLen(buf, primitive, fail) { - var len = buf.readUInt8(fail); + let len = buf.readUInt8(fail); if (buf.isError(len)) return len; @@ -40232,14 +40470,14 @@ function derDecodeLen(buf, primitive, fail) { } // Long form - var num = len & 0x7f; + const num = len & 0x7f; if (num > 4) return buf.error('length octect is too long'); len = 0; - for (var i = 0; i < num; i++) { + for (let i = 0; i < num; i++) { len <<= 8; - var j = buf.readUInt8(fail); + const j = buf.readUInt8(fail); if (buf.isError(j)) return j; len |= j; @@ -40248,35 +40486,39 @@ function derDecodeLen(buf, primitive, fail) { return len; } -},{"../../asn1":144,"inherits":259}],153:[function(require,module,exports){ -var decoders = exports; +},{"../base/buffer":145,"../base/node":147,"../constants/der":149,"bn.js":157,"inherits":279}],152:[function(require,module,exports){ +'use strict'; + +const decoders = exports; decoders.der = require('./der'); decoders.pem = require('./pem'); -},{"./der":152,"./pem":154}],154:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":151,"./pem":153}],153:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; -var DERDecoder = require('./der'); +const DERDecoder = require('./der'); function PEMDecoder(entity) { DERDecoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMDecoder, DERDecoder); module.exports = PEMDecoder; PEMDecoder.prototype.decode = function decode(data, options) { - var lines = data.toString().split(/[\r\n]+/g); + const lines = data.toString().split(/[\r\n]+/g); - var label = options.label.toUpperCase(); + const label = options.label.toUpperCase(); - var re = /^-----(BEGIN|END) ([^-]+)-----$/; - var start = -1; - var end = -1; - for (var i = 0; i < lines.length; i++) { - var match = lines[i].match(re); + const re = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(re); if (match === null) continue; @@ -40297,23 +40539,23 @@ PEMDecoder.prototype.decode = function decode(data, options) { if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label); - var base64 = lines.slice(start + 1, end).join(''); + const base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols - base64.replace(/[^a-z0-9\+\/=]+/gi, ''); + base64.replace(/[^a-z0-9+/=]+/gi, ''); - var input = new Buffer(base64, 'base64'); + const input = Buffer.from(base64, 'base64'); return DERDecoder.prototype.decode.call(this, input, options); }; -},{"./der":152,"buffer":131,"inherits":259}],155:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":151,"inherits":279,"safer-buffer":346}],154:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DEREncoder(entity) { this.enc = 'der'; @@ -40323,7 +40565,7 @@ function DEREncoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DEREncoder; DEREncoder.prototype.encode = function encode(data, reporter) { @@ -40333,19 +40575,19 @@ DEREncoder.prototype.encode = function encode(data, reporter) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._encodeComposite = function encodeComposite(tag, - primitive, - cls, - content) { - var encodedTag = encodeTag(tag, primitive, cls, this.reporter); + primitive, + cls, + content) { + const encodedTag = encodeTag(tag, primitive, cls, this.reporter); // Short form if (content.length < 0x80) { - var header = new Buffer(2); + const header = Buffer.alloc(2); header[0] = encodedTag; header[1] = content.length; return this._createEncoderBuffer([ header, content ]); @@ -40353,15 +40595,15 @@ DERNode.prototype._encodeComposite = function encodeComposite(tag, // Long form // Count octets required to store length - var lenOctets = 1; - for (var i = content.length; i >= 0x100; i >>= 8) + let lenOctets = 1; + for (let i = content.length; i >= 0x100; i >>= 8) lenOctets++; - var header = new Buffer(1 + 1 + lenOctets); + const header = Buffer.alloc(1 + 1 + lenOctets); header[0] = encodedTag; header[1] = 0x80 | lenOctets; - for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) + for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) header[i] = j & 0xff; return this._createEncoderBuffer([ header, content ]); @@ -40371,8 +40613,8 @@ DERNode.prototype._encodeStr = function encodeStr(str, tag) { if (tag === 'bitstr') { return this._createEncoderBuffer([ str.unused | 0, str.data ]); } else if (tag === 'bmpstr') { - var buf = new Buffer(str.length * 2); - for (var i = 0; i < str.length; i++) { + const buf = Buffer.alloc(str.length * 2); + for (let i = 0; i < str.length; i++) { buf.writeUInt16BE(str.charCodeAt(i), i * 2); } return this._createEncoderBuffer(buf); @@ -40408,12 +40650,12 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { return this.reporter.error('string objid given, but no values map found'); if (!values.hasOwnProperty(id)) return this.reporter.error('objid not found in values map'); - id = values[id].split(/[\s\.]+/g); - for (var i = 0; i < id.length; i++) + id = values[id].split(/[\s.]+/g); + for (let i = 0; i < id.length; i++) id[i] |= 0; } else if (Array.isArray(id)) { id = id.slice(); - for (var i = 0; i < id.length; i++) + for (let i = 0; i < id.length; i++) id[i] |= 0; } @@ -40429,17 +40671,17 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { } // Count number of octets - var size = 0; - for (var i = 0; i < id.length; i++) { - var ident = id[i]; + let size = 0; + for (let i = 0; i < id.length; i++) { + let ident = id[i]; for (size++; ident >= 0x80; ident >>= 7) size++; } - var objid = new Buffer(size); - var offset = objid.length - 1; - for (var i = id.length - 1; i >= 0; i--) { - var ident = id[i]; + const objid = Buffer.alloc(size); + let offset = objid.length - 1; + for (let i = id.length - 1; i >= 0; i--) { + let ident = id[i]; objid[offset--] = ident & 0x7f; while ((ident >>= 7) > 0) objid[offset--] = 0x80 | (ident & 0x7f); @@ -40456,12 +40698,12 @@ function two(num) { } DERNode.prototype._encodeTime = function encodeTime(time, tag) { - var str; - var date = new Date(time); + let str; + const date = new Date(time); if (tag === 'gentime') { str = [ - two(date.getFullYear()), + two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -40471,7 +40713,7 @@ DERNode.prototype._encodeTime = function encodeTime(time, tag) { ].join(''); } else if (tag === 'utctime') { str = [ - two(date.getFullYear() % 100), + two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -40503,22 +40745,22 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { // Bignum, assume big endian if (typeof num !== 'number' && !Buffer.isBuffer(num)) { - var numArray = num.toArray(); + const numArray = num.toArray(); if (!num.sign && numArray[0] & 0x80) { numArray.unshift(0); } - num = new Buffer(numArray); + num = Buffer.from(numArray); } if (Buffer.isBuffer(num)) { - var size = num.length; + let size = num.length; if (num.length === 0) size++; - var out = new Buffer(size); + const out = Buffer.alloc(size); num.copy(out); if (num.length === 0) - out[0] = 0 + out[0] = 0; return this._createEncoderBuffer(out); } @@ -40528,12 +40770,12 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { if (num < 0x100) return this._createEncoderBuffer([0, num]); - var size = 1; - for (var i = num; i >= 0x100; i >>= 8) + let size = 1; + for (let i = num; i >= 0x100; i >>= 8) size++; - var out = new Array(size); - for (var i = out.length - 1; i >= 0; i--) { + const out = new Array(size); + for (let i = out.length - 1; i >= 0; i--) { out[i] = num & 0xff; num >>= 8; } @@ -40541,7 +40783,7 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { out.unshift(0); } - return this._createEncoderBuffer(new Buffer(out)); + return this._createEncoderBuffer(Buffer.from(out)); }; DERNode.prototype._encodeBool = function encodeBool(value) { @@ -40555,12 +40797,12 @@ DERNode.prototype._use = function use(entity, obj) { }; DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { - var state = this._baseState; - var i; + const state = this._baseState; + let i; if (state['default'] === null) return false; - var data = dataBuffer.join(); + const data = dataBuffer.join(); if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); @@ -40577,7 +40819,7 @@ DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, pare // Utility methods function encodeTag(tag, primitive, cls, reporter) { - var res; + let res; if (tag === 'seqof') tag = 'seq'; @@ -40602,1910 +40844,5458 @@ function encodeTag(tag, primitive, cls, reporter) { return res; } -},{"../../asn1":144,"buffer":131,"inherits":259}],156:[function(require,module,exports){ -var encoders = exports; +},{"../base/node":147,"../constants/der":149,"inherits":279,"safer-buffer":346}],155:[function(require,module,exports){ +'use strict'; + +const encoders = exports; encoders.der = require('./der'); encoders.pem = require('./pem'); -},{"./der":155,"./pem":157}],157:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":154,"./pem":156}],156:[function(require,module,exports){ +'use strict'; -var DEREncoder = require('./der'); +const inherits = require('inherits'); + +const DEREncoder = require('./der'); function PEMEncoder(entity) { DEREncoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMEncoder, DEREncoder); module.exports = PEMEncoder; PEMEncoder.prototype.encode = function encode(data, options) { - var buf = DEREncoder.prototype.encode.call(this, data); + const buf = DEREncoder.prototype.encode.call(this, data); - var p = buf.toString('base64'); - var out = [ '-----BEGIN ' + options.label + '-----' ]; - for (var i = 0; i < p.length; i += 64) + const p = buf.toString('base64'); + const out = [ '-----BEGIN ' + options.label + '-----' ]; + for (let i = 0; i < p.length; i += 64) out.push(p.slice(i, i + 64)); out.push('-----END ' + options.label + '-----'); return out.join('\n'); }; -},{"./der":155,"inherits":259}],158:[function(require,module,exports){ -(function (Buffer){ -var bn = require('bn.js'); -var randomBytes = require('randombytes'); -module.exports = crt; -function blind(priv) { - var r = getr(priv); - var blinder = r.toRed(bn.mont(priv.modulus)) - .redPow(new bn(priv.publicExponent)).fromRed(); - return { - blinder: blinder, - unblinder:r.invm(priv.modulus) - }; -} -function crt(msg, priv) { - var blinds = blind(priv); - var len = priv.modulus.byteLength(); - var mod = bn.mont(priv.modulus); - var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus); - var c1 = blinded.toRed(bn.mont(priv.prime1)); - var c2 = blinded.toRed(bn.mont(priv.prime2)); - var qinv = priv.coefficient; - var p = priv.prime1; - var q = priv.prime2; - var m1 = c1.redPow(priv.exponent1); - var m2 = c2.redPow(priv.exponent2); - m1 = m1.fromRed(); - m2 = m2.fromRed(); - var h = m1.isub(m2).imul(qinv).umod(p); - h.imul(q); - m2.iadd(h); - return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len)); -} -crt.getr = getr; -function getr(priv) { - var len = priv.modulus.byteLength(); - var r = new bn(randomBytes(len)); - while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) { - r = new bn(randomBytes(len)); - } - return r; -} +},{"./der":154,"inherits":279}],157:[function(require,module,exports){ +arguments[4][90][0].apply(exports,arguments) +},{"buffer":239,"dup":90}],158:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; -}).call(this,require("buffer").Buffer) -},{"bn.js":90,"buffer":131,"randombytes":306}],159:[function(require,module,exports){ -module.exports = require('./browser/algorithms.json') + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } -},{"./browser/algorithms.json":160}],160:[function(require,module,exports){ -module.exports={ - "sha224WithRSAEncryption": { - "sign": "rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "RSA-SHA224": { - "sign": "ecdsa/rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "sha256WithRSAEncryption": { - "sign": "rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "RSA-SHA256": { - "sign": "ecdsa/rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "sha384WithRSAEncryption": { - "sign": "rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "RSA-SHA384": { - "sign": "ecdsa/rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "sha512WithRSAEncryption": { - "sign": "rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA512": { - "sign": "ecdsa/rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA1": { - "sign": "rsa", - "hash": "sha1", - "id": "3021300906052b0e03021a05000414" - }, - "ecdsa-with-SHA1": { - "sign": "ecdsa", - "hash": "sha1", - "id": "" - }, - "sha256": { - "sign": "ecdsa", - "hash": "sha256", - "id": "" - }, - "sha224": { - "sign": "ecdsa", - "hash": "sha224", - "id": "" - }, - "sha384": { - "sign": "ecdsa", - "hash": "sha384", - "id": "" - }, - "sha512": { - "sign": "ecdsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-SHA1": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-WITH-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-WITH-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-WITH-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-WITH-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-RIPEMD160": { - "sign": "dsa", - "hash": "rmd160", - "id": "" - }, - "ripemd160WithRSA": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "RSA-RIPEMD160": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "md5WithRSAEncryption": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" - }, - "RSA-MD5": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; } -} -},{}],161:[function(require,module,exports){ -module.exports={ - "1.3.132.0.10": "secp256k1", - "1.3.132.0.33": "p224", - "1.2.840.10045.3.1.1": "p192", - "1.2.840.10045.3.1.7": "p256", - "1.3.132.0.34": "p384", - "1.3.132.0.35": "p521" -} + // BN -},{}],162:[function(require,module,exports){ -(function (Buffer){ -var createHash = require('create-hash') -var stream = require('stream') -var inherits = require('inherits') -var sign = require('./sign') -var verify = require('./verify') + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } -var algorithms = require('./algorithms.json') -Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = new Buffer(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] -}) + this.negative = 0; + this.words = null; + this.length = 0; -function Sign (algorithm) { - stream.Writable.call(this) + // Reduction context + this.red = null; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Sign, stream.Writable) + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + BN.BN = BN; + BN.wordSize = 26; -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } - this._hash.update(data) - return this -} + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; - return enc ? sig.toString(enc) : sig -} + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; -function Verify (algorithm) { - stream.Writable.call(this) + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Verify, stream.Writable) + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } - this._hash.update(data) - return this -} + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = new Buffer(sig, enc) + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) -} + if (endian !== 'le') return; -function createSign (algorithm) { - return new Sign(algorithm) -} + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; -function createVerify (algorithm) { - return new Verify(algorithm) -} + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } -module.exports = { - Sign: createSign, - Verify: createVerify, - createSign: createSign, - createVerify: createVerify -} + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } -}).call(this,require("buffer").Buffer) -},{"./algorithms.json":160,"./sign":163,"./verify":164,"buffer":131,"create-hash":139,"inherits":259,"stream":338}],163:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var createHmac = require('create-hmac') -var crt = require('browserify-rsa') -var EC = require('elliptic').ec -var BN = require('bn.js') -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; -function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) - if (priv.curve) { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) - } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [ 0, 1 ] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) - - var out = crt(pad, priv) - return out -} - -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) - return new Buffer(out.toDER()) -} - -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) - while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) - if (s.cmpn(0) === 0) { - s = false - r = new BN(0) + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } + return r; } - return toDER(r, s) -} -function toDER (r, s) { - r = r.toArray() - s = s.toArray() + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } - // Pad values - if (r[0] & 0x80) r = [ 0 ].concat(r) - if (s[0] & 0x80) s = [ 0 ].concat(s) + // 24-bits chunks + var off = 0; + var j = 0; - var total = r.length + s.length + 4 - var res = [ 0x30, total, 0x02, r.length ] - res = res.concat(r, [ 0x02, s.length ], s) - return new Buffer(res) -} + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } -function getKey (x, q, hash, algo) { - x = new Buffer(x.toArray()) - if (x.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - x.length) - zeros.fill(0) - x = Buffer.concat([ zeros, x ]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = new Buffer(hlen) - v.fill(1) - var k = new Buffer(hlen) - k.fill(0) - k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } -} + this._strip(); + }; -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits -} + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = new Buffer(bits.toArray()) - if (out.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - out.length) - zeros.fill(0) - out = Buffer.concat([ zeros, out ]) - } - return out -} + r *= mul; -function makeKey (q, kv, algo) { - var t - var k + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; - do { - t = new Buffer(0) + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; - while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([ t, kv.v ]) + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; } + return r; + } - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; - return k -} + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) -} + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); -}).call(this,require("buffer").Buffer) -},{"./curves.json":161,"bn.js":90,"browserify-rsa":158,"buffer":131,"create-hmac":141,"elliptic":221,"parse-asn1":169}],164:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var BN = require('bn.js') -var EC = require('elliptic').ec -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) - if (pub.type === 'ec') { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) - } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [ 1 ] - var padNum = 0 - while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - pad = new Buffer(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - sig = sig.redPow(new BN(pub.publicExponent)) - sig = new Buffer(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 + for (i = 0; i < mod; i++) { + pow *= base; + } - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 -} + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + this._strip(); + }; - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; - return curve.verify(hash, sig, pubkey) -} + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) - var v = g.toRed(montp) - .redPow(new BN(hash).mul(w).mod(q)) - .fromRed() - .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) - .mod(p) - .mod(q) - return v.cmp(r) === 0 -} + BN.prototype._move = function _move (dest) { + move(dest, this); + }; -function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') -} + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; -module.exports = verify + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; -}).call(this,require("buffer").Buffer) -},{"./curves.json":161,"bn.js":90,"buffer":131,"elliptic":221,"parse-asn1":169}],165:[function(require,module,exports){ -module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", -"2.16.840.1.101.3.4.1.2": "aes-128-cbc", -"2.16.840.1.101.3.4.1.3": "aes-128-ofb", -"2.16.840.1.101.3.4.1.4": "aes-128-cfb", -"2.16.840.1.101.3.4.1.21": "aes-192-ecb", -"2.16.840.1.101.3.4.1.22": "aes-192-cbc", -"2.16.840.1.101.3.4.1.23": "aes-192-ofb", -"2.16.840.1.101.3.4.1.24": "aes-192-cfb", -"2.16.840.1.101.3.4.1.41": "aes-256-ecb", -"2.16.840.1.101.3.4.1.42": "aes-256-cbc", -"2.16.840.1.101.3.4.1.43": "aes-256-ofb", -"2.16.840.1.101.3.4.1.44": "aes-256-cfb" -} -},{}],166:[function(require,module,exports){ -// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js -// Fedor, you are amazing. -'use strict' + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; -var asn1 = require('asn1.js') + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; -exports.certificate = require('./certificate') + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } -var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('modulus').int(), - this.key('publicExponent').int(), - this.key('privateExponent').int(), - this.key('prime1').int(), - this.key('prime2').int(), - this.key('exponent1').int(), - this.key('exponent2').int(), - this.key('coefficient').int() - ) -}) -exports.RSAPrivateKey = RSAPrivateKey + function inspect () { + return (this.red ? ''; + } -var RSAPublicKey = asn1.define('RSAPublicKey', function () { - this.seq().obj( - this.key('modulus').int(), - this.key('publicExponent').int() - ) -}) -exports.RSAPublicKey = RSAPublicKey + /* -var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) -exports.PublicKey = PublicKey + var zeros = []; + var groupSizes = []; + var groupBases = []; -var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('none').null_().optional(), - this.key('curve').objid().optional(), - this.key('params').seq().obj( - this.key('p').int(), - this.key('q').int(), - this.key('g').int() - ).optional() - ) -}) + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } -var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { - this.seq().obj( - this.key('version').int(), - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPrivateKey').octstr() - ) -}) -exports.PrivateKey = PrivateKeyInfo -var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { - this.seq().obj( - this.key('algorithm').seq().obj( - this.key('id').objid(), - this.key('decrypt').seq().obj( - this.key('kde').seq().obj( - this.key('id').objid(), - this.key('kdeparams').seq().obj( - this.key('salt').octstr(), - this.key('iters').int() - ) - ), - this.key('cipher').seq().obj( - this.key('algo').objid(), - this.key('iv').octstr() - ) - ) - ), - this.key('subjectPrivateKey').octstr() - ) -}) + */ -exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + var zeros = [ + '', + '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' + ]; -var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('p').int(), - this.key('q').int(), - this.key('g').int(), - this.key('pub_key').int(), - this.key('priv_key').int() - ) -}) -exports.DSAPrivateKey = DSAPrivateKey + var groupSizes = [ + 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 + ]; -exports.DSAparam = asn1.define('DSAparam', function () { - this.int() -}) + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; -var ECPrivateKey = asn1.define('ECPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('privateKey').octstr(), - this.key('parameters').optional().explicit(0).use(ECParameters), - this.key('publicKey').optional().explicit(1).bitstr() - ) -}) -exports.ECPrivateKey = ECPrivateKey + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; -var ECParameters = asn1.define('ECParameters', function () { - this.choice({ - namedCurve: this.objid() - }) -}) + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -exports.signature = asn1.define('signature', function () { - this.seq().obj( - this.key('r').int(), - this.key('s').int() - ) -}) + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); -},{"./certificate":167,"asn1.js":144}],167:[function(require,module,exports){ -// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js -// thanks to @Rantanen + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -'use strict' + assert(false, 'Base should be between 2 and 36'); + }; -var asn = require('asn1.js') + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; -var Time = asn.define('Time', function () { - this.choice({ - utcTime: this.utctime(), - generalTime: this.gentime() - }) -}) + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; -var AttributeTypeValue = asn.define('AttributeTypeValue', function () { - this.seq().obj( - this.key('type').objid(), - this.key('value').any() - ) -}) + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } -var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('parameters').optional() - ) -}) + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; -var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; -var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { - this.setof(AttributeTypeValue) -}) + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); -var RDNSequence = asn.define('RDNSequence', function () { - this.seqof(RelativeDistinguishedName) -}) + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); -var Name = asn.define('Name', function () { - this.choice({ - rdnSequence: this.use(RDNSequence) - }) -}) + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; -var Validity = asn.define('Validity', function () { - this.seq().obj( - this.key('notBefore').use(Time), - this.key('notAfter').use(Time) - ) -}) + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; -var Extension = asn.define('Extension', function () { - this.seq().obj( - this.key('extnID').objid(), - this.key('critical').bool().def(false), - this.key('extnValue').octstr() - ) -}) + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; -var TBSCertificate = asn.define('TBSCertificate', function () { - this.seq().obj( - this.key('version').explicit(0).int(), - this.key('serialNumber').int(), - this.key('signature').use(AlgorithmIdentifier), - this.key('issuer').use(Name), - this.key('validity').use(Validity), - this.key('subject').use(Name), - this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), - this.key('issuerUniqueID').implicit(1).bitstr().optional(), - this.key('subjectUniqueID').implicit(2).bitstr().optional(), - this.key('extensions').explicit(3).seqof(Extension).optional() - ) -}) + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } -var X509Certificate = asn.define('X509Certificate', function () { - this.seq().obj( - this.key('tbsCertificate').use(TBSCertificate), - this.key('signatureAlgorithm').use(AlgorithmIdentifier), - this.key('signatureValue').bitstr() - ) -}) + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } -module.exports = X509Certificate + if (position < res.length) { + res[position++] = carry; -},{"asn1.js":144}],168:[function(require,module,exports){ -(function (Buffer){ -// adapted from https://github.com/apatil/pemstrip -var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m -var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m -var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m -var evp = require('evp_bytestokey') -var ciphers = require('browserify-aes') -module.exports = function (okey, password) { - var key = okey.toString() - var match = key.match(findProc) - var decrypted - if (!match) { - var match2 = key.match(fullRegex) - decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64') - } else { - var suite = 'aes' + match[1] - var iv = new Buffer(match[2], 'hex') - var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64') - var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key - var out = [] - var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - decrypted = Buffer.concat(out) - } - var tag = key.match(startRegex)[1] - return { - tag: tag, - data: decrypted - } -} + while (position < res.length) { + res[position++] = 0; + } + } + }; -}).call(this,require("buffer").Buffer) -},{"browserify-aes":107,"buffer":131,"evp_bytestokey":237}],169:[function(require,module,exports){ -(function (Buffer){ -var asn1 = require('./asn1') -var aesid = require('./aesid.json') -var fixProc = require('./fixProc') -var ciphers = require('browserify-aes') -var compat = require('pbkdf2') -module.exports = parseKeys + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; -function parseKeys (buffer) { - var password - if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { - password = buffer.passphrase - buffer = buffer.key - } - if (typeof buffer === 'string') { - buffer = new Buffer(buffer) - } + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; - var stripped = fixProc(buffer, password) + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } - var type = stripped.tag - var data = stripped.data - var subtype, ndata - switch (type) { - case 'CERTIFICATE': - ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo - // falls through - case 'PUBLIC KEY': - if (!ndata) { - ndata = asn1.PublicKey.decode(data, 'der') + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; } - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') - case '1.2.840.10045.2.1': - ndata.subjectPrivateKey = ndata.subjectPublicKey - return { - type: 'ec', - data: ndata - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') - return { - type: 'dsa', - data: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; } - throw new Error('unknown key type ' + type) - case 'ENCRYPTED PRIVATE KEY': - data = asn1.EncryptedPrivateKey.decode(data, 'der') - data = decrypt(data, password) - // falls through - case 'PRIVATE KEY': - ndata = asn1.PrivateKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') - case '1.2.840.10045.2.1': - return { - curve: ndata.algorithm.curve, - privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') - return { - type: 'dsa', - params: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; } - throw new Error('unknown key type ' + type) - case 'RSA PUBLIC KEY': - return asn1.RSAPublicKey.decode(data, 'der') - case 'RSA PRIVATE KEY': - return asn1.RSAPrivateKey.decode(data, 'der') - case 'DSA PRIVATE KEY': - return { - type: 'dsa', - params: asn1.DSAPrivateKey.decode(data, 'der') + if (t >= 0x40) { + r += 7; + t >>>= 7; } - case 'EC PRIVATE KEY': - data = asn1.ECPrivateKey.decode(data, 'der') - return { - curve: data.parameters.value, - privateKey: data.privateKey + if (t >= 0x8) { + r += 4; + t >>>= 4; } - default: throw new Error('unknown key type ' + type) + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; } -} -parseKeys.signature = asn1.signature -function decrypt (data, password) { - var salt = data.algorithm.decrypt.kde.kdeparams.salt - var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) - var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] - var iv = data.algorithm.decrypt.cipher.iv - var cipherText = data.subjectPrivateKey - var keylen = parseInt(algo.split('-')[1], 10) / 8 - var key = compat.pbkdf2Sync(password, salt, iters, keylen) - var cipher = ciphers.createDecipheriv(algo, key, iv) - var out = [] - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - return Buffer.concat(out) -} -}).call(this,require("buffer").Buffer) -},{"./aesid.json":165,"./asn1":166,"./fixProc":168,"browserify-aes":107,"buffer":131,"pbkdf2":269}],170:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; - // Lookup tables - var SBOX = []; - var INV_SBOX = []; - var SUB_MIX_0 = []; - var SUB_MIX_1 = []; - var SUB_MIX_2 = []; - var SUB_MIX_3 = []; - var INV_SUB_MIX_0 = []; - var INV_SUB_MIX_1 = []; - var INV_SUB_MIX_2 = []; - var INV_SUB_MIX_3 = []; + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; - // Compute lookup tables - (function () { - // Compute double table - var d = []; - for (var i = 0; i < 256; i++) { - if (i < 128) { - d[i] = i << 1; - } else { - d[i] = (i << 1) ^ 0x11b; - } - } + function toBitArray (num) { + var w = new Array(num.bitLength()); - // Walk GF(2^8) - var x = 0; - var xi = 0; - for (var i = 0; i < 256; i++) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; - SBOX[x] = sx; - INV_SBOX[sx] = x; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - // Compute multiplication - var x2 = d[x]; - var x4 = d[x2]; - var x8 = d[x4]; + w[bit] = (num.words[off] >>> wbit) & 0x01; + } - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100); - SUB_MIX_0[x] = (t << 24) | (t >>> 8); - SUB_MIX_1[x] = (t << 16) | (t >>> 16); - SUB_MIX_2[x] = (t << 8) | (t >>> 24); - SUB_MIX_3[x] = t; + return w; + } - // Compute inv sub bytes, inv mix columns tables - var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); - INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); - INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); - INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); - INV_SUB_MIX_3[sx] = t; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - // Compute next counter - if (!x) { - x = xi = 1; - } else { - x = x2 ^ d[d[d[x8 ^ x2]]]; - xi ^= d[d[xi]]; - } - } - }()); + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; - // Precomputed Rcon lookup - var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; - /** - * AES block cipher algorithm. - */ - var AES = C_algo.AES = BlockCipher.extend({ - _doReset: function () { - // Skip reset of nRounds has been set before and key did not change - if (this._nRounds && this._keyPriorReset === this._key) { - return; - } + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; - // Shortcuts - var key = this._keyPriorReset = this._key; - var keyWords = key.words; - var keySize = key.sigBytes / 4; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; - // Compute number of rounds - var nRounds = this._nRounds = keySize + 6; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; - // Compute number of key schedule rows - var ksRows = (nRounds + 1) * 4; + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; - // Compute key schedule - var keySchedule = this._keySchedule = []; - for (var ksRow = 0; ksRow < ksRows; ksRow++) { - if (ksRow < keySize) { - keySchedule[ksRow] = keyWords[ksRow]; - } else { - var t = keySchedule[ksRow - 1]; + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } - if (!(ksRow % keySize)) { - // Rot word - t = (t << 8) | (t >>> 24); + return this; + }; - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } - // Mix Rcon - t ^= RCON[(ksRow / keySize) | 0] << 24; - } else if (keySize > 6 && ksRow % keySize == 4) { - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - } + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } - keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; - } - } + return this._strip(); + }; - // Compute inv key schedule - var invKeySchedule = this._invKeySchedule = []; - for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { - var ksRow = ksRows - invKsRow; + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; - if (invKsRow % 4) { - var t = keySchedule[ksRow]; - } else { - var t = keySchedule[ksRow - 4]; - } + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; - if (invKsRow < 4 || ksRow <= 4) { - invKeySchedule[invKsRow] = t; - } else { - invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ - INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; - } - } - }, + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); - }, + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } - decryptBlock: function (M, offset) { - // Swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } - this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + this.length = b.length; - // Inv swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; - }, + return this._strip(); + }; - _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { - // Shortcut - var nRounds = this._nRounds; + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; - // Get input, add round key - var s0 = M[offset] ^ keySchedule[0]; - var s1 = M[offset + 1] ^ keySchedule[1]; - var s2 = M[offset + 2] ^ keySchedule[2]; - var s3 = M[offset + 3] ^ keySchedule[3]; + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; - // Key schedule row counter - var ksRow = 4; + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - // Rounds - for (var round = 1; round < nRounds; round++) { - // Shift rows, sub bytes, mix columns, add round key - var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; - var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; - var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; - var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - // Update state - s0 = t0; - s1 = t1; - s2 = t2; - s3 = t3; - } + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } - // Shift rows, sub bytes, add round key - var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; - var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; - var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; - var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - // Set output - M[offset] = t0; - M[offset + 1] = t1; - M[offset + 2] = t2; - M[offset + 3] = t3; - }, + this.length = a.length; - keySize: 256/32 - }); + return this._strip(); + }; - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); - */ - C.AES = BlockCipher._createHelper(AES); - }()); + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; - return CryptoJS.AES; + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; -})); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],171:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - /** - * Cipher core components. - */ - CryptoJS.lib.Cipher || (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var Base64 = C_enc.Base64; - var C_algo = C.algo; - var EvpKDF = C_algo.EvpKDF; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - /** - * Abstract base cipher template. - * - * @property {number} keySize This cipher's key size. Default: 4 (128 bits) - * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) - * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. - * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. - */ - var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - * - * @property {WordArray} iv The IV to use for this operation. - */ - cfg: Base.extend(), + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - /** - * Creates this cipher in encryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); - */ - createEncryptor: function (key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); - }, + if (bitsLeft > 0) { + bytesNeeded--; + } - /** - * Creates this cipher in decryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); - */ - createDecryptor: function (key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); - }, + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - /** - * Initializes a newly created cipher. - * - * @param {number} xformMode Either the encryption or decryption transormation mode constant. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @example - * - * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); - */ - init: function (xformMode, key, cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - // Store transform mode and key - this._xformMode = xformMode; - this._key = key; + // And remove leading zeroes + return this._strip(); + }; - // Set initial values - this.reset(); - }, + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; - /** - * Resets this cipher to its initial state. - * - * @example - * - * cipher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - // Perform concrete-cipher logic - this._doReset(); - }, + var off = (bit / 26) | 0; + var wbit = bit % 26; - /** - * Adds data to be encrypted or decrypted. - * - * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. - * - * @return {WordArray} The data after processing. - * - * @example - * - * var encrypted = cipher.process('data'); - * var encrypted = cipher.process(wordArray); - */ - process: function (dataUpdate) { - // Append - this._append(dataUpdate); + this._expand(off + 1); - // Process available blocks - return this._process(); - }, + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } - /** - * Finalizes the encryption or decryption process. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. - * - * @return {WordArray} The data after final processing. - * - * @example - * - * var encrypted = cipher.finalize(); - * var encrypted = cipher.finalize('data'); - * var encrypted = cipher.finalize(wordArray); - */ - finalize: function (dataUpdate) { - // Final data update - if (dataUpdate) { - this._append(dataUpdate); - } + return this._strip(); + }; - // Perform concrete-cipher logic - var finalProcessedData = this._doFinalize(); + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; - return finalProcessedData; - }, + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); - keySize: 128/32, + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } - ivSize: 128/32, + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - _ENC_XFORM_MODE: 1, + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } - _DEC_XFORM_MODE: 2, + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * Creates shortcut functions to a cipher's object interface. - * - * @param {Cipher} cipher The cipher to create a helper for. - * - * @return {Object} An object with encrypt and decrypt shortcut functions. - * - * @static - * - * @example - * - * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); - */ - _createHelper: (function () { - function selectCipherStrategy(key) { - if (typeof key == 'string') { - return PasswordBasedCipher; - } else { - return SerializableCipher; - } - } + return this; + }; - return function (cipher) { - return { - encrypt: function (message, key, cfg) { - return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); - }, + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } - decrypt: function (ciphertext, key, cfg) { - return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); - } - }; - }; - }()) - }); + if (this.length > num.length) return this.clone().iadd(num); - /** - * Abstract base stream cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) - */ - var StreamCipher = C_lib.StreamCipher = Cipher.extend({ - _doFinalize: function () { - // Process partial blocks - var finalProcessedBlocks = this._process(!!'flush'); + return num.clone().iadd(this); + }; - return finalProcessedBlocks; - }, + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); - blockSize: 1 - }); + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } - /** - * Mode namespace. - */ - var C_mode = C.mode = {}; + // At this point both numbers are positive + var cmp = this.cmp(num); - /** - * Abstract base block cipher mode template. - */ - var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ - /** - * Creates this mode for encryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); - */ - createEncryptor: function (cipher, iv) { - return this.Encryptor.create(cipher, iv); - }, + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } - /** - * Creates this mode for decryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); - */ - createDecryptor: function (cipher, iv) { - return this.Decryptor.create(cipher, iv); - }, + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * Initializes a newly created mode. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @example - * - * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); - */ - init: function (cipher, iv) { - this._cipher = cipher; - this._iv = iv; - } - }); + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } - /** - * Cipher Block Chaining mode. - */ - var CBC = C_mode.CBC = (function () { - /** - * Abstract base CBC mode. - */ - var CBC = BlockCipherMode.extend(); + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * CBC encryptor. - */ - CBC.Encryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; + this.length = Math.max(this.length, i); - // XOR and encrypt - xorBlock.call(this, words, offset, blockSize); - cipher.encryptBlock(words, offset); + if (a !== this) { + this.negative = 1; + } - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); - - /** - * CBC decryptor. - */ - CBC.Decryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); - - // Decrypt and XOR - cipher.decryptBlock(words, offset); - xorBlock.call(this, words, offset, blockSize); - - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); - - function xorBlock(words, offset, blockSize) { - // Shortcut - var iv = this._iv; - - // Choose mixing block - if (iv) { - var block = iv; - - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - var block = this._prevBlock; - } - - // XOR blocks - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= block[i]; - } - } - - return CBC; - }()); - - /** - * Padding namespace. - */ - var C_pad = C.pad = {}; - - /** - * PKCS #5/7 padding strategy. - */ - var Pkcs7 = C_pad.Pkcs7 = { - /** - * Pads data using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to pad. - * @param {number} blockSize The multiple that the data should be padded to. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.pad(wordArray, 4); - */ - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Create padding word - var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; - - // Create padding - var paddingWords = []; - for (var i = 0; i < nPaddingBytes; i += 4) { - paddingWords.push(paddingWord); - } - var padding = WordArray.create(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - - /** - * Unpads data that had been padded using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to unpad. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.unpad(wordArray); - */ - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; - - /** - * Abstract base block cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) - */ - var BlockCipher = C_lib.BlockCipher = Cipher.extend({ - /** - * Configuration options. - * - * @property {Mode} mode The block mode to use. Default: CBC - * @property {Padding} padding The padding strategy to use. Default: Pkcs7 - */ - cfg: Cipher.cfg.extend({ - mode: CBC, - padding: Pkcs7 - }), - - reset: function () { - // Reset cipher - Cipher.reset.call(this); - - // Shortcuts - var cfg = this.cfg; - var iv = cfg.iv; - var mode = cfg.mode; - - // Reset block mode - if (this._xformMode == this._ENC_XFORM_MODE) { - var modeCreator = mode.createEncryptor; - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - var modeCreator = mode.createDecryptor; - - // Keep at least one block in the buffer for unpadding - this._minBufferSize = 1; - } - this._mode = modeCreator.call(mode, this, iv && iv.words); - }, - - _doProcessBlock: function (words, offset) { - this._mode.processBlock(words, offset); - }, - - _doFinalize: function () { - // Shortcut - var padding = this.cfg.padding; - - // Finalize - if (this._xformMode == this._ENC_XFORM_MODE) { - // Pad data - padding.pad(this._data, this.blockSize); - - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - - // Unpad data - padding.unpad(finalProcessedBlocks); - } - - return finalProcessedBlocks; - }, - - blockSize: 128/32 - }); - - /** - * A collection of cipher parameters. - * - * @property {WordArray} ciphertext The raw ciphertext. - * @property {WordArray} key The key to this ciphertext. - * @property {WordArray} iv The IV used in the ciphering operation. - * @property {WordArray} salt The salt used with a key derivation function. - * @property {Cipher} algorithm The cipher algorithm. - * @property {Mode} mode The block mode used in the ciphering operation. - * @property {Padding} padding The padding scheme used in the ciphering operation. - * @property {number} blockSize The block size of the cipher. - * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. - */ - var CipherParams = C_lib.CipherParams = Base.extend({ - /** - * Initializes a newly created cipher params object. - * - * @param {Object} cipherParams An object with any of the possible cipher parameters. - * - * @example - * - * var cipherParams = CryptoJS.lib.CipherParams.create({ - * ciphertext: ciphertextWordArray, - * key: keyWordArray, - * iv: ivWordArray, - * salt: saltWordArray, - * algorithm: CryptoJS.algo.AES, - * mode: CryptoJS.mode.CBC, - * padding: CryptoJS.pad.PKCS7, - * blockSize: 4, - * formatter: CryptoJS.format.OpenSSL - * }); - */ - init: function (cipherParams) { - this.mixIn(cipherParams); - }, - - /** - * Converts this cipher params object to a string. - * - * @param {Format} formatter (Optional) The formatting strategy to use. - * - * @return {string} The stringified cipher params. - * - * @throws Error If neither the formatter nor the default formatter is set. - * - * @example - * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); - */ - toString: function (formatter) { - return (formatter || this.formatter).stringify(this); - } - }); - - /** - * Format namespace. - */ - var C_format = C.format = {}; - - /** - * OpenSSL formatting strategy. - */ - var OpenSSLFormatter = C_format.OpenSSL = { - /** - * Converts a cipher params object to an OpenSSL-compatible string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The OpenSSL-compatible string. - * - * @static - * - * @example - * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); - */ - stringify: function (cipherParams) { - // Shortcuts - var ciphertext = cipherParams.ciphertext; - var salt = cipherParams.salt; - - // Format - if (salt) { - var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); - } else { - var wordArray = ciphertext; - } - - return wordArray.toString(Base64); - }, - - /** - * Converts an OpenSSL-compatible string to a cipher params object. - * - * @param {string} openSSLStr The OpenSSL-compatible string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); - */ - parse: function (openSSLStr) { - // Parse base64 - var ciphertext = Base64.parse(openSSLStr); - - // Shortcut - var ciphertextWords = ciphertext.words; - - // Test for salt - if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { - // Extract salt - var salt = WordArray.create(ciphertextWords.slice(2, 4)); - - // Remove salt from ciphertext - ciphertextWords.splice(0, 4); - ciphertext.sigBytes -= 16; - } - - return CipherParams.create({ ciphertext: ciphertext, salt: salt }); - } - }; - - /** - * A cipher wrapper that returns ciphertext as a serializable cipher params object. - */ - var SerializableCipher = C_lib.SerializableCipher = Base.extend({ - /** - * Configuration options. - * - * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL - */ - cfg: Base.extend({ - format: OpenSSLFormatter - }), - - /** - * Encrypts a message. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + return this._strip(); + }; - // Encrypt - var encryptor = cipher.createEncryptor(key, cfg); - var ciphertext = encryptor.finalize(message); + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; - // Shortcut - var cipherCfg = encryptor.cfg; + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; - // Create and return serializable cipher params - return CipherParams.create({ - ciphertext: ciphertext, - key: key, - iv: cipherCfg.iv, - algorithm: cipher, - mode: cipherCfg.mode, - padding: cipherCfg.padding, - blockSize: cipher.blockSize, - formatter: cfg.format - }); - }, + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; - /** - * Decrypts serialized ciphertext. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } - // Decrypt - var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return out._strip(); + } - return plaintext; - }, + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; - /** - * Converts serialized ciphertext to CipherParams, - * else assumed CipherParams already and returns ciphertext unchanged. - * - * @param {CipherParams|string} ciphertext The ciphertext. - * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. - * - * @return {CipherParams} The unserialized ciphertext. - * - * @static + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out._strip(); + } + + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out._strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this._strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this._strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this._strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this._strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this._strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this._strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return isNegNum ? -acc : acc; + }; + + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + this._strip(); + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this._strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); + +},{"buffer":239}],159:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js') +var randomBytes = require('randombytes') + +function blind (priv) { + var r = getr(priv) + var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() + return { blinder: blinder, unblinder: r.invm(priv.modulus) } +} + +function getr (priv) { + var len = priv.modulus.byteLength() + var r + do { + r = new BN(randomBytes(len)) + } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) + return r +} + +function crt (msg, priv) { + var blinds = blind(priv) + var len = priv.modulus.byteLength() + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) + var c1 = blinded.toRed(BN.mont(priv.prime1)) + var c2 = blinded.toRed(BN.mont(priv.prime2)) + var qinv = priv.coefficient + var p = priv.prime1 + var q = priv.prime2 + var m1 = c1.redPow(priv.exponent1).fromRed() + var m2 = c2.redPow(priv.exponent2).fromRed() + var h = m1.isub(m2).imul(qinv).umod(p).imul(q) + return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) +} +crt.getr = getr + +module.exports = crt + +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":158,"buffer":130,"randombytes":327}],160:[function(require,module,exports){ +module.exports = require('./browser/algorithms.json') + +},{"./browser/algorithms.json":161}],161:[function(require,module,exports){ +module.exports={ + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } +} + +},{}],162:[function(require,module,exports){ +module.exports={ + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" +} + +},{}],163:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var createHash = require('create-hash') +var stream = require('readable-stream') +var inherits = require('inherits') +var sign = require('./sign') +var verify = require('./verify') + +var algorithms = require('./algorithms.json') +Object.keys(algorithms).forEach(function (key) { + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') + algorithms[key.toLowerCase()] = algorithms[key] +}) + +function Sign (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hashType = data.hash + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Sign, stream.Writable) + +Sign.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Sign.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Sign.prototype.sign = function signMethod (key, enc) { + this.end() + var hash = this._hash.digest() + var sig = sign(hash, key, this._hashType, this._signType, this._tag) + + return enc ? sig.toString(enc) : sig +} + +function Verify (algorithm) { + stream.Writable.call(this) + + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') + + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Verify, stream.Writable) + +Verify.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} + +Verify.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) + + this._hash.update(data) + return this +} + +Verify.prototype.verify = function verifyMethod (key, sig, enc) { + if (typeof sig === 'string') sig = Buffer.from(sig, enc) + + this.end() + var hash = this._hash.digest() + return verify(sig, hash, key, this._signType, this._tag) +} + +function createSign (algorithm) { + return new Sign(algorithm) +} + +function createVerify (algorithm) { + return new Verify(algorithm) +} + +module.exports = { + Sign: createSign, + Verify: createVerify, + createSign: createSign, + createVerify: createVerify +} + +},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,"inherits":279,"readable-stream":343,"safe-buffer":345}],164:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var createHmac = require('create-hmac') +var crt = require('browserify-rsa') +var EC = require('elliptic').ec +var BN = require('bn.js') +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function sign (hash, key, hashType, signType, tag) { + var priv = parseKeys(key) + if (priv.curve) { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + return ecSign(hash, priv) + } else if (priv.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong private key type') + return dsaSign(hash, priv, hashType) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + } + hash = Buffer.concat([tag, hash]) + var len = priv.modulus.byteLength() + var pad = [0, 1] + while (hash.length + pad.length + 1 < len) pad.push(0xff) + pad.push(0x00) + var i = -1 + while (++i < hash.length) pad.push(hash[i]) + + var out = crt(pad, priv) + return out +} + +function ecSign (hash, priv) { + var curveId = curves[priv.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) + + var curve = new EC(curveId) + var key = curve.keyFromPrivate(priv.privateKey) + var out = key.sign(hash) + + return Buffer.from(out.toDER()) +} + +function dsaSign (hash, priv, algo) { + var x = priv.params.priv_key + var p = priv.params.p + var q = priv.params.q + var g = priv.params.g + var r = new BN(0) + var k + var H = bits2int(hash, q).mod(q) + var s = false + var kv = getKey(x, q, hash, algo) + while (s === false) { + k = makeKey(q, kv, algo) + r = makeR(g, k, p, q) + s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + if (s.cmpn(0) === 0) { + s = false + r = new BN(0) + } + } + return toDER(r, s) +} + +function toDER (r, s) { + r = r.toArray() + s = s.toArray() + + // Pad values + if (r[0] & 0x80) r = [0].concat(r) + if (s[0] & 0x80) s = [0].concat(s) + + var total = r.length + s.length + 4 + var res = [0x30, total, 0x02, r.length] + res = res.concat(r, [0x02, s.length], s) + return Buffer.from(res) +} + +function getKey (x, q, hash, algo) { + x = Buffer.from(x.toArray()) + if (x.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - x.length) + x = Buffer.concat([zeros, x]) + } + var hlen = hash.length + var hbits = bits2octets(hash, q) + var v = Buffer.alloc(hlen) + v.fill(1) + var k = Buffer.alloc(hlen) + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + return { k: k, v: v } +} + +function bits2int (obits, q) { + var bits = new BN(obits) + var shift = (obits.length << 3) - q.bitLength() + if (shift > 0) bits.ishrn(shift) + return bits +} + +function bits2octets (bits, q) { + bits = bits2int(bits, q) + bits = bits.mod(q) + var out = Buffer.from(bits.toArray()) + if (out.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - out.length) + out = Buffer.concat([zeros, out]) + } + return out +} + +function makeKey (q, kv, algo) { + var t + var k + + do { + t = Buffer.alloc(0) + + while (t.length * 8 < q.bitLength()) { + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + t = Buffer.concat([t, kv.v]) + } + + k = bits2int(t, q) + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + } while (k.cmp(q) !== -1) + + return k +} + +function makeR (g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +} + +module.exports = sign +module.exports.getKey = getKey +module.exports.makeKey = makeKey + +},{"./curves.json":162,"bn.js":158,"browserify-rsa":159,"create-hmac":140,"elliptic":222,"parse-asn1":170,"safe-buffer":345}],165:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var BN = require('bn.js') +var EC = require('elliptic').ec +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') + +function verify (sig, hash, key, signType, tag) { + var pub = parseKeys(key) + if (pub.type === 'ec') { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + return ecVerify(sig, hash, pub) + } else if (pub.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong public key type') + return dsaVerify(sig, hash, pub) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + } + hash = Buffer.concat([tag, hash]) + var len = pub.modulus.byteLength() + var pad = [1] + var padNum = 0 + while (hash.length + pad.length + 2 < len) { + pad.push(0xff) + padNum++ + } + pad.push(0x00) + var i = -1 + while (++i < hash.length) { + pad.push(hash[i]) + } + pad = Buffer.from(pad) + var red = BN.mont(pub.modulus) + sig = new BN(sig).toRed(red) + + sig = sig.redPow(new BN(pub.publicExponent)) + sig = Buffer.from(sig.fromRed().toArray()) + var out = padNum < 8 ? 1 : 0 + len = Math.min(sig.length, pad.length) + if (sig.length !== pad.length) out = 1 + + i = -1 + while (++i < len) out |= sig[i] ^ pad[i] + return out === 0 +} + +function ecVerify (sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + + var curve = new EC(curveId) + var pubkey = pub.data.subjectPrivateKey.data + + return curve.verify(hash, sig, pubkey) +} + +function dsaVerify (sig, hash, pub) { + var p = pub.data.p + var q = pub.data.q + var g = pub.data.g + var y = pub.data.pub_key + var unpacked = parseKeys.signature.decode(sig, 'der') + var s = unpacked.s + var r = unpacked.r + checkValue(s, q) + checkValue(r, q) + var montp = BN.mont(p) + var w = s.invm(q) + var v = g.toRed(montp) + .redPow(new BN(hash).mul(w).mod(q)) + .fromRed() + .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) + .mod(p) + .mod(q) + return v.cmp(r) === 0 +} + +function checkValue (b, q) { + if (b.cmpn(0) <= 0) throw new Error('invalid sig') + if (b.cmp(q) >= q) throw new Error('invalid sig') +} + +module.exports = verify + +},{"./curves.json":162,"bn.js":158,"elliptic":222,"parse-asn1":170,"safe-buffer":345}],166:[function(require,module,exports){ +module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", +"2.16.840.1.101.3.4.1.2": "aes-128-cbc", +"2.16.840.1.101.3.4.1.3": "aes-128-ofb", +"2.16.840.1.101.3.4.1.4": "aes-128-cfb", +"2.16.840.1.101.3.4.1.21": "aes-192-ecb", +"2.16.840.1.101.3.4.1.22": "aes-192-cbc", +"2.16.840.1.101.3.4.1.23": "aes-192-ofb", +"2.16.840.1.101.3.4.1.24": "aes-192-cfb", +"2.16.840.1.101.3.4.1.41": "aes-256-ecb", +"2.16.840.1.101.3.4.1.42": "aes-256-cbc", +"2.16.840.1.101.3.4.1.43": "aes-256-ofb", +"2.16.840.1.101.3.4.1.44": "aes-256-cfb" +} +},{}],167:[function(require,module,exports){ +// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js +// Fedor, you are amazing. +'use strict' + +var asn1 = require('asn1.js') + +exports.certificate = require('./certificate') + +var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('modulus').int(), + this.key('publicExponent').int(), + this.key('privateExponent').int(), + this.key('prime1').int(), + this.key('prime2').int(), + this.key('exponent1').int(), + this.key('exponent2').int(), + this.key('coefficient').int() + ) +}) +exports.RSAPrivateKey = RSAPrivateKey + +var RSAPublicKey = asn1.define('RSAPublicKey', function () { + this.seq().obj( + this.key('modulus').int(), + this.key('publicExponent').int() + ) +}) +exports.RSAPublicKey = RSAPublicKey + +var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) +exports.PublicKey = PublicKey + +var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('none').null_().optional(), + this.key('curve').objid().optional(), + this.key('params').seq().obj( + this.key('p').int(), + this.key('q').int(), + this.key('g').int() + ).optional() + ) +}) + +var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { + this.seq().obj( + this.key('version').int(), + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPrivateKey').octstr() + ) +}) +exports.PrivateKey = PrivateKeyInfo +var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { + this.seq().obj( + this.key('algorithm').seq().obj( + this.key('id').objid(), + this.key('decrypt').seq().obj( + this.key('kde').seq().obj( + this.key('id').objid(), + this.key('kdeparams').seq().obj( + this.key('salt').octstr(), + this.key('iters').int() + ) + ), + this.key('cipher').seq().obj( + this.key('algo').objid(), + this.key('iv').octstr() + ) + ) + ), + this.key('subjectPrivateKey').octstr() + ) +}) + +exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + +var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('p').int(), + this.key('q').int(), + this.key('g').int(), + this.key('pub_key').int(), + this.key('priv_key').int() + ) +}) +exports.DSAPrivateKey = DSAPrivateKey + +exports.DSAparam = asn1.define('DSAparam', function () { + this.int() +}) + +var ECPrivateKey = asn1.define('ECPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('privateKey').octstr(), + this.key('parameters').optional().explicit(0).use(ECParameters), + this.key('publicKey').optional().explicit(1).bitstr() + ) +}) +exports.ECPrivateKey = ECPrivateKey + +var ECParameters = asn1.define('ECParameters', function () { + this.choice({ + namedCurve: this.objid() + }) +}) + +exports.signature = asn1.define('signature', function () { + this.seq().obj( + this.key('r').int(), + this.key('s').int() + ) +}) + +},{"./certificate":168,"asn1.js":143}],168:[function(require,module,exports){ +// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js +// thanks to @Rantanen + +'use strict' + +var asn = require('asn1.js') + +var Time = asn.define('Time', function () { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }) +}) + +var AttributeTypeValue = asn.define('AttributeTypeValue', function () { + this.seq().obj( + this.key('type').objid(), + this.key('value').any() + ) +}) + +var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('parameters').optional(), + this.key('curve').objid().optional() + ) +}) + +var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) + +var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { + this.setof(AttributeTypeValue) +}) + +var RDNSequence = asn.define('RDNSequence', function () { + this.seqof(RelativeDistinguishedName) +}) + +var Name = asn.define('Name', function () { + this.choice({ + rdnSequence: this.use(RDNSequence) + }) +}) + +var Validity = asn.define('Validity', function () { + this.seq().obj( + this.key('notBefore').use(Time), + this.key('notAfter').use(Time) + ) +}) + +var Extension = asn.define('Extension', function () { + this.seq().obj( + this.key('extnID').objid(), + this.key('critical').bool().def(false), + this.key('extnValue').octstr() + ) +}) + +var TBSCertificate = asn.define('TBSCertificate', function () { + this.seq().obj( + this.key('version').explicit(0).int().optional(), + this.key('serialNumber').int(), + this.key('signature').use(AlgorithmIdentifier), + this.key('issuer').use(Name), + this.key('validity').use(Validity), + this.key('subject').use(Name), + this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), + this.key('issuerUniqueID').implicit(1).bitstr().optional(), + this.key('subjectUniqueID').implicit(2).bitstr().optional(), + this.key('extensions').explicit(3).seqof(Extension).optional() + ) +}) + +var X509Certificate = asn.define('X509Certificate', function () { + this.seq().obj( + this.key('tbsCertificate').use(TBSCertificate), + this.key('signatureAlgorithm').use(AlgorithmIdentifier), + this.key('signatureValue').bitstr() + ) +}) + +module.exports = X509Certificate + +},{"asn1.js":143}],169:[function(require,module,exports){ +// adapted from https://github.com/apatil/pemstrip +var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m +var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m +var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m +var evp = require('evp_bytestokey') +var ciphers = require('browserify-aes') +var Buffer = require('safe-buffer').Buffer +module.exports = function (okey, password) { + var key = okey.toString() + var match = key.match(findProc) + var decrypted + if (!match) { + var match2 = key.match(fullRegex) + decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') + } else { + var suite = 'aes' + match[1] + var iv = Buffer.from(match[2], 'hex') + var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key + var out = [] + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + decrypted = Buffer.concat(out) + } + var tag = key.match(startRegex)[1] + return { + tag: tag, + data: decrypted + } +} + +},{"browserify-aes":106,"evp_bytestokey":238,"safe-buffer":345}],170:[function(require,module,exports){ +var asn1 = require('./asn1') +var aesid = require('./aesid.json') +var fixProc = require('./fixProc') +var ciphers = require('browserify-aes') +var compat = require('pbkdf2') +var Buffer = require('safe-buffer').Buffer +module.exports = parseKeys + +function parseKeys (buffer) { + var password + if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { + password = buffer.passphrase + buffer = buffer.key + } + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer) + } + + var stripped = fixProc(buffer, password) + + var type = stripped.tag + var data = stripped.data + var subtype, ndata + switch (type) { + case 'CERTIFICATE': + ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo + // falls through + case 'PUBLIC KEY': + if (!ndata) { + ndata = asn1.PublicKey.decode(data, 'der') + } + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') + case '1.2.840.10045.2.1': + ndata.subjectPrivateKey = ndata.subjectPublicKey + return { + type: 'ec', + data: ndata + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') + return { + type: 'dsa', + data: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'ENCRYPTED PRIVATE KEY': + data = asn1.EncryptedPrivateKey.decode(data, 'der') + data = decrypt(data, password) + // falls through + case 'PRIVATE KEY': + ndata = asn1.PrivateKey.decode(data, 'der') + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') + case '1.2.840.10045.2.1': + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') + return { + type: 'dsa', + params: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'RSA PUBLIC KEY': + return asn1.RSAPublicKey.decode(data, 'der') + case 'RSA PRIVATE KEY': + return asn1.RSAPrivateKey.decode(data, 'der') + case 'DSA PRIVATE KEY': + return { + type: 'dsa', + params: asn1.DSAPrivateKey.decode(data, 'der') + } + case 'EC PRIVATE KEY': + data = asn1.ECPrivateKey.decode(data, 'der') + return { + curve: data.parameters.value, + privateKey: data.privateKey + } + default: throw new Error('unknown key type ' + type) + } +} +parseKeys.signature = asn1.signature +function decrypt (data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) + var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] + var iv = data.algorithm.decrypt.cipher.iv + var cipherText = data.subjectPrivateKey + var keylen = parseInt(algo.split('-')[1], 10) / 8 + var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') + var cipher = ciphers.createDecipheriv(algo, key, iv) + var out = [] + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + return Buffer.concat(out) +} + +},{"./aesid.json":166,"./asn1":167,"./fixProc":169,"browserify-aes":106,"pbkdf2":290,"safe-buffer":345}],171:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + + // Compute lookup tables + (function () { + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } + + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); + + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; + + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; + + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + var t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; + + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + var ksRow = 4; + + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + + keySize: 256/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + C.AES = BlockCipher._createHelper(AES); + }()); + + + return CryptoJS.AES; + +})); +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./evpkdf")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./evpkdf"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + /** + * Cipher core components. + */ + CryptoJS.lib.Cipher || (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + + /** + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. + */ + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function (key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function (key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function (xformMode, key, cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; + + // Set initial values + this.reset(); + }, + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-cipher logic + this._doReset(); + }, + + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function (dataUpdate) { + // Append + this._append(dataUpdate); + + // Process available blocks + return this._process(); + }, + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function (dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } + + // Perform concrete-cipher logic + var finalProcessedData = this._doFinalize(); + + return finalProcessedData; + }, + + keySize: 128/32, + + ivSize: 128/32, + + _ENC_XFORM_MODE: 1, + + _DEC_XFORM_MODE: 2, + + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: (function () { + function selectCipherStrategy(key) { + if (typeof key == 'string') { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + + return function (cipher) { + return { + encrypt: function (message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + + decrypt: function (ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + }()) + }); + + /** + * Abstract base stream cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ + var StreamCipher = C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function () { + // Process partial blocks + var finalProcessedBlocks = this._process(!!'flush'); + + return finalProcessedBlocks; + }, + + blockSize: 1 + }); + + /** + * Mode namespace. + */ + var C_mode = C.mode = {}; + + /** + * Abstract base block cipher mode template. + */ + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function (cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function (cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function (cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + + /** + * Cipher Block Chaining mode. + */ + var CBC = C_mode.CBC = (function () { + /** + * Abstract base CBC mode. + */ + var CBC = BlockCipherMode.extend(); + + /** + * CBC encryptor. + */ + CBC.Encryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + /** + * CBC decryptor. + */ + CBC.Decryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function xorBlock(words, offset, blockSize) { + // Shortcut + var iv = this._iv; + + // Choose mixing block + if (iv) { + var block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + var block = this._prevBlock; + } + + // XOR blocks + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + + return CBC; + }()); + + /** + * Padding namespace. + */ + var C_pad = C.pad = {}; + + /** + * PKCS #5/7 padding strategy. + */ + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Create padding word + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; + + // Create padding + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + /** + * Abstract base block cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + var BlockCipher = C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + + reset: function () { + // Reset cipher + Cipher.reset.call(this); + + // Shortcuts + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + + // Reset block mode + if (this._xformMode == this._ENC_XFORM_MODE) { + var modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + var modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; + } + + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + + _doProcessBlock: function (words, offset) { + this._mode.processBlock(words, offset); + }, + + _doFinalize: function () { + // Shortcut + var padding = this.cfg.padding; + + // Finalize + if (this._xformMode == this._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); + + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); + + // Unpad data + padding.unpad(finalProcessedBlocks); + } + + return finalProcessedBlocks; + }, + + blockSize: 128/32 + }); + + /** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. + */ + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function (cipherParams) { + this.mixIn(cipherParams); + }, + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function (formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + + /** + * Format namespace. + */ + var C_format = C.format = {}; + + /** + * OpenSSL formatting strategy. + */ + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function (cipherParams) { + // Shortcuts + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + + // Format + if (salt) { + var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + var wordArray = ciphertext; + } + + return wordArray.toString(Base64); + }, + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function (openSSLStr) { + // Parse base64 + var ciphertext = Base64.parse(openSSLStr); + + // Shortcut + var ciphertextWords = ciphertext.words; + + // Test for salt + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { + // Extract salt + var salt = WordArray.create(ciphertextWords.slice(2, 4)); + + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + + return CipherParams.create({ ciphertext: ciphertext, salt: salt }); + } + }; + + /** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Encrypt + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + + // Shortcut + var cipherCfg = encryptor.cfg; + + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext: ciphertext, + key: key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Decrypt + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + + return plaintext; + }, + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static * * @example * @@ -42654,7 +46444,7 @@ function decrypt (data, password) { })); -},{"./core":172}],172:[function(require,module,exports){ +},{"./core":173,"./evpkdf":176}],173:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -43415,7 +47205,7 @@ function decrypt (data, password) { return CryptoJS; })); -},{}],173:[function(require,module,exports){ +},{}],174:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -43551,7 +47341,7 @@ function decrypt (data, password) { return CryptoJS.enc.Base64; })); -},{"./core":172}],174:[function(require,module,exports){ +},{"./core":173}],175:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -43701,7 +47491,7 @@ function decrypt (data, password) { return CryptoJS.enc.Utf16; })); -},{"./core":172}],175:[function(require,module,exports){ +},{"./core":173}],176:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -43834,7 +47624,7 @@ function decrypt (data, password) { return CryptoJS.EvpKDF; })); -},{"./core":172,"./hmac":177,"./sha1":196}],176:[function(require,module,exports){ +},{"./core":173,"./hmac":178,"./sha1":197}],177:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -43901,7 +47691,7 @@ function decrypt (data, password) { return CryptoJS.format.Hex; })); -},{"./cipher-core":171,"./core":172}],177:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],178:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -44045,7 +47835,7 @@ function decrypt (data, password) { })); -},{"./core":172}],178:[function(require,module,exports){ +},{"./core":173}],179:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44064,7 +47854,7 @@ function decrypt (data, password) { return CryptoJS; })); -},{"./aes":170,"./cipher-core":171,"./core":172,"./enc-base64":173,"./enc-utf16":174,"./evpkdf":175,"./format-hex":176,"./hmac":177,"./lib-typedarrays":179,"./md5":180,"./mode-cfb":181,"./mode-ctr":183,"./mode-ctr-gladman":182,"./mode-ecb":184,"./mode-ofb":185,"./pad-ansix923":186,"./pad-iso10126":187,"./pad-iso97971":188,"./pad-nopadding":189,"./pad-zeropadding":190,"./pbkdf2":191,"./rabbit":193,"./rabbit-legacy":192,"./rc4":194,"./ripemd160":195,"./sha1":196,"./sha224":197,"./sha256":198,"./sha3":199,"./sha384":200,"./sha512":201,"./tripledes":202,"./x64-core":203}],179:[function(require,module,exports){ +},{"./aes":171,"./cipher-core":172,"./core":173,"./enc-base64":174,"./enc-utf16":175,"./evpkdf":176,"./format-hex":177,"./hmac":178,"./lib-typedarrays":180,"./md5":181,"./mode-cfb":182,"./mode-ctr":184,"./mode-ctr-gladman":183,"./mode-ecb":185,"./mode-ofb":186,"./pad-ansix923":187,"./pad-iso10126":188,"./pad-iso97971":189,"./pad-nopadding":190,"./pad-zeropadding":191,"./pbkdf2":192,"./rabbit":194,"./rabbit-legacy":193,"./rc4":195,"./ripemd160":196,"./sha1":197,"./sha224":198,"./sha256":199,"./sha3":200,"./sha384":201,"./sha512":202,"./tripledes":203,"./x64-core":204}],180:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -44141,7 +47931,7 @@ function decrypt (data, password) { return CryptoJS.lib.WordArray; })); -},{"./core":172}],180:[function(require,module,exports){ +},{"./core":173}],181:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -44410,7 +48200,7 @@ function decrypt (data, password) { return CryptoJS.MD5; })); -},{"./core":172}],181:[function(require,module,exports){ +},{"./core":173}],182:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44489,7 +48279,7 @@ function decrypt (data, password) { return CryptoJS.mode.CFB; })); -},{"./cipher-core":171,"./core":172}],182:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],183:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44606,7 +48396,7 @@ function decrypt (data, password) { return CryptoJS.mode.CTRGladman; })); -},{"./cipher-core":171,"./core":172}],183:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],184:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44665,7 +48455,7 @@ function decrypt (data, password) { return CryptoJS.mode.CTR; })); -},{"./cipher-core":171,"./core":172}],184:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],185:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44706,7 +48496,7 @@ function decrypt (data, password) { return CryptoJS.mode.ECB; })); -},{"./cipher-core":171,"./core":172}],185:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],186:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44761,7 +48551,7 @@ function decrypt (data, password) { return CryptoJS.mode.OFB; })); -},{"./cipher-core":171,"./core":172}],186:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],187:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44811,7 +48601,7 @@ function decrypt (data, password) { return CryptoJS.pad.Ansix923; })); -},{"./cipher-core":171,"./core":172}],187:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],188:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44856,7 +48646,7 @@ function decrypt (data, password) { return CryptoJS.pad.Iso10126; })); -},{"./cipher-core":171,"./core":172}],188:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],189:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44897,7 +48687,7 @@ function decrypt (data, password) { return CryptoJS.pad.Iso97971; })); -},{"./cipher-core":171,"./core":172}],189:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],190:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44928,7 +48718,7 @@ function decrypt (data, password) { return CryptoJS.pad.NoPadding; })); -},{"./cipher-core":171,"./core":172}],190:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],191:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -44974,7 +48764,7 @@ function decrypt (data, password) { return CryptoJS.pad.ZeroPadding; })); -},{"./cipher-core":171,"./core":172}],191:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173}],192:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -45120,7 +48910,7 @@ function decrypt (data, password) { return CryptoJS.PBKDF2; })); -},{"./core":172,"./hmac":177,"./sha1":196}],192:[function(require,module,exports){ +},{"./core":173,"./hmac":178,"./sha1":197}],193:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -45311,7 +49101,7 @@ function decrypt (data, password) { return CryptoJS.RabbitLegacy; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],193:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -45504,7 +49294,7 @@ function decrypt (data, password) { return CryptoJS.Rabbit; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],194:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -45644,7 +49434,7 @@ function decrypt (data, password) { return CryptoJS.RC4; })); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],195:[function(require,module,exports){ +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -45912,7 +49702,7 @@ function decrypt (data, password) { return CryptoJS.RIPEMD160; })); -},{"./core":172}],196:[function(require,module,exports){ +},{"./core":173}],197:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -46063,7 +49853,7 @@ function decrypt (data, password) { return CryptoJS.SHA1; })); -},{"./core":172}],197:[function(require,module,exports){ +},{"./core":173}],198:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -46144,7 +49934,7 @@ function decrypt (data, password) { return CryptoJS.SHA224; })); -},{"./core":172,"./sha256":198}],198:[function(require,module,exports){ +},{"./core":173,"./sha256":199}],199:[function(require,module,exports){ ;(function (root, factory) { if (typeof exports === "object") { // CommonJS @@ -46344,7 +50134,7 @@ function decrypt (data, password) { return CryptoJS.SHA256; })); -},{"./core":172}],199:[function(require,module,exports){ +},{"./core":173}],200:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -46668,7 +50458,7 @@ function decrypt (data, password) { return CryptoJS.SHA3; })); -},{"./core":172,"./x64-core":203}],200:[function(require,module,exports){ +},{"./core":173,"./x64-core":204}],201:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -46752,7 +50542,7 @@ function decrypt (data, password) { return CryptoJS.SHA384; })); -},{"./core":172,"./sha512":201,"./x64-core":203}],201:[function(require,module,exports){ +},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -47076,7 +50866,7 @@ function decrypt (data, password) { return CryptoJS.SHA512; })); -},{"./core":172,"./x64-core":203}],202:[function(require,module,exports){ +},{"./core":173,"./x64-core":204}],203:[function(require,module,exports){ ;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS @@ -47524,7325 +51314,10192 @@ function decrypt (data, password) { 0x1e80: 0x10000000, 0x1f80: 0x10002008 }, - { - 0x0: 0x100000, - 0x10: 0x2000401, - 0x20: 0x400, - 0x30: 0x100401, - 0x40: 0x2100401, - 0x50: 0x0, - 0x60: 0x1, - 0x70: 0x2100001, - 0x80: 0x2000400, - 0x90: 0x100001, - 0xa0: 0x2000001, - 0xb0: 0x2100400, - 0xc0: 0x2100000, - 0xd0: 0x401, - 0xe0: 0x100400, - 0xf0: 0x2000000, - 0x8: 0x2100001, - 0x18: 0x0, - 0x28: 0x2000401, - 0x38: 0x2100400, - 0x48: 0x100000, - 0x58: 0x2000001, - 0x68: 0x2000000, - 0x78: 0x401, - 0x88: 0x100401, - 0x98: 0x2000400, - 0xa8: 0x2100000, - 0xb8: 0x100001, - 0xc8: 0x400, - 0xd8: 0x2100401, - 0xe8: 0x1, - 0xf8: 0x100400, - 0x100: 0x2000000, - 0x110: 0x100000, - 0x120: 0x2000401, - 0x130: 0x2100001, - 0x140: 0x100001, - 0x150: 0x2000400, - 0x160: 0x2100400, - 0x170: 0x100401, - 0x180: 0x401, - 0x190: 0x2100401, - 0x1a0: 0x100400, - 0x1b0: 0x1, - 0x1c0: 0x0, - 0x1d0: 0x2100000, - 0x1e0: 0x2000001, - 0x1f0: 0x400, - 0x108: 0x100400, - 0x118: 0x2000401, - 0x128: 0x2100001, - 0x138: 0x1, - 0x148: 0x2000000, - 0x158: 0x100000, - 0x168: 0x401, - 0x178: 0x2100400, - 0x188: 0x2000001, - 0x198: 0x2100000, - 0x1a8: 0x0, - 0x1b8: 0x2100401, - 0x1c8: 0x100401, - 0x1d8: 0x400, - 0x1e8: 0x2000400, - 0x1f8: 0x100001 + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } + ]; + + // Masks that select the SBOX input + var SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f + ]; + + /** + * DES block cipher algorithm. + */ + var DES = C_algo.DES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Select 56 bits according to PC1 + var keyBits = []; + for (var i = 0; i < 56; i++) { + var keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; + } + + // Assemble 16 subkeys + var subKeys = this._subKeys = []; + for (var nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + var subKey = subKeys[nSubKey] = []; + + // Shortcut + var bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (var i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (var i = 1; i < 7; i++) { + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + var invSubKeys = this._invSubKeys = []; + for (var i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + }, + + decryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + }, + + _doCryptBlock: function (M, offset, subKeys) { + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (var round = 0; round < 16; round++) { + // Shortcuts + var subKey = subKeys[round]; + var lBlock = this._lBlock; + var rBlock = this._rBlock; + + // Feistel function + var f = 0; + for (var i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + var t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + M[offset] = this._lBlock; + M[offset + 1] = this._rBlock; + }, + + keySize: 64/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + // Swap bits across the left and right words + function exchangeLR(offset, mask) { + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; + } + + function exchangeRL(offset, mask) { + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + C.DES = BlockCipher._createHelper(DES); + + /** + * Triple-DES block cipher algorithm. + */ + var TripleDES = C_algo.TripleDES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Create DES instances + this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); + this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); + this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); + }, + + encryptBlock: function (M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + }, + + decryptBlock: function (M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + }, + + keySize: 192/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + C.TripleDES = BlockCipher._createHelper(TripleDES); + }()); + + + return CryptoJS.TripleDES; + +})); +},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],204:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var X32WordArray = C_lib.WordArray; + + /** + * x64 namespace. + */ + var C_x64 = C.x64 = {}; + + /** + * A 64-bit word. + */ + var X64Word = C_x64.Word = Base.extend({ + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + init: function (high, low) { + this.high = high; + this.low = low; + } + + /** + * Bitwise NOTs this word. + * + * @return {X64Word} A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + // not: function () { + // var high = ~this.high; + // var low = ~this.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ANDs this word with the passed word. + * + * @param {X64Word} word The x64-Word to AND with this word. + * + * @return {X64Word} A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + // and: function (word) { + // var high = this.high & word.high; + // var low = this.low & word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to OR with this word. + * + * @return {X64Word} A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + // or: function (word) { + // var high = this.high | word.high; + // var low = this.low | word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise XORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to XOR with this word. + * + * @return {X64Word} A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + // xor: function (word) { + // var high = this.high ^ word.high; + // var low = this.low ^ word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the left. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + // shiftL: function (n) { + // if (n < 32) { + // var high = (this.high << n) | (this.low >>> (32 - n)); + // var low = this.low << n; + // } else { + // var high = this.low << (n - 32); + // var low = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the right. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + // shiftR: function (n) { + // if (n < 32) { + // var low = (this.low >>> n) | (this.high << (32 - n)); + // var high = this.high >>> n; + // } else { + // var low = this.high >>> (n - 32); + // var high = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Rotates this word n bits to the left. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + // rotL: function (n) { + // return this.shiftL(n).or(this.shiftR(64 - n)); + // }, + + /** + * Rotates this word n bits to the right. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + // rotR: function (n) { + // return this.shiftR(n).or(this.shiftL(64 - n)); + // }, + + /** + * Adds this word with the passed word. + * + * @param {X64Word} word The x64-Word to add with this word. + * + * @return {X64Word} A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + // add: function (word) { + // var low = (this.low + word.low) | 0; + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; + // var high = (this.high + word.high + carry) | 0; + + // return X64Word.create(high, low); + // } + }); + + /** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var X64WordArray = C_x64.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 8; + } }, - { - 0x0: 0x8000820, - 0x1: 0x20000, - 0x2: 0x8000000, - 0x3: 0x20, - 0x4: 0x20020, - 0x5: 0x8020820, - 0x6: 0x8020800, - 0x7: 0x800, - 0x8: 0x8020000, - 0x9: 0x8000800, - 0xa: 0x20800, - 0xb: 0x8020020, - 0xc: 0x820, - 0xd: 0x0, - 0xe: 0x8000020, - 0xf: 0x20820, - 0x80000000: 0x800, - 0x80000001: 0x8020820, - 0x80000002: 0x8000820, - 0x80000003: 0x8000000, - 0x80000004: 0x8020000, - 0x80000005: 0x20800, - 0x80000006: 0x20820, - 0x80000007: 0x20, - 0x80000008: 0x8000020, - 0x80000009: 0x820, - 0x8000000a: 0x20020, - 0x8000000b: 0x8020800, - 0x8000000c: 0x0, - 0x8000000d: 0x8020020, - 0x8000000e: 0x8000800, - 0x8000000f: 0x20000, - 0x10: 0x20820, - 0x11: 0x8020800, - 0x12: 0x20, - 0x13: 0x800, - 0x14: 0x8000800, - 0x15: 0x8000020, - 0x16: 0x8020020, - 0x17: 0x20000, - 0x18: 0x0, - 0x19: 0x20020, - 0x1a: 0x8020000, - 0x1b: 0x8000820, - 0x1c: 0x8020820, - 0x1d: 0x20800, - 0x1e: 0x820, - 0x1f: 0x8000000, - 0x80000010: 0x20000, - 0x80000011: 0x800, - 0x80000012: 0x8020020, - 0x80000013: 0x20820, - 0x80000014: 0x20, - 0x80000015: 0x8020000, - 0x80000016: 0x8000000, - 0x80000017: 0x8000820, - 0x80000018: 0x8020820, - 0x80000019: 0x8000020, - 0x8000001a: 0x8000800, - 0x8000001b: 0x0, - 0x8000001c: 0x20800, - 0x8000001d: 0x820, - 0x8000001e: 0x20020, - 0x8000001f: 0x8020800 + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32: function () { + // Shortcuts + var x64Words = this.words; + var x64WordsLength = x64Words.length; + + // Convert + var x32Words = []; + for (var i = 0; i < x64WordsLength; i++) { + var x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + }, + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + + // Clone "words" array + var words = clone.words = this.words.slice(0); + + // Clone each X64Word object + var wordsLength = words.length; + for (var i = 0; i < wordsLength; i++) { + words[i] = words[i].clone(); + } + + return clone; } - ]; + }); + }()); + + + return CryptoJS; + +})); +},{"./core":173}],205:[function(require,module,exports){ +(function (process){(function (){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} - // Masks that select the SBOX input - var SBOX_MASK = [ - 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, - 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f - ]; +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ - /** - * DES block cipher algorithm. - */ - var DES = C_algo.DES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; - // Select 56 bits according to PC1 - var keyBits = []; - for (var i = 0; i < 56; i++) { - var keyBitPos = PC1[i] - 1; - keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; - } - // Assemble 16 subkeys - var subKeys = this._subKeys = []; - for (var nSubKey = 0; nSubKey < 16; nSubKey++) { - // Create subkey - var subKey = subKeys[nSubKey] = []; +/** + * Colorize log arguments if enabled. + * + * @api public + */ - // Shortcut - var bitShift = BIT_SHIFTS[nSubKey]; +function formatArgs(args) { + var useColors = this.useColors; - // Select 48 bits according to PC2 - for (var i = 0; i < 24; i++) { - // Select from the left 28 key bits - subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); - // Select from the right 28 key bits - subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); - } + if (!useColors) return; - // Since each subkey is applied to an expanded 32-bit input, - // the subkey can be broken into 8 values scaled to 32-bits, - // which allows the key to be used without expansion - subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); - for (var i = 1; i < 7; i++) { - subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); - } - subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); - } + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') - // Compute inverse subkeys - var invSubKeys = this._invSubKeys = []; - for (var i = 0; i < 16; i++) { - invSubKeys[i] = subKeys[15 - i]; - } - }, + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._subKeys); - }, + args.splice(lastC, 0, c); +} - decryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._invSubKeys); - }, +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ - _doCryptBlock: function (M, offset, subKeys) { - // Get input - this._lBlock = M[offset]; - this._rBlock = M[offset + 1]; +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} - // Initial permutation - exchangeLR.call(this, 4, 0x0f0f0f0f); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeRL.call(this, 2, 0x33333333); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeLR.call(this, 1, 0x55555555); +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ - // Rounds - for (var round = 0; round < 16; round++) { - // Shortcuts - var subKey = subKeys[round]; - var lBlock = this._lBlock; - var rBlock = this._rBlock; +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} - // Feistel function - var f = 0; - for (var i = 0; i < 8; i++) { - f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; - } - this._lBlock = rBlock; - this._rBlock = lBlock ^ f; - } +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ - // Undo swap from last round - var t = this._lBlock; - this._lBlock = this._rBlock; - this._rBlock = t; +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} - // Final permutation - exchangeLR.call(this, 1, 0x55555555); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeRL.call(this, 2, 0x33333333); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeLR.call(this, 4, 0x0f0f0f0f); + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } - // Set output - M[offset] = this._lBlock; - M[offset + 1] = this._rBlock; - }, + return r; +} - keySize: 64/32, +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ - ivSize: 64/32, +exports.enable(load()); - blockSize: 64/32 - }); +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ - // Swap bits across the left and right words - function exchangeLR(offset, mask) { - var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; - this._rBlock ^= t; - this._lBlock ^= t << offset; - } +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} - function exchangeRL(offset, mask) { - var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; - this._lBlock ^= t; - this._rBlock ^= t << offset; - } +}).call(this)}).call(this,require('_process')) +},{"./debug":206,"_process":291}],206:[function(require,module,exports){ - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); - */ - C.DES = BlockCipher._createHelper(DES); +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ - /** - * Triple-DES block cipher algorithm. - */ - var TripleDES = C_algo.TripleDES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); - // Create DES instances - this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); - this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); - this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); - }, +/** + * The currently active debug mode names, and names to skip. + */ - encryptBlock: function (M, offset) { - this._des1.encryptBlock(M, offset); - this._des2.decryptBlock(M, offset); - this._des3.encryptBlock(M, offset); - }, +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":288}],207:[function(require,module,exports){ +'use strict'; + +exports.utils = require('./des/utils'); +exports.Cipher = require('./des/cipher'); +exports.DES = require('./des/des'); +exports.CBC = require('./des/cbc'); +exports.EDE = require('./des/ede'); + +},{"./des/cbc":208,"./des/cipher":209,"./des/des":210,"./des/ede":211,"./des/utils":212}],208:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var proto = {}; + +function CBCState(iv) { + assert.equal(iv.length, 8, 'Invalid IV length'); + + this.iv = new Array(8); + for (var i = 0; i < this.iv.length; i++) + this.iv[i] = iv[i]; +} + +function instantiate(Base) { + function CBC(options) { + Base.call(this, options); + this._cbcInit(); + } + inherits(CBC, Base); + + var keys = Object.keys(proto); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + CBC.prototype[key] = proto[key]; + } + + CBC.create = function create(options) { + return new CBC(options); + }; + + return CBC; +} + +exports.instantiate = instantiate; + +proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; +}; + +proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + + var iv = state.iv; + if (this.type === 'encrypt') { + for (var i = 0; i < this.blockSize; i++) + iv[i] ^= inp[inOff + i]; + + superProto._update.call(this, iv, 0, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + iv[i] = out[outOff + i]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + out[outOff + i] ^= iv[i]; + + for (var i = 0; i < this.blockSize; i++) + iv[i] = inp[inOff + i]; + } +}; - decryptBlock: function (M, offset) { - this._des3.decryptBlock(M, offset); - this._des2.encryptBlock(M, offset); - this._des1.decryptBlock(M, offset); - }, +},{"inherits":279,"minimalistic-assert":286}],209:[function(require,module,exports){ +'use strict'; - keySize: 192/32, +var assert = require('minimalistic-assert'); - ivSize: 64/32, +function Cipher(options) { + this.options = options; - blockSize: 64/32 - }); + this.type = this.options.type; + this.blockSize = 8; + this._init(); - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); - */ - C.TripleDES = BlockCipher._createHelper(TripleDES); - }()); + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; +} +module.exports = Cipher; +Cipher.prototype._init = function _init() { + // Might be overrided +}; - return CryptoJS.TripleDES; +Cipher.prototype.update = function update(data) { + if (data.length === 0) + return []; -})); -},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],203:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + if (this.type === 'decrypt') + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); +}; - (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var X32WordArray = C_lib.WordArray; +Cipher.prototype._buffer = function _buffer(data, off) { + // Append data to buffer + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i = 0; i < min; i++) + this.buffer[this.bufferOff + i] = data[off + i]; + this.bufferOff += min; - /** - * x64 namespace. - */ - var C_x64 = C.x64 = {}; + // Shift next + return min; +}; - /** - * A 64-bit word. - */ - var X64Word = C_x64.Word = Base.extend({ - /** - * Initializes a newly created 64-bit word. - * - * @param {number} high The high 32 bits. - * @param {number} low The low 32 bits. - * - * @example - * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); - */ - init: function (high, low) { - this.high = high; - this.low = low; - } +Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; +}; - /** - * Bitwise NOTs this word. - * - * @return {X64Word} A new x64-Word object after negating. - * - * @example - * - * var negated = x64Word.not(); - */ - // not: function () { - // var high = ~this.high; - // var low = ~this.low; +Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; - // return X64Word.create(high, low); - // }, + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; + var out = new Array(count * this.blockSize); - /** - * Bitwise ANDs this word with the passed word. - * - * @param {X64Word} word The x64-Word to AND with this word. - * - * @return {X64Word} A new x64-Word object after ANDing. - * - * @example - * - * var anded = x64Word.and(anotherX64Word); - */ - // and: function (word) { - // var high = this.high & word.high; - // var low = this.low & word.low; + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); - // return X64Word.create(high, low); - // }, + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } - /** - * Bitwise ORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to OR with this word. - * - * @return {X64Word} A new x64-Word object after ORing. - * - * @example - * - * var ored = x64Word.or(anotherX64Word); - */ - // or: function (word) { - // var high = this.high | word.high; - // var low = this.low | word.low; + // Write blocks + var max = data.length - ((data.length - inputOff) % this.blockSize); + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } - // return X64Word.create(high, low); - // }, + // Queue rest + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; - /** - * Bitwise XORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to XOR with this word. - * - * @return {X64Word} A new x64-Word object after XORing. - * - * @example - * - * var xored = x64Word.xor(anotherX64Word); - */ - // xor: function (word) { - // var high = this.high ^ word.high; - // var low = this.low ^ word.low; + return out; +}; - // return X64Word.create(high, low); - // }, +Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; - /** - * Shifts this word n bits to the left. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftL(25); - */ - // shiftL: function (n) { - // if (n < 32) { - // var high = (this.high << n) | (this.low >>> (32 - n)); - // var low = this.low << n; - // } else { - // var high = this.low << (n - 32); - // var low = 0; - // } + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); - // return X64Word.create(high, low); - // }, + // TODO(indutny): optimize it, this is far from optimal + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } - /** - * Shifts this word n bits to the right. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftR(7); - */ - // shiftR: function (n) { - // if (n < 32) { - // var low = (this.low >>> n) | (this.high << (32 - n)); - // var high = this.high >>> n; - // } else { - // var low = this.high >>> (n - 32); - // var high = 0; - // } + // Buffer rest of the input + inputOff += this._buffer(data, inputOff); - // return X64Word.create(high, low); - // }, + return out; +}; - /** - * Rotates this word n bits to the left. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotL(25); - */ - // rotL: function (n) { - // return this.shiftL(n).or(this.shiftR(64 - n)); - // }, +Cipher.prototype.final = function final(buffer) { + var first; + if (buffer) + first = this.update(buffer); - /** - * Rotates this word n bits to the right. - * - * @param {number} n The number of bits to rotate. - * - * @return {X64Word} A new x64-Word object after rotating. - * - * @example - * - * var rotated = x64Word.rotR(7); - */ - // rotR: function (n) { - // return this.shiftR(n).or(this.shiftL(64 - n)); - // }, + var last; + if (this.type === 'encrypt') + last = this._finalEncrypt(); + else + last = this._finalDecrypt(); - /** - * Adds this word with the passed word. - * - * @param {X64Word} word The x64-Word to add with this word. - * - * @return {X64Word} A new x64-Word object after adding. - * - * @example - * - * var added = x64Word.add(anotherX64Word); - */ - // add: function (word) { - // var low = (this.low + word.low) | 0; - // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; - // var high = (this.high + word.high + carry) | 0; + if (first) + return first.concat(last); + else + return last; +}; - // return X64Word.create(high, low); - // } - }); +Cipher.prototype._pad = function _pad(buffer, off) { + if (off === 0) + return false; - /** - * An array of 64-bit words. - * - * @property {Array} words The array of CryptoJS.x64.Word objects. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var X64WordArray = C_x64.WordArray = Base.extend({ - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * var wordArray = CryptoJS.x64.WordArray.create(); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ]); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ], 10); - */ - init: function (words, sigBytes) { - words = this.words = words || []; + while (off < buffer.length) + buffer[off++] = 0; - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 8; - } - }, + return true; +}; - /** - * Converts this 64-bit word array to a 32-bit word array. - * - * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. - * - * @example - * - * var x32WordArray = x64WordArray.toX32(); - */ - toX32: function () { - // Shortcuts - var x64Words = this.words; - var x64WordsLength = x64Words.length; +Cipher.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; - // Convert - var x32Words = []; - for (var i = 0; i < x64WordsLength; i++) { - var x64Word = x64Words[i]; - x32Words.push(x64Word.high); - x32Words.push(x64Word.low); - } + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; +}; - return X32WordArray.create(x32Words, this.sigBytes); - }, +Cipher.prototype._unpad = function _unpad(buffer) { + return buffer; +}; - /** - * Creates a copy of this word array. - * - * @return {X64WordArray} The clone. - * - * @example - * - * var clone = x64WordArray.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); +Cipher.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); - // Clone "words" array - var words = clone.words = this.words.slice(0); + return this._unpad(out); +}; - // Clone each X64Word object - var wordsLength = words.length; - for (var i = 0; i < wordsLength; i++) { - words[i] = words[i].clone(); - } +},{"minimalistic-assert":286}],210:[function(require,module,exports){ +'use strict'; - return clone; - } - }); - }()); +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); +var utils = require('./utils'); +var Cipher = require('./cipher'); - return CryptoJS; +function DESState() { + this.tmp = new Array(2); + this.keys = null; +} -})); -},{"./core":172}],204:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ +function DES(options) { + Cipher.call(this, options); -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); + var state = new DESState(); + this._desState = state; -/** - * Colors. - */ + this.deriveKeys(state, options.key); +} +inherits(DES, Cipher); +module.exports = DES; -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' +DES.create = function create(options) { + return new DES(options); +}; + +var shiftTable = [ + 1, 1, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 1 ]; -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ +DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; + assert.equal(key.length, this.blockSize, 'Invalid key length'); + + var kL = utils.readUInt32BE(key, 0); + var kR = utils.readUInt32BE(key, 4); + + utils.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i = 0; i < state.keys.length; i += 2) { + var shift = shiftTable[i >>> 1]; + kL = utils.r28shl(kL, shift); + kR = utils.r28shl(kR, shift); + utils.pc2(kL, kR, state.keys, i); } +}; - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} +DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + var l = utils.readUInt32BE(inp, inOff); + var r = utils.readUInt32BE(inp, inOff + 4); + + // Initial Permutation + utils.ip(l, r, state.tmp, 0); + l = state.tmp[0]; + r = state.tmp[1]; + + if (this.type === 'encrypt') + this._encrypt(state, l, r, state.tmp, 0); + else + this._decrypt(state, l, r, state.tmp, 0); + + l = state.tmp[0]; + r = state.tmp[1]; -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } + utils.writeUInt32BE(out, l, outOff); + utils.writeUInt32BE(out, r, outOff + 4); }; +DES.prototype._pad = function _pad(buffer, off) { + var value = buffer.length - off; + for (var i = off; i < buffer.length; i++) + buffer[i] = value; -/** - * Colorize log arguments if enabled. - * - * @api public - */ + return true; +}; -function formatArgs(args) { - var useColors = this.useColors; +DES.prototype._unpad = function _unpad(buffer) { + var pad = buffer[buffer.length - 1]; + for (var i = buffer.length - pad; i < buffer.length; i++) + assert.equal(buffer[i], pad); - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); + return buffer.slice(0, buffer.length - pad); +}; - if (!useColors) return; +DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l = lStart; + var r = rStart; - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') + // Apply f() x16 times + for (var i = 0; i < state.keys.length; i += 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + // f(r, k) + utils.expand(r, state.tmp, 0); - args.splice(lastC, 0, c); -} + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ + var t = r; + r = (l ^ f) >>> 0; + l = t; + } -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} + // Reverse Initial Permutation + utils.rip(r, l, out, off); +}; -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ +DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l = rStart; + var r = lStart; -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} + // Apply f() x16 times + for (var i = state.keys.length - 2; i >= 0; i -= 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ + // f(r, k) + utils.expand(l, state.tmp, 0); -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; + var t = l; + l = (r ^ f) >>> 0; + r = t; } - return r; -} + // Reverse Initial Permutation + utils.rip(l, r, out, off); +}; -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ +},{"./cipher":209,"./utils":212,"inherits":279,"minimalistic-assert":286}],211:[function(require,module,exports){ +'use strict'; -exports.enable(load()); +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ +var Cipher = require('./cipher'); +var DES = require('./des'); -function localstorage() { - try { - return window.localStorage; - } catch (e) {} +function EDEState(type, key) { + assert.equal(key.length, 24, 'Invalid key length'); + + var k1 = key.slice(0, 8); + var k2 = key.slice(8, 16); + var k3 = key.slice(16, 24); + + if (type === 'encrypt') { + this.ciphers = [ + DES.create({ type: 'encrypt', key: k1 }), + DES.create({ type: 'decrypt', key: k2 }), + DES.create({ type: 'encrypt', key: k3 }) + ]; + } else { + this.ciphers = [ + DES.create({ type: 'decrypt', key: k3 }), + DES.create({ type: 'encrypt', key: k2 }), + DES.create({ type: 'decrypt', key: k1 }) + ]; + } } -}).call(this,require('_process')) -},{"./debug":205,"_process":271}],205:[function(require,module,exports){ +function EDE(options) { + Cipher.call(this, options); -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ + var state = new EDEState(this.type, this.options.key); + this._edeState = state; +} +inherits(EDE, Cipher); -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); +module.exports = EDE; -/** - * The currently active debug mode names, and names to skip. - */ +EDE.create = function create(options) { + return new EDE(options); +}; -exports.names = []; -exports.skips = []; +EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); +}; -exports.formatters = {}; +EDE.prototype._pad = DES.prototype._pad; +EDE.prototype._unpad = DES.prototype._unpad; -/** - * Previous log timestamp. - */ +},{"./cipher":209,"./des":210,"inherits":279,"minimalistic-assert":286}],212:[function(require,module,exports){ +'use strict'; -var prevTime; +exports.readUInt32BE = function readUInt32BE(bytes, off) { + var res = (bytes[0 + off] << 24) | + (bytes[1 + off] << 16) | + (bytes[2 + off] << 8) | + bytes[3 + off]; + return res >>> 0; +}; -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ +exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { + bytes[0 + off] = value >>> 24; + bytes[1 + off] = (value >>> 16) & 0xff; + bytes[2 + off] = (value >>> 8) & 0xff; + bytes[3 + off] = value & 0xff; +}; -function selectColor(namespace) { - var hash = 0, i; +exports.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer + for (var i = 6; i >= 0; i -= 2) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } } - return exports.colors[Math.abs(hash) % exports.colors.length]; -} + for (var i = 6; i >= 0; i -= 2) { + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + } + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; -function createDebug(namespace) { +exports.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; - function debug() { - // disabled? - if (!debug.enabled) return; + for (var i = 0; i < 4; i++) { + for (var j = 24; j >= 0; j -= 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + for (var i = 4; i < 8; i++) { + for (var j = 24; j >= 0; j -= 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } - var self = debug; + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; +exports.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; + // 7, 15, 23, 31, 39, 47, 55, 63 + // 6, 14, 22, 30, 39, 47, 55, 63 + // 5, 13, 21, 29, 39, 47, 55, 63 + // 4, 12, 20, 28 + for (var i = 7; i >= 5; i--) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); + // 1, 9, 17, 25, 33, 41, 49, 57 + // 2, 10, 18, 26, 34, 42, 50, 58 + // 3, 11, 19, 27, 35, 43, 51, 59 + // 36, 44, 52, 60 + for (var i = 1; i <= 3; i++) { + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inR >> (j + i)) & 1; } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); +exports.r28shl = function r28shl(num, shift) { + return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); +}; - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); +var pc2table = [ + // inL => outL + 14, 11, 17, 4, 27, 23, 25, 0, + 13, 22, 7, 18, 5, 9, 16, 24, + 2, 20, 12, 21, 1, 8, 15, 26, - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); + // inR => outR + 15, 4, 25, 19, 9, 1, 26, 16, + 5, 11, 23, 8, 12, 7, 17, 0, + 22, 3, 10, 14, 6, 20, 27, 24 +]; + +exports.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + var len = pc2table.length >>> 1; + for (var i = 0; i < len; i++) { + outL <<= 1; + outL |= (inL >>> pc2table[i]) & 0x1; + } + for (var i = len; i < pc2table.length; i++) { + outR <<= 1; + outR |= (inR >>> pc2table[i]) & 0x1; } - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); +exports.expand = function expand(r, out, off) { + var outL = 0; + var outR = 0; + + outL = ((r & 1) << 5) | (r >>> 27); + for (var i = 23; i >= 15; i -= 4) { + outL <<= 6; + outL |= (r >>> i) & 0x3f; + } + for (var i = 11; i >= 3; i -= 4) { + outR |= (r >>> i) & 0x3f; + outR <<= 6; } + outR |= ((r & 0x1f) << 1) | (r >>> 31); - return debug; -} + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ +var sTable = [ + 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, + 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, + 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, + 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, -function enable(namespaces) { - exports.save(namespaces); + 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, + 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, + 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, + 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - exports.names = []; - exports.skips = []; + 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, + 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, + 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, + 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; + 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, + 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, + 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, + 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} + 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, + 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, + 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, + 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, -/** - * Disable debug output. - * - * @api public - */ + 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, + 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, + 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, + 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, -function disable() { - exports.enable(''); -} + 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, + 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, + 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, + 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ + 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, + 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, + 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, + 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 +]; + +exports.substitute = function substitute(inL, inR) { + var out = 0; + for (var i = 0; i < 4; i++) { + var b = (inL >>> (18 - i * 6)) & 0x3f; + var sb = sTable[i * 0x40 + b]; -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } + out <<= 4; + out |= sb; } - return false; -} + for (var i = 0; i < 4; i++) { + var b = (inR >>> (18 - i * 6)) & 0x3f; + var sb = sTable[4 * 0x40 + i * 0x40 + b]; -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ + out <<= 4; + out |= sb; + } + return out >>> 0; +}; -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} +var permuteTable = [ + 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, + 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 +]; -},{"ms":268}],206:[function(require,module,exports){ -'use strict'; +exports.permute = function permute(num) { + var out = 0; + for (var i = 0; i < permuteTable.length; i++) { + out <<= 1; + out |= (num >>> permuteTable[i]) & 0x1; + } + return out >>> 0; +}; -exports.utils = require('./des/utils'); -exports.Cipher = require('./des/cipher'); -exports.DES = require('./des/des'); -exports.CBC = require('./des/cbc'); -exports.EDE = require('./des/ede'); +exports.padSplit = function padSplit(num, size, group) { + var str = num.toString(2); + while (str.length < size) + str = '0' + str; -},{"./des/cbc":207,"./des/cipher":208,"./des/des":209,"./des/ede":210,"./des/utils":211}],207:[function(require,module,exports){ -'use strict'; + var out = []; + for (var i = 0; i < size; i += group) + out.push(str.slice(i, i + group)); + return out.join(' '); +}; -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); +},{}],213:[function(require,module,exports){ +(function (Buffer){(function (){ +var generatePrime = require('./lib/generatePrime') +var primes = require('./lib/primes.json') -var proto = {}; +var DH = require('./lib/dh') -function CBCState(iv) { - assert.equal(iv.length, 8, 'Invalid IV length'); +function getDiffieHellman (mod) { + var prime = new Buffer(primes[mod].prime, 'hex') + var gen = new Buffer(primes[mod].gen, 'hex') - this.iv = new Array(8); - for (var i = 0; i < this.iv.length; i++) - this.iv[i] = iv[i]; + return new DH(prime, gen) } -function instantiate(Base) { - function CBC(options) { - Base.call(this, options); - this._cbcInit(); - } - inherits(CBC, Base); +var ENCODINGS = { + 'binary': true, 'hex': true, 'base64': true +} - var keys = Object.keys(proto); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - CBC.prototype[key] = proto[key]; +function createDiffieHellman (prime, enc, generator, genc) { + if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { + return createDiffieHellman(prime, 'binary', enc, generator) } - CBC.create = function create(options) { - return new CBC(options); - }; - - return CBC; -} - -exports.instantiate = instantiate; + enc = enc || 'binary' + genc = genc || 'binary' + generator = generator || new Buffer([2]) -proto._cbcInit = function _cbcInit() { - var state = new CBCState(this.options.iv); - this._cbcState = state; -}; + if (!Buffer.isBuffer(generator)) { + generator = new Buffer(generator, genc) + } -proto._update = function _update(inp, inOff, out, outOff) { - var state = this._cbcState; - var superProto = this.constructor.super_.prototype; + if (typeof prime === 'number') { + return new DH(generatePrime(prime, generator), generator, true) + } - var iv = state.iv; - if (this.type === 'encrypt') { - for (var i = 0; i < this.blockSize; i++) - iv[i] ^= inp[inOff + i]; + if (!Buffer.isBuffer(prime)) { + prime = new Buffer(prime, enc) + } - superProto._update.call(this, iv, 0, out, outOff); + return new DH(prime, generator, true) +} - for (var i = 0; i < this.blockSize; i++) - iv[i] = out[outOff + i]; - } else { - superProto._update.call(this, inp, inOff, out, outOff); +exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman +exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman - for (var i = 0; i < this.blockSize; i++) - out[outOff + i] ^= iv[i]; +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/dh":214,"./lib/generatePrime":215,"./lib/primes.json":216,"buffer":130}],214:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js'); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var TWENTYFOUR = new BN(24); +var ELEVEN = new BN(11); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var primes = require('./generatePrime'); +var randomBytes = require('randombytes'); +module.exports = DH; - for (var i = 0; i < this.blockSize; i++) - iv[i] = inp[inOff + i]; +function setPublicKey(pub, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc); } -}; + this._pub = new BN(pub); + return this; +} -},{"inherits":259,"minimalistic-assert":266}],208:[function(require,module,exports){ -'use strict'; +function setPrivateKey(priv, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc); + } + this._priv = new BN(priv); + return this; +} -var assert = require('minimalistic-assert'); +var primeCache = {}; +function checkPrime(prime, generator) { + var gen = generator.toString('hex'); + var hex = [gen, prime.toString(16)].join('_'); + if (hex in primeCache) { + return primeCache[hex]; + } + var error = 0; -function Cipher(options) { - this.options = options; + if (prime.isEven() || + !primes.simpleSieve || + !primes.fermatTest(prime) || + !millerRabin.test(prime)) { + //not a prime so +1 + error += 1; - this.type = this.options.type; - this.blockSize = 8; - this._init(); + if (gen === '02' || gen === '05') { + // we'd be able to check the generator + // it would fail so +8 + error += 8; + } else { + //we wouldn't be able to test the generator + // so +4 + error += 4; + } + primeCache[hex] = error; + return error; + } + if (!millerRabin.test(prime.shrn(1))) { + //not a safe prime + error += 2; + } + var rem; + switch (gen) { + case '02': + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + // unsuidable generator + error += 8; + } + break; + case '05': + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + // prime mod 10 needs to equal 3 or 7 + error += 8; + } + break; + default: + error += 4; + } + primeCache[hex] = error; + return error; +} - this.buffer = new Array(this.blockSize); - this.bufferOff = 0; +function DH(prime, generator, malleable) { + this.setGenerator(generator); + this.__prime = new BN(prime); + this._prime = BN.mont(this.__prime); + this._primeLen = prime.length; + this._pub = undefined; + this._priv = undefined; + this._primeCode = undefined; + if (malleable) { + this.setPublicKey = setPublicKey; + this.setPrivateKey = setPrivateKey; + } else { + this._primeCode = 8; + } } -module.exports = Cipher; +Object.defineProperty(DH.prototype, 'verifyError', { + enumerable: true, + get: function () { + if (typeof this._primeCode !== 'number') { + this._primeCode = checkPrime(this.__prime, this.__gen); + } + return this._primeCode; + } +}); +DH.prototype.generateKeys = function () { + if (!this._priv) { + this._priv = new BN(randomBytes(this._primeLen)); + } + this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); + return this.getPublicKey(); +}; -Cipher.prototype._init = function _init() { - // Might be overrided +DH.prototype.computeSecret = function (other) { + other = new BN(other); + other = other.toRed(this._prime); + var secret = other.redPow(this._priv).fromRed(); + var out = new Buffer(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer(prime.length - out.length); + front.fill(0); + out = Buffer.concat([front, out]); + } + return out; }; -Cipher.prototype.update = function update(data) { - if (data.length === 0) - return []; +DH.prototype.getPublicKey = function getPublicKey(enc) { + return formatReturnValue(this._pub, enc); +}; - if (this.type === 'decrypt') - return this._updateDecrypt(data); - else - return this._updateEncrypt(data); +DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue(this._priv, enc); }; -Cipher.prototype._buffer = function _buffer(data, off) { - // Append data to buffer - var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); - for (var i = 0; i < min; i++) - this.buffer[this.bufferOff + i] = data[off + i]; - this.bufferOff += min; +DH.prototype.getPrime = function (enc) { + return formatReturnValue(this.__prime, enc); +}; - // Shift next - return min; +DH.prototype.getGenerator = function (enc) { + return formatReturnValue(this._gen, enc); }; -Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { - this._update(this.buffer, 0, out, off); - this.bufferOff = 0; - return this.blockSize; +DH.prototype.setGenerator = function (gen, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(gen)) { + gen = new Buffer(gen, enc); + } + this.__gen = gen; + this._gen = new BN(gen); + return this; }; -Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { - var inputOff = 0; - var outputOff = 0; +function formatReturnValue(bn, enc) { + var buf = new Buffer(bn.toArray()); + if (!enc) { + return buf; + } else { + return buf.toString(enc); + } +} - var count = ((this.bufferOff + data.length) / this.blockSize) | 0; - var out = new Array(count * this.blockSize); +}).call(this)}).call(this,require("buffer").Buffer) +},{"./generatePrime":215,"bn.js":90,"buffer":130,"miller-rabin":285,"randombytes":327}],215:[function(require,module,exports){ +var randomBytes = require('randombytes'); +module.exports = findPrime; +findPrime.simpleSieve = simpleSieve; +findPrime.fermatTest = fermatTest; +var BN = require('bn.js'); +var TWENTYFOUR = new BN(24); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var ONE = new BN(1); +var TWO = new BN(2); +var FIVE = new BN(5); +var SIXTEEN = new BN(16); +var EIGHT = new BN(8); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var ELEVEN = new BN(11); +var FOUR = new BN(4); +var TWELVE = new BN(12); +var primes = null; - if (this.bufferOff !== 0) { - inputOff += this._buffer(data, inputOff); +function _getPrimes() { + if (primes !== null) + return primes; - if (this.bufferOff === this.buffer.length) - outputOff += this._flushBuffer(out, outputOff); - } + var limit = 0x100000; + var res = []; + res[0] = 2; + for (var i = 1, k = 3; k < limit; k += 2) { + var sqrt = Math.ceil(Math.sqrt(k)); + for (var j = 0; j < i && res[j] <= sqrt; j++) + if (k % res[j] === 0) + break; - // Write blocks - var max = data.length - ((data.length - inputOff) % this.blockSize); - for (; inputOff < max; inputOff += this.blockSize) { - this._update(data, inputOff, out, outputOff); - outputOff += this.blockSize; + if (i !== j && res[j] <= sqrt) + continue; + + res[i++] = k; } + primes = res; + return res; +} - // Queue rest - for (; inputOff < data.length; inputOff++, this.bufferOff++) - this.buffer[this.bufferOff] = data[inputOff]; +function simpleSieve(p) { + var primes = _getPrimes(); - return out; -}; + for (var i = 0; i < primes.length; i++) + if (p.modn(primes[i]) === 0) { + if (p.cmpn(primes[i]) === 0) { + return true; + } else { + return false; + } + } -Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { - var inputOff = 0; - var outputOff = 0; + return true; +} - var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; - var out = new Array(count * this.blockSize); +function fermatTest(p) { + var red = BN.mont(p); + return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; +} - // TODO(indutny): optimize it, this is far from optimal - for (; count > 0; count--) { - inputOff += this._buffer(data, inputOff); - outputOff += this._flushBuffer(out, outputOff); +function findPrime(bits, gen) { + if (bits < 16) { + // this is what openssl does + if (gen === 2 || gen === 5) { + return new BN([0x8c, 0x7b]); + } else { + return new BN([0x8c, 0x27]); + } } + gen = new BN(gen); - // Buffer rest of the input - inputOff += this._buffer(data, inputOff); + var num, n2; - return out; -}; + while (true) { + num = new BN(randomBytes(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n2 = num.shrn(1); + if (simpleSieve(n2) && simpleSieve(num) && + fermatTest(n2) && fermatTest(num) && + millerRabin.test(n2) && millerRabin.test(num)) { + return num; + } + } -Cipher.prototype.final = function final(buffer) { - var first; - if (buffer) - first = this.update(buffer); +} - var last; - if (this.type === 'encrypt') - last = this._finalEncrypt(); - else - last = this._finalDecrypt(); +},{"bn.js":90,"miller-rabin":285,"randombytes":327}],216:[function(require,module,exports){ +module.exports={ + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } +} +},{}],217:[function(require,module,exports){ +var assert = require('assert') +var BigInteger = require('bigi') - if (first) - return first.concat(last); - else - return last; -}; +var Point = require('./point') -Cipher.prototype._pad = function _pad(buffer, off) { - if (off === 0) - return false; +function Curve (p, a, b, Gx, Gy, n, h) { + this.p = p + this.a = a + this.b = b + this.G = Point.fromAffine(this, Gx, Gy) + this.n = n + this.h = h - while (off < buffer.length) - buffer[off++] = 0; + this.infinity = new Point(this, null, null, BigInteger.ZERO) - return true; -}; + // result caching + this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) + + // determine size of p in bytes + this.pLength = Math.floor((this.p.bitLength() + 7) / 8) +} -Cipher.prototype._finalEncrypt = function _finalEncrypt() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; +Curve.prototype.pointFromX = function (isOdd, x) { + var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) + var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves - var out = new Array(this.blockSize); - this._update(this.buffer, 0, out, 0); - return out; -}; + var y = beta + if (beta.isEven() ^ !isOdd) { + y = this.p.subtract(y) // -y % p + } -Cipher.prototype._unpad = function _unpad(buffer) { - return buffer; -}; + return Point.fromAffine(this, x, y) +} -Cipher.prototype._finalDecrypt = function _finalDecrypt() { - assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); - var out = new Array(this.blockSize); - this._flushBuffer(out, 0); +Curve.prototype.isInfinity = function (Q) { + if (Q === this.infinity) return true - return this._unpad(out); -}; + return Q.z.signum() === 0 && Q.y.signum() !== 0 +} -},{"minimalistic-assert":266}],209:[function(require,module,exports){ -'use strict'; +Curve.prototype.isOnCurve = function (Q) { + if (this.isInfinity(Q)) return true -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); + var x = Q.affineX + var y = Q.affineY + var a = this.a + var b = this.b + var p = this.p -var des = require('../des'); -var utils = des.utils; -var Cipher = des.Cipher; + // Check that xQ and yQ are integers in the interval [0, p - 1] + if (x.signum() < 0 || x.compareTo(p) >= 0) return false + if (y.signum() < 0 || y.compareTo(p) >= 0) return false -function DESState() { - this.tmp = new Array(2); - this.keys = null; + // and check that y^2 = x^3 + ax + b (mod p) + var lhs = y.square().mod(p) + var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) + return lhs.equals(rhs) } -function DES(options) { - Cipher.call(this, options); +/** + * Validate an elliptic curve point. + * + * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive + */ +Curve.prototype.validate = function (Q) { + // Check Q != O + assert(!this.isInfinity(Q), 'Point is at infinity') + assert(this.isOnCurve(Q), 'Point is not on the curve') - var state = new DESState(); - this._desState = state; + // Check nQ = O (where Q is a scalar multiple of G) + var nQ = Q.multiply(this.n) + assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') - this.deriveKeys(state, options.key); + return true } -inherits(DES, Cipher); -module.exports = DES; -DES.create = function create(options) { - return new DES(options); -}; - -var shiftTable = [ - 1, 1, 2, 2, 2, 2, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 1 -]; +module.exports = Curve -DES.prototype.deriveKeys = function deriveKeys(state, key) { - state.keys = new Array(16 * 2); +},{"./point":221,"assert":24,"bigi":34}],218:[function(require,module,exports){ +module.exports={ + "secp128r1": { + "p": "fffffffdffffffffffffffffffffffff", + "a": "fffffffdfffffffffffffffffffffffc", + "b": "e87579c11079f43dd824993c2cee5ed3", + "n": "fffffffe0000000075a30d1b9038a115", + "h": "01", + "Gx": "161ff7528b899b2d0c28607ca52c5b86", + "Gy": "cf5ac8395bafeb13c02da292dded7a83" + }, + "secp160k1": { + "p": "fffffffffffffffffffffffffffffffeffffac73", + "a": "00", + "b": "07", + "n": "0100000000000000000001b8fa16dfab9aca16b6b3", + "h": "01", + "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", + "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" + }, + "secp160r1": { + "p": "ffffffffffffffffffffffffffffffff7fffffff", + "a": "ffffffffffffffffffffffffffffffff7ffffffc", + "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", + "n": "0100000000000000000001f4c8f927aed3ca752257", + "h": "01", + "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", + "Gy": "23a628553168947d59dcc912042351377ac5fb32" + }, + "secp192k1": { + "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", + "a": "00", + "b": "03", + "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", + "h": "01", + "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", + "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" + }, + "secp192r1": { + "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", + "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", + "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", + "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", + "h": "01", + "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", + "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" + }, + "secp256k1": { + "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", + "a": "00", + "b": "07", + "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", + "h": "01", + "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" + }, + "secp256r1": { + "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", + "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", + "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", + "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", + "h": "01", + "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", + "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" + } +} - assert.equal(key.length, this.blockSize, 'Invalid key length'); +},{}],219:[function(require,module,exports){ +var Point = require('./point') +var Curve = require('./curve') - var kL = utils.readUInt32BE(key, 0); - var kR = utils.readUInt32BE(key, 4); +var getCurveByName = require('./names') - utils.pc1(kL, kR, state.tmp, 0); - kL = state.tmp[0]; - kR = state.tmp[1]; - for (var i = 0; i < state.keys.length; i += 2) { - var shift = shiftTable[i >>> 1]; - kL = utils.r28shl(kL, shift); - kR = utils.r28shl(kR, shift); - utils.pc2(kL, kR, state.keys, i); - } -}; +module.exports = { + Curve: Curve, + Point: Point, + getCurveByName: getCurveByName +} -DES.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._desState; +},{"./curve":217,"./names":220,"./point":221}],220:[function(require,module,exports){ +var BigInteger = require('bigi') - var l = utils.readUInt32BE(inp, inOff); - var r = utils.readUInt32BE(inp, inOff + 4); +var curves = require('./curves.json') +var Curve = require('./curve') - // Initial Permutation - utils.ip(l, r, state.tmp, 0); - l = state.tmp[0]; - r = state.tmp[1]; +function getCurveByName (name) { + var curve = curves[name] + if (!curve) return null - if (this.type === 'encrypt') - this._encrypt(state, l, r, state.tmp, 0); - else - this._decrypt(state, l, r, state.tmp, 0); + var p = new BigInteger(curve.p, 16) + var a = new BigInteger(curve.a, 16) + var b = new BigInteger(curve.b, 16) + var n = new BigInteger(curve.n, 16) + var h = new BigInteger(curve.h, 16) + var Gx = new BigInteger(curve.Gx, 16) + var Gy = new BigInteger(curve.Gy, 16) - l = state.tmp[0]; - r = state.tmp[1]; + return new Curve(p, a, b, Gx, Gy, n, h) +} - utils.writeUInt32BE(out, l, outOff); - utils.writeUInt32BE(out, r, outOff + 4); -}; +module.exports = getCurveByName -DES.prototype._pad = function _pad(buffer, off) { - var value = buffer.length - off; - for (var i = off; i < buffer.length; i++) - buffer[i] = value; +},{"./curve":217,"./curves.json":218,"bigi":34}],221:[function(require,module,exports){ +var assert = require('assert') +var Buffer = require('safe-buffer').Buffer +var BigInteger = require('bigi') - return true; -}; +var THREE = BigInteger.valueOf(3) -DES.prototype._unpad = function _unpad(buffer) { - var pad = buffer[buffer.length - 1]; - for (var i = buffer.length - pad; i < buffer.length; i++) - assert.equal(buffer[i], pad); +function Point (curve, x, y, z) { + assert.notStrictEqual(z, undefined, 'Missing Z coordinate') - return buffer.slice(0, buffer.length - pad); -}; + this.curve = curve + this.x = x + this.y = y + this.z = z + this._zInv = null -DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { - var l = lStart; - var r = rStart; + this.compressed = true +} - // Apply f() x16 times - for (var i = 0; i < state.keys.length; i += 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; +Object.defineProperty(Point.prototype, 'zInv', { + get: function () { + if (this._zInv === null) { + this._zInv = this.z.modInverse(this.curve.p) + } - // f(r, k) - utils.expand(r, state.tmp, 0); + return this._zInv + } +}) - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); +Object.defineProperty(Point.prototype, 'affineX', { + get: function () { + return this.x.multiply(this.zInv).mod(this.curve.p) + } +}) - var t = r; - r = (l ^ f) >>> 0; - l = t; +Object.defineProperty(Point.prototype, 'affineY', { + get: function () { + return this.y.multiply(this.zInv).mod(this.curve.p) } +}) - // Reverse Initial Permutation - utils.rip(r, l, out, off); -}; +Point.fromAffine = function (curve, x, y) { + return new Point(curve, x, y, BigInteger.ONE) +} -DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { - var l = rStart; - var r = lStart; +Point.prototype.equals = function (other) { + if (other === this) return true + if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) + if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) - // Apply f() x16 times - for (var i = state.keys.length - 2; i >= 0; i -= 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; + // u = Y2 * Z1 - Y1 * Z2 + var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) - // f(r, k) - utils.expand(l, state.tmp, 0); + if (u.signum() !== 0) return false - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); + // v = X2 * Z1 - X1 * Z2 + var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) - var t = l; - l = (r ^ f) >>> 0; - r = t; - } + return v.signum() === 0 +} - // Reverse Initial Permutation - utils.rip(l, r, out, off); -}; +Point.prototype.negate = function () { + var y = this.curve.p.subtract(this.y) -},{"../des":206,"inherits":259,"minimalistic-assert":266}],210:[function(require,module,exports){ -'use strict'; + return new Point(this.curve, this.x, y, this.z) +} -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); +Point.prototype.add = function (b) { + if (this.curve.isInfinity(this)) return b + if (this.curve.isInfinity(b)) return this -var des = require('../des'); -var Cipher = des.Cipher; -var DES = des.DES; + var x1 = this.x + var y1 = this.y + var x2 = b.x + var y2 = b.y -function EDEState(type, key) { - assert.equal(key.length, 24, 'Invalid key length'); + // u = Y2 * Z1 - Y1 * Z2 + var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) + // v = X2 * Z1 - X1 * Z2 + var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) - var k1 = key.slice(0, 8); - var k2 = key.slice(8, 16); - var k3 = key.slice(16, 24); + if (v.signum() === 0) { + if (u.signum() === 0) { + return this.twice() // this == b, so double + } - if (type === 'encrypt') { - this.ciphers = [ - DES.create({ type: 'encrypt', key: k1 }), - DES.create({ type: 'decrypt', key: k2 }), - DES.create({ type: 'encrypt', key: k3 }) - ]; - } else { - this.ciphers = [ - DES.create({ type: 'decrypt', key: k3 }), - DES.create({ type: 'encrypt', key: k2 }), - DES.create({ type: 'decrypt', key: k1 }) - ]; + return this.curve.infinity // this = -b, so infinity } -} -function EDE(options) { - Cipher.call(this, options); + var v2 = v.square() + var v3 = v2.multiply(v) + var x1v2 = x1.multiply(v2) + var zu2 = u.square().multiply(this.z) - var state = new EDEState(this.type, this.options.key); - this._edeState = state; -} -inherits(EDE, Cipher); + // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) + var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) + // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 + var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) + // z3 = v^3 * z1 * z2 + var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) -module.exports = EDE; + return new Point(this.curve, x3, y3, z3) +} -EDE.create = function create(options) { - return new EDE(options); -}; +Point.prototype.twice = function () { + if (this.curve.isInfinity(this)) return this + if (this.y.signum() === 0) return this.curve.infinity -EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; + var x1 = this.x + var y1 = this.y - state.ciphers[0]._update(inp, inOff, out, outOff); - state.ciphers[1]._update(out, outOff, out, outOff); - state.ciphers[2]._update(out, outOff, out, outOff); -}; + var y1z1 = y1.multiply(this.z).mod(this.curve.p) + var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) + var a = this.curve.a -EDE.prototype._pad = DES.prototype._pad; -EDE.prototype._unpad = DES.prototype._unpad; + // w = 3 * x1^2 + a * z1^2 + var w = x1.square().multiply(THREE) -},{"../des":206,"inherits":259,"minimalistic-assert":266}],211:[function(require,module,exports){ -'use strict'; + if (a.signum() !== 0) { + w = w.add(this.z.square().multiply(a)) + } -exports.readUInt32BE = function readUInt32BE(bytes, off) { - var res = (bytes[0 + off] << 24) | - (bytes[1 + off] << 16) | - (bytes[2 + off] << 8) | - bytes[3 + off]; - return res >>> 0; -}; + w = w.mod(this.curve.p) + // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) + var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) + // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 + var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) + // z3 = 8 * (y1 * z1)^3 + var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) -exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { - bytes[0 + off] = value >>> 24; - bytes[1 + off] = (value >>> 16) & 0xff; - bytes[2 + off] = (value >>> 8) & 0xff; - bytes[3 + off] = value & 0xff; -}; + return new Point(this.curve, x3, y3, z3) +} -exports.ip = function ip(inL, inR, out, off) { - var outL = 0; - var outR = 0; +// Simple NAF (Non-Adjacent Form) multiplication algorithm +// TODO: modularize the multiplication algorithm +Point.prototype.multiply = function (k) { + if (this.curve.isInfinity(this)) return this + if (k.signum() === 0) return this.curve.infinity - for (var i = 6; i >= 0; i -= 2) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } + var e = k + var h = e.multiply(THREE) - for (var i = 6; i >= 0; i -= 2) { - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - } - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } + var neg = this.negate() + var R = this - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + for (var i = h.bitLength() - 2; i > 0; --i) { + var hBit = h.testBit(i) + var eBit = e.testBit(i) -exports.rip = function rip(inL, inR, out, off) { - var outL = 0; - var outR = 0; + R = R.twice() - for (var i = 0; i < 4; i++) { - for (var j = 24; j >= 0; j -= 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - for (var i = 4; i < 8; i++) { - for (var j = 24; j >= 0; j -= 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; + if (hBit !== eBit) { + R = R.add(hBit ? this : neg) } } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + return R +} -exports.pc1 = function pc1(inL, inR, out, off) { - var outL = 0; - var outR = 0; +// Compute this*j + x*k (simultaneous multiplication) +Point.prototype.multiplyTwo = function (j, x, k) { + var i = Math.max(j.bitLength(), k.bitLength()) - 1 + var R = this.curve.infinity + var both = this.add(x) - // 7, 15, 23, 31, 39, 47, 55, 63 - // 6, 14, 22, 30, 39, 47, 55, 63 - // 5, 13, 21, 29, 39, 47, 55, 63 - // 4, 12, 20, 28 - for (var i = 7; i >= 5; i--) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } + while (i >= 0) { + var jBit = j.testBit(i) + var kBit = k.testBit(i) - // 1, 9, 17, 25, 33, 41, 49, 57 - // 2, 10, 18, 26, 34, 42, 50, 58 - // 3, 11, 19, 27, 35, 43, 51, 59 - // 36, 44, 52, 60 - for (var i = 1; i <= 3; i++) { - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; + R = R.twice() + + if (jBit) { + if (kBit) { + R = R.add(both) + } else { + R = R.add(this) + } + } else if (kBit) { + R = R.add(x) } - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; + --i } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + return R +} -exports.r28shl = function r28shl(num, shift) { - return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); -}; +Point.prototype.getEncoded = function (compressed) { + if (compressed == null) compressed = this.compressed + if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' -var pc2table = [ - // inL => outL - 14, 11, 17, 4, 27, 23, 25, 0, - 13, 22, 7, 18, 5, 9, 16, 24, - 2, 20, 12, 21, 1, 8, 15, 26, + var x = this.affineX + var y = this.affineY + var byteLength = this.curve.pLength + var buffer - // inR => outR - 15, 4, 25, 19, 9, 1, 26, 16, - 5, 11, 23, 8, 12, 7, 17, 0, - 22, 3, 10, 14, 6, 20, 27, 24 -]; + // 0x02/0x03 | X + if (compressed) { + buffer = Buffer.allocUnsafe(1 + byteLength) + buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) -exports.pc2 = function pc2(inL, inR, out, off) { - var outL = 0; - var outR = 0; + // 0x04 | X | Y + } else { + buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) + buffer.writeUInt8(0x04, 0) - var len = pc2table.length >>> 1; - for (var i = 0; i < len; i++) { - outL <<= 1; - outL |= (inL >>> pc2table[i]) & 0x1; - } - for (var i = len; i < pc2table.length; i++) { - outR <<= 1; - outR |= (inR >>> pc2table[i]) & 0x1; + y.toBuffer(byteLength).copy(buffer, 1 + byteLength) } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + x.toBuffer(byteLength).copy(buffer, 1) -exports.expand = function expand(r, out, off) { - var outL = 0; - var outR = 0; + return buffer +} - outL = ((r & 1) << 5) | (r >>> 27); - for (var i = 23; i >= 15; i -= 4) { - outL <<= 6; - outL |= (r >>> i) & 0x3f; - } - for (var i = 11; i >= 3; i -= 4) { - outR |= (r >>> i) & 0x3f; - outR <<= 6; - } - outR |= ((r & 0x1f) << 1) | (r >>> 31); +Point.decodeFrom = function (curve, buffer) { + var type = buffer.readUInt8(0) + var compressed = (type !== 4) - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) + var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) -var sTable = [ - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, + var Q + if (compressed) { + assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') + assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, + var isOdd = (type === 0x03) + Q = curve.pointFromX(isOdd, x) + } else { + assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, + var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) + Q = Point.fromAffine(curve, x, y) + } - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, + Q.compressed = compressed + return Q +} - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, +Point.prototype.toString = function () { + if (this.curve.isInfinity(this)) return '(INFINITY)' - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, + return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' +} - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, +module.exports = Point - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 -]; +},{"assert":24,"bigi":34,"safe-buffer":345}],222:[function(require,module,exports){ +'use strict'; -exports.substitute = function substitute(inL, inR) { - var out = 0; - for (var i = 0; i < 4; i++) { - var b = (inL >>> (18 - i * 6)) & 0x3f; - var sb = sTable[i * 0x40 + b]; +var elliptic = exports; - out <<= 4; - out |= sb; - } - for (var i = 0; i < 4; i++) { - var b = (inR >>> (18 - i * 6)) & 0x3f; - var sb = sTable[4 * 0x40 + i * 0x40 + b]; +elliptic.version = require('../package.json').version; +elliptic.utils = require('./elliptic/utils'); +elliptic.rand = require('brorand'); +elliptic.curve = require('./elliptic/curve'); +elliptic.curves = require('./elliptic/curves'); - out <<= 4; - out |= sb; - } - return out >>> 0; -}; +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); -var permuteTable = [ - 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, - 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 -]; +},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,"brorand":103}],223:[function(require,module,exports){ +'use strict'; -exports.permute = function permute(num) { - var out = 0; - for (var i = 0; i < permuteTable.length; i++) { - out <<= 1; - out |= (num >>> permuteTable[i]) & 0x1; - } - return out >>> 0; -}; +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; -exports.padSplit = function padSplit(num, size, group) { - var str = num.toString(2); - while (str.length < size) - str = '0' + str; +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); - var out = []; - for (var i = 0; i < size; i += group) - out.push(str.slice(i, i + group)); - return out.join(' '); -}; + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); -},{}],212:[function(require,module,exports){ -(function (Buffer){ -var generatePrime = require('./lib/generatePrime') -var primes = require('./lib/primes.json') + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); -var DH = require('./lib/dh') + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); -function getDiffieHellman (mod) { - var prime = new Buffer(primes[mod].prime, 'hex') - var gen = new Buffer(primes[mod].gen, 'hex') + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); - return new DH(prime, gen) -} + this._bitLength = this.n ? this.n.bitLength() : 0; -var ENCODINGS = { - 'binary': true, 'hex': true, 'base64': true + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } } +module.exports = BaseCurve; -function createDiffieHellman (prime, enc, generator, genc) { - if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { - return createDiffieHellman(prime, 'binary', enc, generator) - } +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; - enc = enc || 'binary' - genc = genc || 'binary' - generator = generator || new Buffer([2]) +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; - if (!Buffer.isBuffer(generator)) { - generator = new Buffer(generator, genc) - } +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); - if (typeof prime === 'number') { - return new DH(generatePrime(prime, generator), generator, true) + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + var j; + var nafW; + for (j = 0; j < naf.length; j += doubles.step) { + nafW = 0; + for (var l = j + doubles.step - 1; l >= j; l--) + nafW = (nafW << 1) + naf[l]; + repr.push(nafW); } - if (!Buffer.isBuffer(prime)) { - prime = new Buffer(prime, enc) + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (j = 0; j < repr.length; j++) { + nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); } + return a.toP(); +}; - return new DH(prime, generator, true) -} +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; -exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman -exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; -}).call(this,require("buffer").Buffer) -},{"./lib/dh":213,"./lib/generatePrime":214,"./lib/primes.json":215,"buffer":131}],213:[function(require,module,exports){ -(function (Buffer){ -var BN = require('bn.js'); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var TWENTYFOUR = new BN(24); -var ELEVEN = new BN(11); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var primes = require('./generatePrime'); -var randomBytes = require('randombytes'); -module.exports = DH; + // Get NAF form + var naf = getNAF(k, w, this._bitLength); -function setPublicKey(pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this._pub = new BN(pub); - return this; -} + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var l = 0; i >= 0 && naf[i] === 0; i--) + l++; + if (i >= 0) + l++; + acc = acc.dblp(l); -function setPrivateKey(priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } } - this._priv = new BN(priv); - return this; -} + return p.type === 'affine' ? acc.toP() : acc; +}; -var primeCache = {}; -function checkPrime(prime, generator) { - var gen = generator.toString('hex'); - var hex = [gen, prime.toString(16)].join('_'); - if (hex in primeCache) { - return primeCache[hex]; +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + var i; + var j; + var p; + for (i = 0; i < len; i++) { + p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; } - var error = 0; - if (prime.isEven() || - !primes.simpleSieve || - !primes.fermatTest(prime) || - !millerRabin.test(prime)) { - //not a prime so +1 - error += 1; + // Comb small window NAFs + for (i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); + naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } - if (gen === '02' || gen === '05') { - // we'd be able to check the generator - // it would fail so +8 - error += 8; + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); } else { - //we wouldn't be able to test the generator - // so +4 - error += 4; + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3, /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; } - primeCache[hex] = error; - return error; - } - if (!millerRabin.test(prime.shrn(1))) { - //not a safe prime - error += 2; } - var rem; - switch (gen) { - case '02': - if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { - // unsuidable generator - error += 8; - } - break; - case '05': - rem = prime.mod(TEN); - if (rem.cmp(THREE) && rem.cmp(SEVEN)) { - // prime mod 10 needs to equal 3 or 7 - error += 8; + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) break; - default: - error += 4; - } - primeCache[hex] = error; - return error; -} -function DH(prime, generator, malleable) { - this.setGenerator(generator); - this.__prime = new BN(prime); - this._prime = BN.mont(this.__prime); - this._primeLen = prime.length; - this._pub = undefined; - this._priv = undefined; - this._primeCode = undefined; - if (malleable) { - this.setPublicKey = setPublicKey; - this.setPrivateKey = setPrivateKey; - } else { - this._primeCode = 8; - } -} -Object.defineProperty(DH.prototype, 'verifyError', { - enumerable: true, - get: function () { - if (typeof this._primeCode !== 'number') { - this._primeCode = checkPrime(this.__prime, this.__gen); + for (j = 0; j < len; j++) { + var z = tmp[j]; + p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); } - return this._primeCode; } -}); -DH.prototype.generateKeys = function () { - if (!this._priv) { - this._priv = new BN(randomBytes(this._primeLen)); + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); } - this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); - return this.getPublicKey(); + throw new Error('Unknown point format'); }; -DH.prototype.computeSecret = function (other) { - other = new BN(other); - other = other.toRed(this._prime); - var secret = other.redPow(this._priv).fromRed(); - var out = new Buffer(secret.toArray()); - var prime = this.getPrime(); - if (out.length < prime.length) { - var front = new Buffer(prime.length - out.length); - front.fill(0); - out = Buffer.concat([front, out]); - } - return out; +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); }; -DH.prototype.getPublicKey = function getPublicKey(enc) { - return formatReturnValue(this._pub, enc); +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); }; -DH.prototype.getPrivateKey = function getPrivateKey(enc) { - return formatReturnValue(this._priv, enc); +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); }; -DH.prototype.getPrime = function (enc) { - return formatReturnValue(this.__prime, enc); +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null, + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; }; -DH.prototype.getGenerator = function (enc) { - return formatReturnValue(this._gen, enc); +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); }; -DH.prototype.setGenerator = function (gen, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(gen)) { - gen = new Buffer(gen, enc); +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); } - this.__gen = gen; - this._gen = new BN(gen); - return this; + return { + step: step, + points: doubles, + }; }; -function formatReturnValue(bn, enc) { - var buf = new Buffer(bn.toArray()); - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } -} +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; -}).call(this,require("buffer").Buffer) -},{"./generatePrime":214,"bn.js":90,"buffer":131,"miller-rabin":265,"randombytes":306}],214:[function(require,module,exports){ -var randomBytes = require('randombytes'); -module.exports = findPrime; -findPrime.simpleSieve = simpleSieve; -findPrime.fermatTest = fermatTest; + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res, + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +},{"../utils":236,"bn.js":90}],224:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); var BN = require('bn.js'); -var TWENTYFOUR = new BN(24); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var ONE = new BN(1); -var TWO = new BN(2); -var FIVE = new BN(5); -var SIXTEEN = new BN(16); -var EIGHT = new BN(8); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var ELEVEN = new BN(11); -var FOUR = new BN(4); -var TWELVE = new BN(12); -var primes = null; +var inherits = require('inherits'); +var Base = require('./base'); -function _getPrimes() { - if (primes !== null) - return primes; +var assert = utils.assert; - var limit = 0x100000; - var res = []; - res[0] = 2; - for (var i = 1, k = 3; k < limit; k += 2) { - var sqrt = Math.ceil(Math.sqrt(k)); - for (var j = 0; j < i && res[j] <= sqrt; j++) - if (k % res[j] === 0) - break; +function EdwardsCurve(conf) { + // NOTE: Important as we are creating point in Base.call() + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; - if (i !== j && res[j] <= sqrt) - continue; + Base.call(this, 'edwards', conf); - res[i++] = k; - } - primes = res; - return res; + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; } +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; -function simpleSieve(p) { - var primes = _getPrimes(); +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); +}; - for (var i = 0; i < primes.length; i++) - if (p.modn(primes[i]) === 0) { - if (p.cmpn(primes[i]) === 0) { - return true; - } else { - return false; - } - } +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); +}; - return true; -} +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); +}; -function fermatTest(p) { - var red = BN.mont(p); - return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; -} +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -function findPrime(bits, gen) { - if (bits < 16) { - // this is what openssl does - if (gen === 2 || gen === 5) { - return new BN([0x8c, 0x7b]); - } else { - return new BN([0x8c, 0x27]); - } - } - gen = new BN(gen); + var x2 = x.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x2)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - var num, n2; + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); - while (true) { - num = new BN(randomBytes(Math.ceil(bits / 8))); - while (num.bitLength() > bits) { - num.ishrn(1); - } - if (num.isEven()) { - num.iadd(ONE); - } - if (!num.testn(1)) { - num.iadd(TWO); - } - if (!gen.cmp(TWO)) { - while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { - num.iadd(FOUR); - } - } else if (!gen.cmp(FIVE)) { - while (num.mod(TEN).cmp(THREE)) { - num.iadd(FOUR); - } - } - n2 = num.shrn(1); - if (simpleSieve(n2) && simpleSieve(num) && - fermatTest(n2) && fermatTest(num) && - millerRabin.test(n2) && millerRabin.test(num)) { - return num; - } + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); + + // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) + var y2 = y.redSqr(); + var lhs = y2.redSub(this.c2); + var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); + var x2 = lhs.redMul(rhs.redInvm()); + + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); } -} + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -},{"bn.js":90,"miller-rabin":265,"randombytes":306}],215:[function(require,module,exports){ -module.exports={ - "modp1": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" - }, - "modp2": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" - }, - "modp5": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" - }, - "modp14": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" - }, - "modp15": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" - }, - "modp16": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" - }, - "modp17": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" - }, - "modp18": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; + + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); + + var x2 = point.x.redSqr(); + var y2 = point.y.redSqr(); + var lhs = x2.redMul(this.a).redAdd(y2); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); + + return lhs.cmp(rhs) === 0; +}; + +function Point(curve, x, y, z, t) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && y === null && z === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = z ? new BN(z, 16) : this.curve.one; + this.t = t && new BN(t, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + + // Use extended coordinates + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); } + } } -},{}],216:[function(require,module,exports){ -var assert = require('assert') -var BigInteger = require('bigi') +inherits(Point, Base.BasePoint); -var Point = require('./point') +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; -function Curve (p, a, b, Gx, Gy, n, h) { - this.p = p - this.a = a - this.b = b - this.G = Point.fromAffine(this, Gx, Gy) - this.n = n - this.h = h +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; - this.infinity = new Point(this, null, null, BigInteger.ZERO) +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; - // result caching - this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // determine size of p in bytes - this.pLength = Math.floor((this.p.bitLength() + 7) / 8) -} +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.x.cmpn(0) === 0 && + (this.y.cmp(this.z) === 0 || + (this.zOne && this.y.cmp(this.curve.c) === 0)); +}; -Curve.prototype.pointFromX = function (isOdd, x) { - var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) - var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S - var y = beta - if (beta.isEven() ^ !isOdd) { - y = this.p.subtract(y) // -y % p + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = 2 * Z1^2 + var c = this.z.redSqr(); + c = c.redIAdd(c); + // D = a * A + var d = this.curve._mulA(a); + // E = (X1 + Y1)^2 - A - B + var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); + // G = D + B + var g = d.redAdd(b); + // F = G - C + var f = g.redSub(c); + // H = D - B + var h = d.redSub(b); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projDbl = function _projDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #doubling-dbl-2008-bbjlp + // #doubling-dbl-2007-bl + // and others + // Generally 3M + 4S or 2M + 4S + + // B = (X1 + Y1)^2 + var b = this.x.redAdd(this.y).redSqr(); + // C = X1^2 + var c = this.x.redSqr(); + // D = Y1^2 + var d = this.y.redSqr(); + + var nx; + var ny; + var nz; + var e; + var h; + var j; + if (this.curve.twisted) { + // E = a * C + e = this.curve._mulA(c); + // F = E + D + var f = e.redAdd(d); + if (this.zOne) { + // X3 = (B - C - D) * (F - 2) + nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F^2 - 2 * F + nz = f.redSqr().redSub(f).redSub(f); + } else { + // H = Z1^2 + h = this.z.redSqr(); + // J = F - 2 * H + j = f.redSub(h).redISub(h); + // X3 = (B-C-D)*J + nx = b.redSub(c).redISub(d).redMul(j); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F * J + nz = f.redMul(j); + } + } else { + // E = C + D + e = c.redAdd(d); + // H = (c * Z1)^2 + h = this.curve._mulC(this.z).redSqr(); + // J = E - 2 * H + j = e.redSub(h).redSub(h); + // X3 = c * (B - E) * J + nx = this.curve._mulC(b.redISub(e)).redMul(j); + // Y3 = c * E * (C - D) + ny = this.curve._mulC(e).redMul(c.redISub(d)); + // Z3 = E * J + nz = e.redMul(j); } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); +}; + +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M - return Point.fromAffine(this, x, y) -} + // A = (Y1 - X1) * (Y2 - X2) + var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); + // B = (Y1 + X1) * (Y2 + X2) + var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); + // C = T1 * k * T2 + var c = this.t.redMul(this.curve.dd).redMul(p.t); + // D = Z1 * 2 * Z2 + var d = this.z.redMul(p.z.redAdd(p.z)); + // E = B - A + var e = b.redSub(a); + // F = D - C + var f = d.redSub(c); + // G = D + C + var g = d.redAdd(c); + // H = B + A + var h = b.redAdd(a); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; -Curve.prototype.isInfinity = function (Q) { - if (Q === this.infinity) return true +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S - return Q.z.signum() === 0 && Q.y.signum() !== 0 -} + // A = Z1 * Z2 + var a = this.z.redMul(p.z); + // B = A^2 + var b = a.redSqr(); + // C = X1 * X2 + var c = this.x.redMul(p.x); + // D = Y1 * Y2 + var d = this.y.redMul(p.y); + // E = d * C * D + var e = this.curve.d.redMul(c).redMul(d); + // F = B - E + var f = b.redSub(e); + // G = B + E + var g = b.redAdd(e); + // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) + var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); + var nx = a.redMul(f).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + // Y3 = A * G * (D - a * C) + ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); + // Z3 = F * G + nz = f.redMul(g); + } else { + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); + } + return this.curve.point(nx, ny, nz); +}; -Curve.prototype.isOnCurve = function (Q) { - if (this.isInfinity(Q)) return true +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; - var x = Q.affineX - var y = Q.affineY - var a = this.a - var b = this.b - var p = this.p + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); +}; - // Check that xQ and yQ are integers in the interval [0, p - 1] - if (x.signum() < 0 || x.compareTo(p) >= 0) return false - if (y.signum() < 0 || y.compareTo(p) >= 0) return false +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; - // and check that y^2 = x^3 + ax + b (mod p) - var lhs = y.square().mod(p) - var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) - return lhs.equals(rhs) -} +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; -/** - * Validate an elliptic curve point. - * - * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive - */ -Curve.prototype.validate = function (Q) { - // Check Q != O - assert(!this.isInfinity(Q), 'Point is at infinity') - assert(this.isOnCurve(Q), 'Point is not on the curve') +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); +}; - // Check nQ = O (where Q is a scalar multiple of G) - var nQ = Q.multiply(this.n) - assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; - return true -} + // Normalize coordinates + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; +}; -module.exports = Curve +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; -},{"./point":220,"assert":24,"bigi":34}],217:[function(require,module,exports){ -module.exports={ - "secp128r1": { - "p": "fffffffdffffffffffffffffffffffff", - "a": "fffffffdfffffffffffffffffffffffc", - "b": "e87579c11079f43dd824993c2cee5ed3", - "n": "fffffffe0000000075a30d1b9038a115", - "h": "01", - "Gx": "161ff7528b899b2d0c28607ca52c5b86", - "Gy": "cf5ac8395bafeb13c02da292dded7a83" - }, - "secp160k1": { - "p": "fffffffffffffffffffffffffffffffeffffac73", - "a": "00", - "b": "07", - "n": "0100000000000000000001b8fa16dfab9aca16b6b3", - "h": "01", - "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", - "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" - }, - "secp160r1": { - "p": "ffffffffffffffffffffffffffffffff7fffffff", - "a": "ffffffffffffffffffffffffffffffff7ffffffc", - "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", - "n": "0100000000000000000001f4c8f927aed3ca752257", - "h": "01", - "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", - "Gy": "23a628553168947d59dcc912042351377ac5fb32" - }, - "secp192k1": { - "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", - "a": "00", - "b": "03", - "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", - "h": "01", - "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", - "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" - }, - "secp192r1": { - "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", - "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", - "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", - "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", - "h": "01", - "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", - "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" - }, - "secp256k1": { - "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - "a": "00", - "b": "07", - "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", - "h": "01", - "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" - }, - "secp256r1": { - "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", - "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", - "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", - "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", - "h": "01", - "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", - "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" - } -} +Point.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); +}; -},{}],218:[function(require,module,exports){ -var Point = require('./point') -var Curve = require('./curve') +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); +}; -var getCurveByName = require('./names') +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; +}; -module.exports = { - Curve: Curve, - Point: Point, - getCurveByName: getCurveByName -} +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; -},{"./curve":216,"./names":219,"./point":220}],219:[function(require,module,exports){ -var BigInteger = require('bigi') + var xc = x.clone(); + var t = this.curve.redN.redMul(this.z); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; -var curves = require('./curves.json') -var Curve = require('./curve') + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; -function getCurveByName (name) { - var curve = curves[name] - if (!curve) return null +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; - var p = new BigInteger(curve.p, 16) - var a = new BigInteger(curve.a, 16) - var b = new BigInteger(curve.b, 16) - var n = new BigInteger(curve.n, 16) - var h = new BigInteger(curve.h, 16) - var Gx = new BigInteger(curve.Gx, 16) - var Gy = new BigInteger(curve.Gy, 16) +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],225:[function(require,module,exports){ +'use strict'; - return new Curve(p, a, b, Gx, Gy, n, h) -} +var curve = exports; -module.exports = getCurveByName +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); -},{"./curve":216,"./curves.json":217,"bigi":34}],220:[function(require,module,exports){ -var assert = require('assert') -var Buffer = require('safe-buffer').Buffer -var BigInteger = require('bigi') +},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(require,module,exports){ +'use strict'; -var THREE = BigInteger.valueOf(3) +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); -function Point (curve, x, y, z) { - assert.notStrictEqual(z, undefined, 'Missing Z coordinate') +var utils = require('../utils'); - this.curve = curve - this.x = x - this.y = y - this.z = z - this._zInv = null +function MontCurve(conf) { + Base.call(this, 'mont', conf); - this.compressed = true + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); } +inherits(MontCurve, Base); +module.exports = MontCurve; -Object.defineProperty(Point.prototype, 'zInv', { - get: function () { - if (this._zInv === null) { - this._zInv = this.z.modInverse(this.curve.p) - } - - return this._zInv - } -}) +MontCurve.prototype.validate = function validate(point) { + var x = point.normalize().x; + var x2 = x.redSqr(); + var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); + var y = rhs.redSqrt(); -Object.defineProperty(Point.prototype, 'affineX', { - get: function () { - return this.x.multiply(this.zInv).mod(this.curve.p) - } -}) + return y.redSqr().cmp(rhs) === 0; +}; -Object.defineProperty(Point.prototype, 'affineY', { - get: function () { - return this.y.multiply(this.zInv).mod(this.curve.p) +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x, 16); + this.z = new BN(z, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); } -}) - -Point.fromAffine = function (curve, x, y) { - return new Point(curve, x, y, BigInteger.ONE) } +inherits(Point, Base.BasePoint); -Point.prototype.equals = function (other) { - if (other === this) return true - if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) - if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) - - // u = Y2 * Z1 - Y1 * Z2 - var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) - - if (u.signum() !== 0) return false +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); +}; - // v = X2 * Z1 - X1 * Z2 - var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); +}; - return v.signum() === 0 -} +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; -Point.prototype.negate = function () { - var y = this.curve.p.subtract(this.y) +Point.prototype.precompute = function precompute() { + // No-op +}; - return new Point(this.curve, this.x, y, this.z) -} +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; -Point.prototype.add = function (b) { - if (this.curve.isInfinity(this)) return b - if (this.curve.isInfinity(b)) return this +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); +}; - var x1 = this.x - var y1 = this.y - var x2 = b.x - var y2 = b.y +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - // u = Y2 * Z1 - Y1 * Z2 - var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) - // v = X2 * Z1 - X1 * Z2 - var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; - if (v.signum() === 0) { - if (u.signum() === 0) { - return this.twice() // this == b, so double - } +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A - return this.curve.infinity // this = -b, so infinity - } + // A = X1 + Z1 + var a = this.x.redAdd(this.z); + // AA = A^2 + var aa = a.redSqr(); + // B = X1 - Z1 + var b = this.x.redSub(this.z); + // BB = B^2 + var bb = b.redSqr(); + // C = AA - BB + var c = aa.redSub(bb); + // X3 = AA * BB + var nx = aa.redMul(bb); + // Z3 = C * (BB + A24 * C) + var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); + return this.curve.point(nx, nz); +}; - var v2 = v.square() - var v3 = v2.multiply(v) - var x1v2 = x1.multiply(v2) - var zu2 = u.square().multiply(this.z) +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; - // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) - var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) - // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 - var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) - // z3 = v^3 * z1 * z2 - var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A - return new Point(this.curve, x3, y3, z3) -} + // A = X2 + Z2 + var a = this.x.redAdd(this.z); + // B = X2 - Z2 + var b = this.x.redSub(this.z); + // C = X3 + Z3 + var c = p.x.redAdd(p.z); + // D = X3 - Z3 + var d = p.x.redSub(p.z); + // DA = D * A + var da = d.redMul(a); + // CB = C * B + var cb = c.redMul(b); + // X5 = Z1 * (DA + CB)^2 + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + // Z5 = X1 * (DA - CB)^2 + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); +}; -Point.prototype.twice = function () { - if (this.curve.isInfinity(this)) return this - if (this.y.signum() === 0) return this.curve.infinity +Point.prototype.mul = function mul(k) { + var t = k.clone(); + var a = this; // (N / 2) * Q + Q + var b = this.curve.point(null, null); // (N / 2) * Q + var c = this; // Q - var x1 = this.x - var y1 = this.y + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); - var y1z1 = y1.multiply(this.z).mod(this.curve.p) - var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) - var a = this.curve.a + for (var i = bits.length - 1; i >= 0; i--) { + if (bits[i] === 0) { + // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q + a = a.diffAdd(b, c); + // N * Q = 2 * ((N / 2) * Q + Q)) + b = b.dbl(); + } else { + // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) + b = a.diffAdd(b, c); + // N * Q + Q = 2 * ((N / 2) * Q + Q) + a = a.dbl(); + } + } + return b; +}; - // w = 3 * x1^2 + a * z1^2 - var w = x1.square().multiply(THREE) +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - if (a.signum() !== 0) { - w = w.add(this.z.square().multiply(a)) - } +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; - w = w.mod(this.curve.p) - // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) - var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) - // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 - var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) - // z3 = 8 * (y1 * z1)^3 - var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; - return new Point(this.curve, x3, y3, z3) -} +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; -// Simple NAF (Non-Adjacent Form) multiplication algorithm -// TODO: modularize the multiplication algorithm -Point.prototype.multiply = function (k) { - if (this.curve.isInfinity(this)) return this - if (k.signum() === 0) return this.curve.infinity +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); - var e = k - var h = e.multiply(THREE) + return this.x.fromRed(); +}; - var neg = this.negate() - var R = this +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],227:[function(require,module,exports){ +'use strict'; - for (var i = h.bitLength() - 2; i > 0; --i) { - var hBit = h.testBit(i) - var eBit = e.testBit(i) +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); - R = R.twice() +var assert = utils.assert; - if (hBit !== eBit) { - R = R.add(hBit ? this : neg) - } - } +function ShortCurve(conf) { + Base.call(this, 'short', conf); - return R -} + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); -// Compute this*j + x*k (simultaneous multiplication) -Point.prototype.multiplyTwo = function (j, x, k) { - var i = Math.max(j.bitLength(), k.bitLength()) - 1 - var R = this.curve.infinity - var both = this.add(x) + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - while (i >= 0) { - var jBit = j.testBit(i) - var kBit = k.testBit(i) + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits(ShortCurve, Base); +module.exports = ShortCurve; - R = R.twice() +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; - if (jBit) { - if (kBit) { - R = R.add(both) - } else { - R = R.add(this) - } - } else if (kBit) { - R = R.add(x) + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); } - --i } - return R -} + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16), + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } -Point.prototype.getEncoded = function (compressed) { - if (compressed == null) compressed = this.compressed - if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' + return { + beta: beta, + lambda: lambda, + basis: basis, + }; +}; - var x = this.affineX - var y = this.affineY - var byteLength = this.curve.pLength - var buffer +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); - // 0x02/0x03 | X - if (compressed) { - buffer = Buffer.allocUnsafe(1 + byteLength) - buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - // 0x04 | X | Y - } else { - buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) - buffer.writeUInt8(0x04, 0) + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; - y.toBuffer(byteLength).copy(buffer, 1 + byteLength) - } +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - x.toBuffer(byteLength).copy(buffer, 1) + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); - return buffer -} + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; -Point.decodeFrom = function (curve, buffer) { - var type = buffer.readUInt8(0) - var compressed = (type !== 4) + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); - var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) - var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; - var Q - if (compressed) { - assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') - assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; - var isOdd = (type === 0x03) - Q = curve.pointFromX(isOdd, x) - } else { - assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } - var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) - Q = Point.fromAffine(curve, x, y) + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); } - Q.compressed = compressed - return Q -} + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; -Point.prototype.toString = function () { - if (this.curve.isInfinity(this)) return '(INFINITY)' +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; - return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' -} + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); -module.exports = Point + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); -},{"assert":24,"bigi":34,"safe-buffer":322}],221:[function(require,module,exports){ -'use strict'; + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; -var elliptic = exports; +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); -elliptic.version = require('../package.json').version; -elliptic.utils = require('./elliptic/utils'); -elliptic.rand = require('brorand'); -elliptic.curve = require('./elliptic/curve'); -elliptic.curves = require('./elliptic/curves'); + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); -},{"../package.json":236,"./elliptic/curve":224,"./elliptic/curves":227,"./elliptic/ec":228,"./elliptic/eddsa":231,"./elliptic/utils":235,"brorand":103}],222:[function(require,module,exports){ -'use strict'; + return this.point(x, y); +}; -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); + var x = point.x; + var y = point.y; - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + +function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; } } -module.exports = BaseCurve; +inherits(Point, Base.BasePoint); -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); }; -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); }; -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; - var naf = getNAF(k, 1); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; - // Translate into more windowed form - var repr = []; - for (var j = 0; j < naf.length; j += doubles.step) { - var nafW = 0; - for (var k = j + doubles.step - 1; k >= j; k--) - nafW = (nafW << 1) + naf[k]; - repr.push(nafW); + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul), + }, + }; } + return beta; +}; - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (var j = 0; j < repr.length; j++) { - var nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1), + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1), + }, + } ]; }; -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } - // Get NAF form - var naf = getNAF(k, w); + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), + }, + }; + return res; +}; - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var k = 0; i >= 0 && naf[i] === 0; i--) - k++; - if (i >= 0) - k++; - acc = acc.dblp(k); +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; +Point.prototype.isInfinity = function isInfinity() { + return this.inf; }; -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; - // Fill all arrays - var max = 0; - for (var i = 0; i < len; i++) { - var p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } + // P + O = P + if (p.inf) + return this; - // Comb small window NAFs - for (var i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a]); - naf[b] = getNAF(coeffs[b], wndWidth[b]); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } + // P + P = 2P + if (this.eq(p)) + return this.dbl(); - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b] /* 7 */ - ]; + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3 /* 1 1 */ - ]; + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (var j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (var i = max; i >= 0; i--) { - var k = 0; + var a = this.curve.a; - while (i >= 0) { - var zero = true; - for (var j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - for (var j = 0; j < len; j++) { - var z = tmp[j]; - var p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (var i = 0; i < len; i++) - wnd[i] = null; +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; - if (jacobianResult) - return acc; +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); else - return acc.toP(); + return this.curve._wnafMul(this, k); }; -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; -} -BaseCurve.BasePoint = BasePoint; +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); }; -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); }; -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; - var len = this.p.byteLength(); + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate), + }, + }; + } + return res; +}; - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); +function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); } - throw new Error('Unknown point format'); -}; + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); + +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); }; -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); - return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; + return this.curve.point(ax, ay); }; -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); }; -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) return this; - var precomputed = { - doubles: null, - naf: null, - beta: null - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); - return this; -}; + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); + return this.curve.jpoint(nx, ny, nz); }; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); } - return { - step: step, - points: doubles - }; -}; -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res - }; -}; + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); -BasePoint.prototype._getBeta = function _getBeta() { - return null; + return this.curve.jpoint(nx, ny, nz); }; -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); -},{"../../elliptic":221,"bn.js":90}],223:[function(require,module,exports){ -'use strict'; + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; + } -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; -var assert = elliptic.utils.assert; + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); -function EdwardsCurve(conf) { - // NOTE: Important as we are creating point in Base.call() - this.twisted = (conf.a | 0) !== 1; - this.mOneA = this.twisted && (conf.a | 0) === -1; - this.extended = this.mOneA; + // Reuse results + var jyd = jy.redAdd(jy); + for (i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - Base.call(this, 'edwards', conf); + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); - this.a = new BN(conf.a, 16).umod(this.red.m); - this.a = this.a.toRed(this.red); - this.c = new BN(conf.c, 16).toRed(this.red); - this.c2 = this.c.redSqr(); - this.d = new BN(conf.d, 16).toRed(this.red); - this.dd = this.d.redAdd(this.d); + jx = nx; + jz = nz; + jyd = dny; + } - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); else - return this.a.redMul(num); + return this._dbl(); }; -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); }; -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var x2 = x.redSqr(); - var rhs = this.c2.redSub(this.a.redMul(x2)); - var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); - - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); -}; +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); - // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) - var y2 = y.redSqr(); - var lhs = y2.redSub(this.c2); - var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); - var x2 = lhs.redMul(rhs.redInvm()); + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); - return this.point(x, y); + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; - - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); - - var x2 = point.x.redSqr(); - var y2 = point.y.redSqr(); - var lhs = x2.redMul(this.a).redAdd(y2); - var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - - return lhs.cmp(rhs) === 0; -}; +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); -function Point(curve, x, y, z, t) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && y === null && z === null) { - this.x = this.curve.zero; - this.y = this.curve.one; - this.z = this.curve.one; - this.t = this.curve.zero; - this.zOne = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = z ? new BN(z, 16) : this.curve.one; - this.t = t && new BN(t, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - if (this.t && !this.t.red) - this.t = this.t.toRed(this.curve.red); - this.zOne = this.z === this.curve.one; + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... - // Use extended coordinates - if (this.curve.extended && !this.t) { - this.t = this.x.redMul(this.y); - if (!this.zOne) - this.t = this.t.redMul(this.z.redInvm()); - } - } -} -inherits(Point, Base.BasePoint); + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); + return this.curve.jpoint(nx, ny, nz); }; -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); -}; +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); + return this.curve._wnafMul(this, k); }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.x.cmpn(0) === 0 && - (this.y.cmp(this.z) === 0 || - (this.zOne && this.y.cmp(this.curve.c) === 0)); -}; + if (this === p) + return true; -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = 2 * Z1^2 - var c = this.z.redSqr(); - c = c.redIAdd(c); - // D = a * A - var d = this.curve._mulA(a); - // E = (X1 + Y1)^2 - A - B - var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); - // G = D + B - var g = d.redAdd(b); - // F = G - C - var f = g.redSub(c); - // H = D - B - var h = d.redSub(b); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; }; -Point.prototype._projDbl = function _projDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #doubling-dbl-2008-bbjlp - // #doubling-dbl-2007-bl - // and others - // Generally 3M + 4S or 2M + 4S +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; - // B = (X1 + Y1)^2 - var b = this.x.redAdd(this.y).redSqr(); - // C = X1^2 - var c = this.x.redSqr(); - // D = Y1^2 - var d = this.y.redSqr(); + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; - var nx; - var ny; - var nz; - if (this.curve.twisted) { - // E = a * C - var e = this.curve._mulA(c); - // F = E + D - var f = e.redAdd(d); - if (this.zOne) { - // X3 = (B - C - D) * (F - 2) - nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F^2 - 2 * F - nz = f.redSqr().redSub(f).redSub(f); - } else { - // H = Z1^2 - var h = this.z.redSqr(); - // J = F - 2 * H - var j = f.redSub(h).redISub(h); - // X3 = (B-C-D)*J - nx = b.redSub(c).redISub(d).redMul(j); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F * J - nz = f.redMul(j); - } - } else { - // E = C + D - var e = c.redAdd(d); - // H = (c * Z1)^2 - var h = this.curve._mulC(this.z).redSqr(); - // J = E - 2 * H - var j = e.redSub(h).redSub(h); - // X3 = c * (B - E) * J - nx = this.curve._mulC(b.redISub(e)).redMul(j); - // Y3 = c * E * (C - D) - ny = this.curve._mulC(e).redMul(c.redISub(d)); - // Z3 = E * J - nz = e.redMul(j); + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; } - return this.curve.point(nx, ny, nz); }; -Point.prototype.dbl = function dbl() { +JPoint.prototype.inspect = function inspect() { if (this.isInfinity()) - return this; - - // Double in extended coordinates - if (this.curve.extended) - return this._extDbl(); - else - return this._projDbl(); + return ''; + return ''; }; -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M - - // A = (Y1 - X1) * (Y2 - X2) - var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); - // B = (Y1 + X1) * (Y2 + X2) - var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); - // C = T1 * k * T2 - var c = this.t.redMul(this.curve.dd).redMul(p.t); - // D = Z1 * 2 * Z2 - var d = this.z.redMul(p.z.redAdd(p.z)); - // E = B - A - var e = b.redSub(a); - // F = D - C - var f = d.redSub(c); - // G = D + C - var g = d.redAdd(c); - // H = B + A - var h = b.redAdd(a); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; }; -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S +},{"../utils":236,"./base":223,"bn.js":90,"inherits":279}],228:[function(require,module,exports){ +'use strict'; - // A = Z1 * Z2 - var a = this.z.redMul(p.z); - // B = A^2 - var b = a.redSqr(); - // C = X1 * X2 - var c = this.x.redMul(p.x); - // D = Y1 * Y2 - var d = this.y.redMul(p.y); - // E = d * C * D - var e = this.curve.d.redMul(c).redMul(d); - // F = B - E - var f = b.redSub(e); - // G = B + E - var g = b.redAdd(e); - // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) - var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); - var nx = a.redMul(f).redMul(tmp); - var ny; - var nz; - if (this.curve.twisted) { - // Y3 = A * G * (D - a * C) - ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); - // Z3 = F * G - nz = f.redMul(g); - } else { - // Y3 = A * G * (D - C) - ny = a.redMul(g).redMul(d.redSub(c)); - // Z3 = c * F * G - nz = this.curve._mulC(f).redMul(g); - } - return this.curve.point(nx, ny, nz); -}; +var curves = exports; -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; +var assert = utils.assert; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve.short(options); + else if (options.type === 'edwards') + this.curve = new curve.edwards(options); else - return this.curve._wnafMul(this, k); -}; - -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; - -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; - // Normalize coordinates - var zi = this.z.redInvm(); - this.x = this.x.redMul(zi); - this.y = this.y.redMul(zi); - if (this.t) - this.t = this.t.redMul(zi); - this.z = this.curve.one; - this.zOne = true; - return this; -}; +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve, + }); + return curve; + }, + }); +} -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; +defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811', + ], +}); -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; +defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34', + ], +}); -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; +defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5', + ], +}); -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; -}; +defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f', + ], +}); -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; +defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650', + ], +}); - var xc = x.clone(); - var t = this.curve.redN.redMul(this.z); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; +defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '9', + ], +}); - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } -}; +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],224:[function(require,module,exports){ -'use strict'; +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} -var curve = exports; +defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash.sha256, -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -},{"./base":222,"./edwards":223,"./mont":225,"./short":226}],225:[function(require,module,exports){ +},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(require,module,exports){ 'use strict'; -var curve = require('../curve'); var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; - -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; - -function MontCurve(conf) { - Base.call(this, 'mont', conf); +var HmacDRBG = require('hmac-drbg'); +var utils = require('../utils'); +var curves = require('../curves'); +var rand = require('brorand'); +var assert = utils.assert; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.i4 = new BN(4).toRed(this.red).redInvm(); - this.two = new BN(2).toRed(this.red); - this.a24 = this.i4.redMul(this.a.redAdd(this.two)); -} -inherits(MontCurve, Base); -module.exports = MontCurve; +var KeyPair = require('./key'); +var Signature = require('./signature'); -MontCurve.prototype.validate = function validate(point) { - var x = point.normalize().x; - var x2 = x.redSqr(); - var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); - var y = rhs.redSqrt(); +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); - return y.redSqr().cmp(rhs) === 0; -}; + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); -function Point(curve, x, z) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && z === null) { - this.x = this.curve.one; - this.z = this.curve.zero; - } else { - this.x = new BN(x, 16); - this.z = new BN(z, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); + options = curves[options]; } -} -inherits(Point, Base.BasePoint); - -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; - -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; - -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; -Point.prototype.precompute = function precompute() { - // No-op -}; + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); -}; + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); }; -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A - - // A = X1 + Z1 - var a = this.x.redAdd(this.z); - // AA = A^2 - var aa = a.redSqr(); - // B = X1 - Z1 - var b = this.x.redSub(this.z); - // BB = B^2 - var bb = b.redSqr(); - // C = AA - BB - var c = aa.redSub(bb); - // X3 = AA * BB - var nx = aa.redMul(bb); - // Z3 = C * (BB + A24 * C) - var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); - return this.curve.point(nx, nz); +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); }; -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); }; -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A - - // A = X2 + Z2 - var a = this.x.redAdd(this.z); - // B = X2 - Z2 - var b = this.x.redSub(this.z); - // C = X3 + Z3 - var c = p.x.redAdd(p.z); - // D = X3 - Z3 - var d = p.x.redSub(p.z); - // DA = D * A - var da = d.redMul(a); - // CB = C * B - var cb = c.redMul(b); - // X5 = Z1 * (DA + CB)^2 - var nx = diff.z.redMul(da.redAdd(cb).redSqr()); - // Z5 = X1 * (DA - CB)^2 - var nz = diff.x.redMul(da.redISub(cb).redSqr()); - return this.curve.point(nx, nz); -}; +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; -Point.prototype.mul = function mul(k) { - var t = k.clone(); - var a = this; // (N / 2) * Q + Q - var b = this.curve.point(null, null); // (N / 2) * Q - var c = this; // Q + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray(), + }); - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (;;) { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; - for (var i = bits.length - 1; i >= 0; i--) { - if (bits[i] === 0) { - // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q - a = a.diffAdd(b, c); - // N * Q = 2 * ((N / 2) * Q + Q)) - b = b.dbl(); - } else { - // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) - b = a.diffAdd(b, c); - // N * Q + Q = 2 * ((N / 2) * Q + Q) - a = a.dbl(); - } + priv.iaddn(1); + return this.keyFromPrivate(priv); } - return b; -}; - -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); }; -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; - -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; +EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; }; -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; -}; +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); - return this.x.fromRed(); -}; + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],226:[function(require,module,exports){ -'use strict'; + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); -var assert = elliptic.utils.assert; + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); -function ShortCurve(conf) { - Base.call(this, 'short', conf); + for (var iter = 0; ; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); -} -inherits(ShortCurve, Base); -module.exports = ShortCurve; + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; } - } - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16) - }; - }); - } else { - basis = this._getEndoBasis(lambda); + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } - - return { - beta: beta, - lambda: lambda, - basis: basis - }; -}; - -ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); - - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; }; -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); - - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; - - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); - - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; - - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; +EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + var p; - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 } - ]; -}; + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; + return p.getX().umod(this.n).cmp(r) === 0; + } - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); }; -ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; - return this.point(x, y); -}; + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); -ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); - var x = point.x; - var y = point.y; + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); }; -ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; + if (Qprime.eq(Q)) + return i; } - return res; + throw new Error('Unable to find valid recovery factor'); }; -function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } -} -inherits(Point, Base.BasePoint); +},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,"brorand":103,"hmac-drbg":277}],230:[function(require,module,exports){ +'use strict'; -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); -}; +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); -}; +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; -Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +module.exports = KeyPair; - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul) - } - }; - } - return beta; + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - } ]; + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); }; -Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)) - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)) - } - }; - return res; + return { result: true, reason: null }; }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - // P + O = P - if (p.inf) - return this; + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; - // P + P = 2P - if (this.eq(p)) - return this.dbl(); +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); }; -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); +},{"../utils":236,"bn.js":90}],231:[function(require,module,exports){ +'use strict'; - var a = this.curve.a; +var BN = require('bn.js'); - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); +var utils = require('../utils'); +var assert = utils.assert; - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; +function Signature(options, enc) { + if (options instanceof Signature) + return options; -Point.prototype.getX = function getX() { - return this.x.fromRed(); -}; + if (this._importDER(options, enc)) + return; -Point.prototype.getY = function getY() { - return this.y.fromRed(); -}; + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +module.exports = Signature; -Point.prototype.mul = function mul(k) { - k = new BN(k, 16); +function Position() { + this.place = 0; +} - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); -}; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; -Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); -}; + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } -Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); -}; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } -Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); -}; + // Leading zeroes + if (val <= 0x7f) { + return false; + } -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; + p.place = off; + return val; +} - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate) - } - }; +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; } - return res; -}; + if (i === 0) { + return buf; + } + return buf.slice(i); +} -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if (len === false) { + return false; + } + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + if (rlen === false) { + return false; + } + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (slen === false) { + return false; + } + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0) { + if (r[1] & 0x80) { + r = r.slice(1); + } else { + // Leading zeroes + return false; + } + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; }; -function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); } -inherits(JPoint, Base.BasePoint); -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); -}; +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); + r = rmPadding(r); + s = rmPadding(s); - return this.curve.point(ax, ay); + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); }; -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; +},{"../utils":236,"bn.js":90}],232:[function(require,module,exports){ +'use strict'; -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; +var hash = require('hash.js'); +var curves = require('../curves'); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var KeyPair = require('./key'); +var Signature = require('./signature'); - // P + O = P - if (p.isInfinity()) - return this; +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); +module.exports = EDDSA; - return this.curve.jpoint(nx, ny, nz); +/** +* @param {Array|String} message - message bytes +* @param {Array|String|KeyPair} secret - secret bytes or a keypair +* @returns {Signature} - signature +*/ +EDDSA.prototype.sign = function sign(message, secret) { + message = parseBytes(message); + var key = this.keyFromSecret(secret); + var r = this.hashInt(key.messagePrefix(), message); + var R = this.g.mul(r); + var Rencoded = this.encodePoint(R); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message) + .mul(key.priv()); + var S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); - - // P + O = P - if (p.isInfinity()) - return this; - - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } +/** +* @param {Array} message - message bytes +* @param {Array|String|Signature} sig - sig bytes +* @param {Array|String|Point|KeyPair} pub - public key +* @returns {Boolean} - true if public key matches sig of message +*/ +EDDSA.prototype.verify = function verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); +}; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +EDDSA.prototype.hashInt = function hashInt() { + var hash = this.hash(); + for (var i = 0; i < arguments.length; i++) + hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); +}; - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - return this.curve.jpoint(nx, ny, nz); +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); }; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (var i = 0; i < pow; i++) - r = r.dbl(); - return r; - } +/** +* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 +* +* EDDSA defines methods for encoding and decoding points and integers. These are +* helper convenience methods, that pass along to utility functions implied +* parameters. +* +*/ +EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray('le', this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; +}; - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - // Reuse results - var jyd = jy.redAdd(jy); - for (var i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); +}; - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - jx = nx; - jz = nz; - jyd = dny; - } +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +},{"../curves":228,"../utils":236,"./key":233,"./signature":234,"hash.js":265}],233:[function(require,module,exports){ +'use strict'; - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; + +/** +* @param {EDDSA} eddsa - instance +* @param {Object} params - public/private key parameters +* +* @param {Array} [params.secret] - secret seed bytes +* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) +* @param {Array} [params.pub] - public key point encoded as bytes +* +*/ +function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; else - return this._dbl(); + this._pubBytes = parseBytes(params.pub); +} + +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); }; -JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); +KeyPair.prototype.secret = function secret() { + return this._secret; +}; - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } + return a; +}); - return this.curve.jpoint(nx, ny, nz); -}; +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); -JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; - return this.curve.jpoint(nx, ny, nz); +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); }; -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); +}; - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); +module.exports = KeyPair; - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); +},{"../utils":236}],234:[function(require,module,exports){ +'use strict'; - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); +/** +* @param {EDDSA} eddsa - eddsa instance +* @param {Array|Object} sig - +* @param {Array|Point} [sig.R] - R point as Point or bytes +* @param {Array|bn} [sig.S] - S scalar as bn or bytes +* @param {Array} [sig.Rencoded] - R point encoded +* @param {Array} [sig.Sencoded] - S scalar encoded +*/ +function Signature(eddsa, sig) { + this.eddsa = eddsa; - return this.curve.jpoint(nx, ny, nz); -}; + if (typeof sig !== 'object') + sig = parseBytes(sig); -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... + assert(sig.R && sig.S, 'Signature without R or S'); - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - return this.curve.jpoint(nx, ny, nz); + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} + +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); + +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); + +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); + +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); + +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); }; -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; - return this.curve._wnafMul(this, k); +module.exports = Signature; + +},{"../utils":236,"bn.js":90}],235:[function(require,module,exports){ +module.exports = { + doubles: { + step: 4, + points: [ + [ + 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', + 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', + ], + [ + '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', + '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', + ], + [ + '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', + 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', + ], + [ + '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', + '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', + ], + [ + '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', + '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', + ], + [ + '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', + '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', + ], + [ + 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', + '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', + ], + [ + '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', + 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', + ], + [ + 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', + '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', + ], + [ + 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', + 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', + ], + [ + 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', + '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', + ], + [ + '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', + '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', + ], + [ + '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', + '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', + ], + [ + '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', + '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', + ], + [ + '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', + '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', + ], + [ + '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', + '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', + ], + [ + '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', + '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', + ], + [ + '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', + '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', + ], + [ + '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', + 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', + ], + [ + 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', + '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', + ], + [ + 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', + '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', + ], + [ + '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', + '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', + ], + [ + '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', + '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', + ], + [ + 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', + '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', + ], + [ + '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', + 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', + ], + [ + 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', + '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', + ], + [ + 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', + 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', + ], + [ + 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', + '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', + ], + [ + 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', + 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', + ], + [ + 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', + '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', + ], + [ + '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', + 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', + ], + [ + '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', + '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', + ], + [ + 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', + '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', + ], + [ + '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', + 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', + ], + [ + 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', + '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', + ], + [ + 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', + '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', + ], + [ + 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', + 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', + ], + [ + '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', + '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', + ], + [ + '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', + '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', + ], + [ + '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', + 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', + ], + [ + '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', + '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', + ], + [ + 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', + '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', + ], + [ + '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', + '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', + ], + [ + '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', + 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', + ], + [ + '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', + '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', + ], + [ + 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', + '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', + ], + [ + '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', + 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', + ], + [ + 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', + 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', + ], + [ + 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', + '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', + ], + [ + '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', + 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', + ], + [ + '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', + 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', + ], + [ + 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', + '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', + ], + [ + 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', + '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', + ], + [ + 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', + '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', + ], + [ + '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', + 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', + ], + [ + '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', + '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', + ], + [ + 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', + 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', + ], + [ + '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', + 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', + ], + [ + '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', + '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', + ], + [ + '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', + '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', + ], + [ + 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', + 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', + ], + [ + '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', + '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', + ], + [ + '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', + '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', + ], + [ + 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', + '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', + ], + [ + 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', + 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', + ], + ], + }, + naf: { + wnd: 7, + points: [ + [ + 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', + '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', + ], + [ + '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', + 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', + ], + [ + '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', + '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', + ], + [ + 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', + 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', + ], + [ + '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', + 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', + ], + [ + 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', + 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', + ], + [ + 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', + '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', + ], + [ + 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', + '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', + ], + [ + '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', + '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', + ], + [ + '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', + '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', + ], + [ + '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', + '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', + ], + [ + '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', + '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', + ], + [ + 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', + 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', + ], + [ + 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', + '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', + ], + [ + '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', + 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', + ], + [ + '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', + 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', + ], + [ + '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', + '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', + ], + [ + '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', + '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', + ], + [ + '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', + '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', + ], + [ + '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', + 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', + ], + [ + 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', + 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', + ], + [ + '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', + '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', + ], + [ + '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', + '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', + ], + [ + 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', + 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', + ], + [ + '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', + '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', + ], + [ + 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', + 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', + ], + [ + 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', + 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', + ], + [ + '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', + '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', + ], + [ + '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', + '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', + ], + [ + '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', + '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', + ], + [ + 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', + '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', + ], + [ + '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', + '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', + ], + [ + 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', + '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', + ], + [ + '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', + 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', + ], + [ + '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', + 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', + ], + [ + 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', + 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', + ], + [ + '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', + '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', + ], + [ + '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', + 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', + ], + [ + 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', + 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', + ], + [ + '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', + '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', + ], + [ + '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', + 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', + ], + [ + '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', + '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', + ], + [ + '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', + 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', + ], + [ + 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', + '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', + ], + [ + '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', + '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', + ], + [ + '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', + 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', + ], + [ + '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', + 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', + ], + [ + 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', + 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', + ], + [ + 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', + 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', + ], + [ + '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', + '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', + ], + [ + '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', + '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', + ], + [ + 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', + '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', + ], + [ + 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', + 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', + ], + [ + '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', + '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', + ], + [ + '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', + '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', + ], + [ + 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', + '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', + ], + [ + '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', + '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', + ], + [ + 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', + 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', + ], + [ + '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', + 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', + ], + [ + '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', + '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', + ], + [ + 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', + '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', + ], + [ + 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', + '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', + ], + [ + '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', + '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', + ], + [ + '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', + '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', + ], + [ + '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', + 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', + ], + [ + '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', + 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', + ], + [ + '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', + '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', + ], + [ + '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', + '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', + ], + [ + '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', + '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', + ], + [ + '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', + 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', + ], + [ + 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', + 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', + ], + [ + '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', + 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', + ], + [ + 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', + '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', + ], + [ + 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', + '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', + ], + [ + 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', + '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', + ], + [ + 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', + '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', + ], + [ + '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', + 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', + ], + [ + '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', + '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', + ], + [ + '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', + 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', + ], + [ + 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', + 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', + ], + [ + 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', + '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', + ], + [ + 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', + 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', + ], + [ + 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', + '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', + ], + [ + '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', + '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', + ], + [ + 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', + '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', + ], + [ + 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', + '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', + ], + [ + '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', + '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', + ], + [ + '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', + 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', + ], + [ + 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', + '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', + ], + [ + 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', + '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', + ], + [ + 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', + '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', + ], + [ + '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', + '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', + ], + [ + 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', + 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', + ], + [ + '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', + 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', + ], + [ + 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', + 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', + ], + [ + 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', + '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', + ], + [ + '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', + 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', + ], + [ + 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', + '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', + ], + [ + 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', + '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', + ], + [ + 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', + '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', + ], + [ + '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', + 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', + ], + [ + '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', + 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', + ], + [ + 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', + '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', + ], + [ + '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', + 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', + ], + [ + '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', + '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', + ], + [ + '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', + 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', + ], + [ + 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', + 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', + ], + [ + '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', + 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', + ], + [ + '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', + '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', + ], + [ + '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', + 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', + ], + [ + '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', + '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', + ], + [ + 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', + 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', + ], + [ + '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', + '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', + ], + [ + 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', + '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', + ], + [ + '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', + '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', + ], + [ + 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', + 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', + ], + [ + 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', + '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', + ], + [ + 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', + 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', + ], + [ + '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', + 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', + ], + [ + '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', + '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', + ], + [ + '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', + 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', + ], + [ + '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', + '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', + ], + [ + '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', + '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', + ], + [ + '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', + 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', + ], + [ + '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', + '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', + ], + [ + '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', + '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', + ], + [ + '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', + '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', + ], + ], + }, }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); +},{}],236:[function(require,module,exports){ +'use strict'; - if (this === p) - return true; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; -}; +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); -JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; + var ws = 1 << (w + 1); + var k = num.clone(); - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; + for (var i = 0; i < naf.length; i++) { + var z; + var mod = k.andln(ws - 1); + if (k.isOdd()) { + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; + naf[i] = z; + k.iushrn(1); } -}; - -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; -},{"../../elliptic":221,"../curve":224,"bn.js":90,"inherits":259}],227:[function(require,module,exports){ -'use strict'; + return naf; +} +utils.getNAF = getNAF; -var curves = exports; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; -var hash = require('hash.js'); -var elliptic = require('../elliptic'); + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); -var assert = elliptic.utils.assert; + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); -function PresetCurve(options) { - if (options.type === 'short') - this.curve = new elliptic.curve.short(options); - else if (options.type === 'edwards') - this.curve = new elliptic.curve.edwards(options); - else - this.curve = new elliptic.curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); + return jsf; } -curves.PresetCurve = PresetCurve; +utils.getJSF = getJSF; -function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve - }); - return curve; - } - }); +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; } +utils.cachedProperty = cachedProperty; -defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' - ] -}); - -defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' - ] -}); - -defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' - ] -}); - -defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' - ] -}); - -defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650' - ] -}); - -defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '1', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9' - ] -}); - -defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658' - ] -}); +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); } +utils.intFromLE = intFromLE; -defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3' - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15' - } +},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "elliptic@6.5.4", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] ], + "_from": "elliptic@6.5.4", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.5.4", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.5.4", + "saveSpec": null, + "fetchSpec": "6.5.4" + }, + "_requiredBy": [ + "/create-ecdh", + "/crypto-browserify/browserify-sign", + "/secp256k1" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_spec": "6.5.4", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" + ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" +} - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre - ] -}); - -},{"../elliptic":221,"./precomputed/secp256k1":234,"hash.js":244}],228:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var HmacDRBG = require('hmac-drbg'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -var KeyPair = require('./key'); -var Signature = require('./signature'); +},{}],238:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var MD5 = require('md5.js') -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); +/* eslint-disable camelcase */ +function EVP_BytesToKey (password, salt, keyBits, ivLen) { + if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') + if (salt) { + if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') + if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + } - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); + var keyLen = keyBits / 8 + var key = Buffer.alloc(keyLen) + var iv = Buffer.alloc(ivLen || 0) + var tmp = Buffer.alloc(0) - options = elliptic.curves[options]; - } + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5() + hash.update(tmp) + hash.update(password) + if (salt) hash.update(salt) + tmp = hash.digest() - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof elliptic.curves.PresetCurve) - options = { curve: options }; + var used = 0 - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; + if (keyLen > 0) { + var keyStart = key.length - keyLen + used = Math.min(keyLen, tmp.length) + tmp.copy(key, keyStart, 0, used) + keyLen -= used + } - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen + var length = Math.min(ivLen, tmp.length - used) + tmp.copy(iv, ivStart, used, used + length) + ivLen -= length + } + } - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; + tmp.fill(0) + return { key: key, iv: iv } } -module.exports = EC; -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; +module.exports = EVP_BytesToKey -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); -}; +},{"md5.js":283,"safe-buffer":345}],239:[function(require,module,exports){ -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); -}; +},{}],240:[function(require,module,exports){ +arguments[4][239][0].apply(exports,arguments) +},{"dup":239}],241:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), - entropyEnc: options.entropy && options.entropyEnc || 'utf8', - nonce: this.n.toArray() - }); +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - do { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; - priv.iaddn(1); - return this.keyFromPrivate(priv); - } while (true); -}; +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; -EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; }; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); + if (!this._events) + this._events = {}; - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + handler = this._events[type]; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8' - }); + if (isUndefined(handler)) + return false; - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } - for (var iter = 0; true; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; + return true; +}; - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; +EventEmitter.prototype.addListener = function(type, listener) { + var m; - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; + if (!this._events) + this._events = {}; - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; } - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } } + + return this; }; -EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); +EventEmitter.prototype.on = EventEmitter.prototype.addListener; - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); + var fired = false; - if (!this.curve._maxwellTrick) { - var p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + function g() { + this.removeListener(type, g); - return p.getX().umod(this.n).cmp(r) === 0; + if (!fired) { + fired = true; + listener.apply(this, arguments); + } } - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - var p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + g.listener = listener; + this.on(type, g); - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); + return this; }; -EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); + if (!this._events || !this._events[type]) + return this; - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); + list = this._events[type]; + length = list.length; + position = -1; - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; + if (position < 0) + return this; - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); } - if (Qprime.eq(Q)) - return i; + if (this._events.removeListener) + this.emit('removeListener', type, listener); } - throw new Error('Unable to find valid recovery factor'); -}; - -},{"../../elliptic":221,"./key":229,"./signature":230,"bn.js":90,"hmac-drbg":256}],229:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); -} -module.exports = KeyPair; - -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc - }); -}; - -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - return new KeyPair(ec, { - priv: priv, - privEnc: enc - }); + return this; }; -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; + if (!this._events) + return this; - return { result: true, reason: null }; -}; + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; } - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); + listeners = this._events[type]; - if (!enc) - return this.pub; + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; - return this.pub.encode(enc, compact); + return this; }; -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; else - return this.priv; + ret = this._events[type].slice(); + return ret; }; -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); -}; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; -KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - // Montgomery points only have an `x` coordinate. - // Weierstrass/Edwards points on the other hand have both `x` and - // `y` coordinates. - if (this.ec.curve.type === 'mont') { - assert(key.x, 'Need x coordinate'); - } else if (this.ec.curve.type === 'short' || - this.ec.curve.type === 'edwards') { - assert(key.x && key.y, 'Need both x and y coordinate'); - } - this.pub = this.ec.curve.point(key.x, key.y); - return; + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; } - this.pub = this.ec.curve.decodePoint(key, enc); + return 0; }; -// ECDH -KeyPair.prototype.derive = function derive(pub) { - return pub.mul(this.priv).getX(); +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); }; -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; +function isFunction(arg) { + return typeof arg === 'function'; +} -KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); -}; +function isNumber(arg) { + return typeof arg === 'number'; +} -KeyPair.prototype.inspect = function inspect() { - return ''; -}; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} -},{"../../elliptic":221,"bn.js":90}],230:[function(require,module,exports){ -'use strict'; +function isUndefined(arg) { + return arg === void 0; +} -var BN = require('bn.js'); +},{}],242:[function(require,module,exports){ +(function (global){(function (){ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { + + /** Detect free variables */ + var freeExports = typeof exports == 'object' && exports && + !exports.nodeType && exports; + var freeModule = typeof module == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, -function Signature(options, enc) { - if (options instanceof Signature) - return options; + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - if (this._importDER(options, enc)) - return; + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; -} -module.exports = Signature; + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators -function Position() { - this.place = 0; -} + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - } - p.place = off; - return val; -} + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, -function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); -} + /** Temporary variable */ + key; -Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0 && (r[1] & 0x80)) { - r = r.slice(1); - } - if (s[0] === 0 && (s[1] & 0x80)) { - s = s.slice(1); - } + /*--------------------------------------------------------------------------*/ - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } - return true; -}; + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } -function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); -} + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } - r = rmPadding(r); - s = rmPadding(s); + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); -}; + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } -},{"../../elliptic":221,"bn.js":90}],231:[function(require,module,exports){ -'use strict'; + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } -var hash = require('hash.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var KeyPair = require('./key'); -var Signature = require('./signature'); + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. - if (!(this instanceof EDDSA)) - return new EDDSA(curve); + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } - var curve = elliptic.curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; -} + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. -module.exports = EDDSA; + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { -/** -* @param {Array|String} message - message bytes -* @param {Array|String|KeyPair} secret - secret bytes or a keypair -* @returns {Signature} - signature -*/ -EDDSA.prototype.sign = function sign(message, secret) { - message = parseBytes(message); - var key = this.keyFromSecret(secret); - var r = this.hashInt(key.messagePrefix(), message); - var R = this.g.mul(r); - var Rencoded = this.encodePoint(R); - var s_ = this.hashInt(Rencoded, key.pubBytes(), message) - .mul(key.priv()); - var S = r.add(s_).umod(this.curve.n); - return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); -}; + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { -/** -* @param {Array} message - message bytes -* @param {Array|String|Signature} sig - sig bytes -* @param {Array|String|Point|KeyPair} pub - public key -* @returns {Boolean} - true if public key matches sig of message -*/ -EDDSA.prototype.verify = function verify(message, sig, pub) { - message = parseBytes(message); - sig = this.makeSignature(sig); - var key = this.keyFromPublic(pub); - var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); - var SG = this.g.mul(sig.S()); - var RplusAh = sig.R().add(key.pub().mul(h)); - return RplusAh.eq(SG); -}; + if (index >= inputLength) { + error('invalid-input'); + } -EDDSA.prototype.hashInt = function hashInt() { - var hash = this.hash(); - for (var i = 0; i < arguments.length; i++) - hash.update(arguments[i]); - return utils.intFromLE(hash.digest()).umod(this.curve.n); -}; + digit = basicToDigit(input.charCodeAt(index++)); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; + if (digit < t) { + break; + } -/** -* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 -* -* EDDSA defines methods for encoding and decoding points and integers. These are -* helper convenience methods, that pass along to utility functions implied -* parameters. -* -*/ -EDDSA.prototype.encodePoint = function encodePoint(point) { - var enc = point.getY().toArray('le', this.encodingLength); - enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; - return enc; -}; + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); + w *= baseMinusT; - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + } - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; + n += floor(i / out); + i %= out; -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); -},{"../../elliptic":221,"./key":232,"./signature":233,"hash.js":244}],232:[function(require,module,exports){ -'use strict'; + } -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var cachedProperty = utils.cachedProperty; + return ucs2encode(output); + } -/** -* @param {EDDSA} eddsa - instance -* @param {Object} params - public/private key parameters -* -* @param {Array} [params.secret] - secret seed bytes -* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) -* @param {Array} [params.pub] - public key point encoded as bytes -* -*/ -function KeyPair(eddsa, params) { - this.eddsa = eddsa; - this._secret = parseBytes(params.secret); - if (eddsa.isPoint(params.pub)) - this._pub = params.pub; - else - this._pubBytes = parseBytes(params.pub); -} + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; + // Cache the length + inputLength = input.length; -KeyPair.prototype.secret = function secret() { - return this._secret; -}; + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + handledCPCount = basicLength = output.length; -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } - return a; -}); + // Main encoding loop: + while (handledCPCount < inputLength) { -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); + delta += (m - n) * handledCPCountPlusOne; + n = m; -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } -module.exports = KeyPair; + ++delta; + ++n; -},{"../../elliptic":221}],233:[function(require,module,exports){ -'use strict'; + } + return output.join(''); + } -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } -/** -* @param {EDDSA} eddsa - eddsa instance -* @param {Array|Object} sig - -* @param {Array|Point} [sig.R] - R point as Point or bytes -* @param {Array|bn} [sig.S] - S scalar as bn or bytes -* @param {Array} [sig.Rencoded] - R point encoded -* @param {Array} [sig.Sencoded] - S scalar encoded -*/ -function Signature(eddsa, sig) { - this.eddsa = eddsa; + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } - if (typeof sig !== 'object') - sig = parseBytes(sig); + /*--------------------------------------------------------------------------*/ - if (Array.isArray(sig)) { - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength) - }; - } + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; - assert(sig.R && sig.S, 'Signature without R or S'); + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { + // in Node.js, io.js, or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { + // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { + // in Rhino or a web browser + root.punycode = punycode; + } - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; +}(this)); - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],243:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); +},{"./lib/_stream_duplex.js":244}],244:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); +'use strict'; -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); +/**/ -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); -}; +var pna = require('process-nextick-args'); +/**/ -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; }; - -module.exports = Signature; - -},{"../../elliptic":221,"bn.js":90}],234:[function(require,module,exports){ -module.exports = { - doubles: { - step: 4, - points: [ - [ - 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', - 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821' - ], - [ - '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', - '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf' - ], - [ - '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', - 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695' - ], - [ - '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', - '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9' - ], - [ - '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', - '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36' - ], - [ - '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', - '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f' - ], - [ - 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', - '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999' - ], - [ - '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', - 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09' - ], - [ - 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', - '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d' - ], - [ - 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', - 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088' - ], - [ - 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', - '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d' - ], - [ - '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', - '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8' - ], - [ - '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', - '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a' - ], - [ - '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', - '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453' - ], - [ - '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', - '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160' - ], - [ - '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', - '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0' - ], - [ - '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', - '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6' - ], - [ - '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', - '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589' - ], - [ - '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', - 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17' - ], - [ - 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', - '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda' - ], - [ - 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', - '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd' - ], - [ - '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', - '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2' - ], - [ - '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', - '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6' - ], - [ - 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', - '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f' - ], - [ - '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', - 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01' - ], - [ - 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', - '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3' - ], - [ - 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', - 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f' - ], - [ - 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', - '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7' - ], - [ - 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', - 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78' - ], - [ - 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', - '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1' - ], - [ - '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', - 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150' - ], - [ - '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', - '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82' - ], - [ - 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', - '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc' - ], - [ - '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', - 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b' - ], - [ - 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', - '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51' - ], - [ - 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', - '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45' - ], - [ - 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', - 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120' - ], - [ - '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', - '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84' - ], - [ - '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', - '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d' - ], - [ - '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', - 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d' - ], - [ - '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', - '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8' - ], - [ - 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', - '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8' - ], - [ - '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', - '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac' - ], - [ - '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', - 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f' - ], - [ - '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', - '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962' - ], - [ - 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', - '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907' - ], - [ - '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', - 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec' - ], - [ - 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', - 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d' - ], - [ - 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', - '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414' - ], - [ - '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', - 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd' - ], - [ - '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', - 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0' - ], - [ - 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', - '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811' - ], - [ - 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', - '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1' - ], - [ - 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', - '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c' - ], - [ - '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', - 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73' - ], - [ - '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', - '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd' - ], - [ - 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', - 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405' - ], - [ - '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', - 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589' - ], - [ - '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', - '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e' - ], - [ - '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', - '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27' - ], - [ - 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', - 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1' - ], - [ - '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', - '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482' - ], - [ - '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', - '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945' - ], - [ - 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', - '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573' - ], - [ - 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', - 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82' - ] - ] +/**/ + +module.exports = Duplex; + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; }, - naf: { - wnd: 7, - points: [ - [ - 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', - '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672' - ], - [ - '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', - 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6' - ], - [ - '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', - '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da' - ], - [ - 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', - 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37' - ], - [ - '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', - 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b' - ], - [ - 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', - 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81' - ], - [ - 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', - '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58' - ], - [ - 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', - '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77' - ], - [ - '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', - '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a' - ], - [ - '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', - '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c' - ], - [ - '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', - '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67' - ], - [ - '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', - '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402' - ], - [ - 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', - 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55' - ], - [ - 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', - '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482' - ], - [ - '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', - 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82' - ], - [ - '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', - 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396' - ], - [ - '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', - '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49' - ], - [ - '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', - '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf' - ], - [ - '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', - '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a' - ], - [ - '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', - 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7' - ], - [ - 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', - 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933' - ], - [ - '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', - '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a' - ], - [ - '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', - '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6' - ], - [ - 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', - 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37' - ], - [ - '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', - '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e' - ], - [ - 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', - 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6' - ], - [ - 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', - 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476' - ], - [ - '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', - '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40' - ], - [ - '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', - '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61' - ], - [ - '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', - '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683' - ], - [ - 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', - '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5' - ], - [ - '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', - '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b' - ], - [ - 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', - '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417' - ], - [ - '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', - 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868' - ], - [ - '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', - 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a' - ], - [ - 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', - 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6' - ], - [ - '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', - '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996' - ], - [ - '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', - 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e' - ], - [ - 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', - 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d' - ], - [ - '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', - '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2' - ], - [ - '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', - 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e' - ], - [ - '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', - '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437' - ], - [ - '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', - 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311' - ], - [ - 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', - '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4' - ], - [ - '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', - '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575' - ], - [ - '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', - 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d' - ], - [ - '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', - 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d' - ], - [ - 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', - 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629' - ], - [ - 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', - 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06' - ], - [ - '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', - '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374' - ], - [ - '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', - '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee' - ], - [ - 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', - '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1' - ], - [ - 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', - 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b' - ], - [ - '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', - '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661' - ], - [ - '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', - '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6' - ], - [ - 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', - '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e' - ], - [ - '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', - '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d' - ], - [ - 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', - 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc' - ], - [ - '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', - 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4' - ], - [ - '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', - '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c' - ], - [ - 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', - '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b' - ], - [ - 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', - '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913' - ], - [ - '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', - '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154' - ], - [ - '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', - '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865' - ], - [ - '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', - 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc' - ], - [ - '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', - 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224' - ], - [ - '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', - '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e' - ], - [ - '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', - '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6' - ], - [ - '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', - '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511' - ], - [ - '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', - 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b' - ], - [ - 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', - 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2' - ], - [ - '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', - 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c' - ], - [ - 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', - '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3' - ], - [ - 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', - '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d' - ], - [ - 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', - '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700' - ], - [ - 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', - '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4' - ], - [ - '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', - 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196' - ], - [ - '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', - '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4' - ], - [ - '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', - 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257' - ], - [ - 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', - 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13' - ], - [ - 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', - '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096' - ], - [ - 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', - 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38' - ], - [ - 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', - '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f' - ], - [ - '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', - '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448' - ], - [ - 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', - '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a' - ], - [ - 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', - '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4' - ], - [ - '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', - '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437' - ], - [ - '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', - 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7' - ], - [ - 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', - '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d' - ], - [ - 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', - '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a' - ], - [ - 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', - '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54' - ], - [ - '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', - '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77' - ], - [ - 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', - 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517' - ], - [ - '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', - 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10' - ], - [ - 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', - 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125' - ], - [ - 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', - '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e' - ], - [ - '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', - 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1' - ], - [ - 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', - '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2' - ], - [ - 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', - '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423' - ], - [ - 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', - '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8' - ], - [ - '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', - 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758' - ], - [ - '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', - 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375' - ], - [ - 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', - '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d' - ], - [ - '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', - 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec' - ], - [ - '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', - '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0' - ], - [ - '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', - 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c' - ], - [ - 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', - 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4' - ], - [ - '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', - 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f' - ], - [ - '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', - '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649' - ], - [ - '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', - 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826' - ], - [ - '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', - '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5' - ], - [ - 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', - 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87' - ], - [ - '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', - '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b' - ], - [ - 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', - '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc' - ], - [ - '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', - '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c' - ], - [ - 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', - 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f' - ], - [ - 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', - '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a' - ], - [ - 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', - 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46' - ], - [ - '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', - 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f' - ], - [ - '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', - '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03' - ], - [ - '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', - 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08' - ], - [ - '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', - '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8' - ], - [ - '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', - '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373' - ], - [ - '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', - 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3' - ], - [ - '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', - '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8' - ], - [ - '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', - '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1' - ], - [ - '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', - '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9' - ] - ] + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; +},{"./_stream_readable":246,"./_stream_writable":248,"core-util-is":136,"inherits":279,"process-nextick-args":252}],245:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":247,"core-util-is":136,"inherits":279}],246:[function(require,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":244,"./internal/streams/BufferList":249,"./internal/streams/destroy":250,"./internal/streams/stream":251,"_process":291,"core-util-is":136,"events":241,"inherits":279,"isarray":281,"process-nextick-args":252,"safe-buffer":258,"string_decoder/":253,"util":239}],247:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} +},{"./_stream_duplex":244,"core-util-is":136,"inherits":279}],248:[function(require,module,exports){ +(function (process,global,setImmediate){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = require('./internal/streams/destroy'); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } + + return ret; }; -},{}],235:[function(require,module,exports){ -'use strict'; +Writable.prototype.cork = function () { + var state = this._writableState; -var utils = exports; -var BN = require('bn.js'); -var minAssert = require('minimalistic-assert'); -var minUtils = require('minimalistic-crypto-utils'); + state.corked++; +}; -utils.assert = minAssert; -utils.toArray = minUtils.toArray; -utils.zero2 = minUtils.zero2; -utils.toHex = minUtils.toHex; -utils.encode = minUtils.encode; +Writable.prototype.uncork = function () { + var state = this._writableState; -// Represent num in a w-NAF form -function getNAF(num, w) { - var naf = []; - var ws = 1 << (w + 1); - var k = num.clone(); - while (k.cmpn(1) >= 0) { - var z; - if (k.isOdd()) { - var mod = k.andln(ws - 1); - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); - } else { - z = 0; - } - naf.push(z); + if (state.corked) { + state.corked--; - // Optimization, shift by word if possible - var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; - for (var i = 1; i < shift; i++) - naf.push(0); - k.iushrn(shift); + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } +}; - return naf; -} -utils.getNAF = getNAF; +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; -// Represent k1, k2 in a Joint Sparse Form -function getJSF(k1, k2) { - var jsf = [ - [], - [] - ]; +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; - } else { - var m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; } - jsf[0].push(u1); + } + var len = state.objectMode ? 1 : chunk.length; - var u2; - if ((m24 & 1) === 0) { - u2 = 0; + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; } else { - var m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; + state.bufferedRequest = state.lastBufferedRequest; } - jsf[1].push(u2); - - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); } - return jsf; + return ret; } -utils.getJSF = getJSF; -function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); - }; +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; } -utils.cachedProperty = cachedProperty; -function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; -} -utils.parseBytes = parseBytes; +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; -function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } } -utils.intFromLE = intFromLE; - -},{"bn.js":90,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],236:[function(require,module,exports){ -module.exports={ - "_from": "elliptic@^6.2.3", - "_id": "elliptic@6.4.1", - "_inBundle": false, - "_integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", - "_location": "/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "elliptic@^6.2.3", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "^6.2.3", - "saveSpec": null, - "fetchSpec": "^6.2.3" - }, - "_requiredBy": [ - "/create-ecdh", - "/crypto-browserify/browserify-sign", - "/secp256k1" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "_shasum": "c2d0b7776911b86722c632c3c06c60f2f819939a", - "_spec": "elliptic@^6.2.3", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/secp256k1", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "bundleDependencies": false, - "dependencies": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - }, - "deprecated": false, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^1.4.3", - "coveralls": "^2.11.3", - "grunt": "^0.4.5", - "grunt-browserify": "^5.0.0", - "grunt-cli": "^1.2.0", - "grunt-contrib-connect": "^1.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-mocha-istanbul": "^3.0.1", - "grunt-saucelabs": "^8.6.2", - "istanbul": "^0.4.2", - "jscs": "^2.9.0", - "jshint": "^2.6.0", - "mocha": "^2.1.0" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "lint": "npm run jscs && npm run jshint", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.4.1" +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; } -},{}],237:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var MD5 = require('md5.js') - -/* eslint-disable camelcase */ -function EVP_BytesToKey (password, salt, keyBits, ivLen) { - if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') - if (salt) { - if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') - if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') - } - - var keyLen = keyBits / 8 - var key = Buffer.alloc(keyLen) - var iv = Buffer.alloc(ivLen || 0) - var tmp = Buffer.alloc(0) +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; - while (keyLen > 0 || ivLen > 0) { - var hash = new MD5() - hash.update(tmp) - hash.update(password) - if (salt) hash.update(salt) - tmp = hash.digest() + onwriteStateUpdate(state); - var used = 0 + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); - if (keyLen > 0) { - var keyStart = key.length - keyLen - used = Math.min(keyLen, tmp.length) - tmp.copy(key, keyStart, 0, used) - keyLen -= used + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); } - if (used < tmp.length && ivLen > 0) { - var ivStart = iv.length - ivLen - var length = Math.min(ivLen, tmp.length - used) - tmp.copy(iv, ivStart, used, used + length) - ivLen -= length + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); } } +} - tmp.fill(0) - return { key: key, iv: iv } +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); } -module.exports = EVP_BytesToKey +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} -},{"md5.js":263,"safe-buffer":322}],238:[function(require,module,exports){ -arguments[4][104][0].apply(exports,arguments) -},{"dup":104}],239:[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); }; -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; +Writable.prototype._writev = null; - if (!this._events) - this._events = {}; +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; } - handler = this._events[type]; + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); - if (isUndefined(handler)) - return false; + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); } +} - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; } +}); - return this; +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); }; +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,"_process":291,"core-util-is":136,"inherits":279,"process-nextick-args":252,"safe-buffer":258,"timers":372,"util-deprecate":381}],249:[function(require,module,exports){ +'use strict'; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); - var fired = false; +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} - function g() { - this.removeListener(type, g); +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); - if (!fired) { - fired = true; - listener.apply(this, arguments); - } + this.head = null; + this.tail = null; + this.length = 0; } - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; - if (!isFunction(listener)) - throw TypeError('listener must be a function'); + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; - if (!this._events || !this._events[type]) - return this; + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; - list = this._events[type]; - length = list.length; - position = -1; + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; } + return ret; + }; - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } + return BufferList; +}(); - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} +},{"safe-buffer":258,"util":239}],250:[function(require,module,exports){ +'use strict'; - return this; -}; +/**/ -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; +var pna = require('process-nextick-args'); +/**/ - if (!this._events) - return this; +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); } - this.removeAllListeners('removeListener'); - this._events = {}; return this; } - listeners = this._events[type]; + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); + if (this._readableState) { + this._readableState.destroyed = true; } - delete this._events[type]; - return this; -}; + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; + return this; +} - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; -function isFunction(arg) { - return typeof arg === 'function'; + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } } -function isNumber(arg) { - return typeof arg === 'number'; +function emitErrorNT(self, err) { + self.emit('error', err); } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":252}],251:[function(require,module,exports){ +module.exports = require('events').EventEmitter; + +},{"events":241}],252:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +if (typeof process === 'undefined' || + !process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process } -function isUndefined(arg) { - return arg === void 0; +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } } -},{}],240:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } +}).call(this)}).call(this,require('_process')) +},{"_process":291}],253:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, +'use strict'; - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 +/**/ - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' +var Buffer = require('safe-buffer').Buffer; +/**/ - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, +StringDecoder.prototype.end = utf8End; - /** Temporary variable */ - key; +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; - /*--------------------------------------------------------------------------*/ +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } +} - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":258}],254:[function(require,module,exports){ +module.exports = require('./readable').PassThrough - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. +},{"./readable":255}],255:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { +},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(require,module,exports){ +module.exports = require('./readable').Transform - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { +},{"./readable":255}],257:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); - if (index >= inputLength) { - error('invalid-input'); - } +},{"./lib/_stream_writable.js":248}],258:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer - digit = basicToDigit(input.charCodeAt(index++)); +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) - if (digit < t) { - break; - } +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} - w *= baseMinusT; +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} - } +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); +},{"buffer":130}],259:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } +module.exports = Stream; - n += floor(i / out); - i %= out; +var EE = require('events').EventEmitter; +var inherits = require('inherits'); - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); - } +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; - return ucs2encode(output); - } - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. - // Cache the length - inputLength = input.length; +function Stream() { + EE.call(this); +} - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; +Stream.prototype.pipe = function(dest, options) { + var source = this; - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } - handledCPCount = basicLength = output.length; + source.on('data', ondata); - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } + dest.on('drain', ondrain); - // Main encoding loop: - while (handledCPCount < inputLength) { + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } + dest.end(); + } - delta += (m - n) * handledCPCountPlusOne; - n = m; - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; + function onclose() { + if (didOnEnd) return; + didOnEnd = true; - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } + if (typeof dest.destroy === 'function') dest.destroy(); + } - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } + source.on('error', onerror); + dest.on('error', onerror); - ++delta; - ++n; + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); - } - return output.join(''); - } + source.removeListener('end', onend); + source.removeListener('close', onclose); - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } + source.removeListener('error', onerror); + dest.removeListener('error', onerror); - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); - /*--------------------------------------------------------------------------*/ + dest.removeListener('close', cleanup); + } - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; + source.on('end', cleanup); + source.on('close', cleanup); - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } + dest.on('close', cleanup); -}(this)); + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],241:[function(require,module,exports){ +},{"events":241,"inherits":279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -55115,150 +61772,16 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":322}],242:[function(require,module,exports){ -var indexOf = require('indexof'); - -var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var defineProp = (function() { - try { - Object.defineProperty({}, '_', {}); - return function(obj, name, value) { - Object.defineProperty(obj, name, { - writable: true, - enumerable: false, - configurable: true, - value: value - }) - }; - } catch(e) { - return function(obj, name, value) { - obj[name] = value; - }; - } -}()); - -var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function', -'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError', -'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError', -'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', -'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; - -function Context() {} -Context.prototype = {}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -Script.prototype.runInContext = function (context) { - if (!(context instanceof Context)) { - throw new TypeError("needs a 'context' argument."); - } - - var iframe = document.createElement('iframe'); - if (!iframe.style) iframe.style = {}; - iframe.style.display = 'none'; - - document.body.appendChild(iframe); - - var win = iframe.contentWindow; - var wEval = win.eval, wExecScript = win.execScript; - - if (!wEval && wExecScript) { - // win.eval() magically appears when this is called in IE: - wExecScript.call(win, 'null'); - wEval = win.eval; - } - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - }); - forEach(globals, function (key) { - if (context[key]) { - win[key] = context[key]; - } - }); - - var winKeys = Object_keys(win); - - var res = wEval.call(win, this.code); - - forEach(Object_keys(win), function (key) { - // Avoid copying circular objects like `top` and `window` by only - // updating existing context properties or new properties in the `win` - // that was only introduced after the eval. - if (key in context || indexOf(winKeys, key) === -1) { - context[key] = win[key]; - } - }); - - forEach(globals, function (key) { - if (!(key in context)) { - defineProp(context, key, win[key]); - } - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInNewContext = function (context) { - var ctx = Script.createContext(context); - var res = this.runInContext(ctx); - - forEach(Object_keys(ctx), function (key) { - context[key] = ctx[key]; - }); - - return res; -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - var copy = new Context(); - if(typeof context === 'object') { - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - } - return copy; -}; - -},{"indexof":258}],243:[function(require,module,exports){ +},{"safe-buffer":258}],261:[function(require,module,exports){ +arguments[4][25][0].apply(exports,arguments) +},{"dup":25}],262:[function(require,module,exports){ +arguments[4][26][0].apply(exports,arguments) +},{"dup":26}],263:[function(require,module,exports){ +arguments[4][27][0].apply(exports,arguments) +},{"./support/isBuffer":262,"_process":291,"dup":27,"inherits":261}],264:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer -var Transform = require('stream').Transform +var Transform = require('readable-stream').Transform var inherits = require('inherits') function throwIfNotStringOrBuffer (val, prefix) { @@ -55352,7 +61875,7 @@ HashBase.prototype._digest = function () { module.exports = HashBase -},{"inherits":259,"safe-buffer":322,"stream":338}],244:[function(require,module,exports){ +},{"inherits":279,"readable-stream":343,"safe-buffer":345}],265:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -55369,7 +61892,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(require,module,exports){ +},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -55463,7 +61986,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":255,"minimalistic-assert":266}],246:[function(require,module,exports){ +},{"./utils":276,"minimalistic-assert":286}],267:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -55512,7 +62035,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":255,"minimalistic-assert":266}],247:[function(require,module,exports){ +},{"./utils":276,"minimalistic-assert":286}],268:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -55660,7 +62183,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":245,"./utils":255}],248:[function(require,module,exports){ +},{"./common":266,"./utils":276}],269:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -55669,7 +62192,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":249,"./sha/224":250,"./sha/256":251,"./sha/384":252,"./sha/512":253}],249:[function(require,module,exports){ +},{"./sha/1":270,"./sha/224":271,"./sha/256":272,"./sha/384":273,"./sha/512":274}],270:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -55745,7 +62268,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":245,"../utils":255,"./common":254}],250:[function(require,module,exports){ +},{"../common":266,"../utils":276,"./common":275}],271:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -55777,7 +62300,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":255,"./256":251}],251:[function(require,module,exports){ +},{"../utils":276,"./256":272}],272:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -55884,7 +62407,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":245,"../utils":255,"./common":254,"minimalistic-assert":266}],252:[function(require,module,exports){ +},{"../common":266,"../utils":276,"./common":275,"minimalistic-assert":286}],273:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -55921,7 +62444,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":255,"./512":253}],253:[function(require,module,exports){ +},{"../utils":276,"./512":274}],274:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -56253,7 +62776,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":245,"../utils":255,"minimalistic-assert":266}],254:[function(require,module,exports){ +},{"../common":266,"../utils":276,"minimalistic-assert":286}],275:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -56304,7 +62827,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":255}],255:[function(require,module,exports){ +},{"../utils":276}],276:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -56584,7 +63107,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":259,"minimalistic-assert":266}],256:[function(require,module,exports){ +},{"inherits":279,"minimalistic-assert":286}],277:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -56699,7 +63222,8 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":244,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],257:[function(require,module,exports){ +},{"hash.js":265,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],278:[function(require,module,exports){ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -56785,20 +63309,36 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],258:[function(require,module,exports){ - -var indexOf = [].indexOf; - -module.exports = function(arr, obj){ - if (indexOf) return arr.indexOf(obj); - for (var i = 0; i < arr.length; ++i) { - if (arr[i] === obj) return i; +},{}],279:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } - return -1; -}; -},{}],259:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],260:[function(require,module,exports){ +} + +},{}],280:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -56821,19 +63361,19 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],261:[function(require,module,exports){ +},{}],281:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],262:[function(require,module,exports){ -(function (global){ +},{}],282:[function(require,module,exports){ +(function (global){(function (){ /** * @license * Lodash - * Copyright JS Foundation and other contributors + * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -56844,14 +63384,15 @@ module.exports = Array.isArray || function (arr) { var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.11'; + var VERSION = '4.17.21'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** Error message constants. */ var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', - FUNC_ERROR_TEXT = 'Expected a function'; + FUNC_ERROR_TEXT = 'Expected a function', + INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; @@ -56984,10 +63525,11 @@ module.exports = Array.isArray || function (arr) { var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g, - reTrimStart = /^\s+/, - reTrimEnd = /\s+$/; + /** Used to match leading whitespace. */ + var reTrimStart = /^\s+/; + + /** Used to match a single whitespace character. */ + var reWhitespace = /\s/; /** Used to match wrap detail comments. */ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, @@ -56997,6 +63539,18 @@ module.exports = Array.isArray || function (arr) { /** Used to match words composed of alphanumeric characters. */ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + /** + * Used to validate the `validate` option in `_.template` variable. + * + * Forbids characters which could potentially change the meaning of the function argument definition: + * - "()," (modification of function parameters) + * - "=" (default value) + * - "[]{}" (destructuring of function parameters) + * - "/" (beginning of a comment) + * - whitespace + */ + var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; + /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; @@ -57825,6 +64379,19 @@ module.exports = Array.isArray || function (arr) { }); } + /** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ + function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; + } + /** * The base implementation of `_.unary` without support for storing metadata. * @@ -58158,6 +64725,21 @@ module.exports = Array.isArray || function (arr) { : asciiToArray(string); } + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; + } + /** * Used by `_.unescape` to convert HTML entities to characters. * @@ -59503,16 +66085,10 @@ module.exports = Array.isArray || function (arr) { value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); - - return result; - } - - if (isMap(value)) { + } else if (isMap(value)) { value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); - - return result; } var keysFunc = isFull @@ -60436,8 +67012,8 @@ module.exports = Array.isArray || function (arr) { return; } baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); if (isObject(srcValue)) { - stack || (stack = new Stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { @@ -60557,8 +67133,21 @@ module.exports = Array.isArray || function (arr) { * @returns {Array} Returns the new sorted array. */ function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } + var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); var result = baseMap(collection, function(value, key, collection) { var criteria = arrayMap(iteratees, function(iteratee) { @@ -60815,6 +67404,10 @@ module.exports = Array.isArray || function (arr) { var key = toKey(path[index]), newValue = value; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + if (index != lastIndex) { var objValue = nested[key]; newValue = customizer ? customizer(objValue, key, nested) : undefined; @@ -60967,11 +67560,14 @@ module.exports = Array.isArray || function (arr) { * into `array`. */ function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, + high = array == null ? 0 : array.length; + if (high === 0) { + return 0; + } + + value = iteratee(value); + var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol(value), valIsUndefined = value === undefined; @@ -62254,7 +68850,7 @@ module.exports = Array.isArray || function (arr) { return function(number, precision) { number = toNumber(number); precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); - if (precision) { + if (precision && nativeIsFinite(number)) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. var pair = (toString(number) + 'e').split('e'), @@ -62456,10 +69052,11 @@ module.exports = Array.isArray || function (arr) { if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; } var index = -1, result = true, @@ -62621,10 +69218,11 @@ module.exports = Array.isArray || function (arr) { return false; } } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; } var result = true; stack.set(object, other); @@ -63437,7 +70035,7 @@ module.exports = Array.isArray || function (arr) { } /** - * Gets the value at `key`, unless `key` is "__proto__". + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". * * @private * @param {Object} object The object to query. @@ -63445,6 +70043,10 @@ module.exports = Array.isArray || function (arr) { * @returns {*} Returns the property value. */ function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + if (key == '__proto__') { return; } @@ -66001,6 +72603,10 @@ module.exports = Array.isArray || function (arr) { * // The `_.property` iteratee shorthand. * _.filter(users, 'active'); * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] */ function filter(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -66750,15 +73356,15 @@ module.exports = Array.isArray || function (arr) { * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, + * { 'user': 'fred', 'age': 30 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] */ var sortBy = baseRest(function(collection, iteratees) { if (collection == null) { @@ -67245,6 +73851,7 @@ module.exports = Array.isArray || function (arr) { } if (maxing) { // Handle invocations in a tight loop. + clearTimeout(timerId); timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } @@ -69301,7 +75908,7 @@ module.exports = Array.isArray || function (arr) { if (typeof value != 'string') { return value === 0 ? value : +value; } - value = value.replace(reTrim, ''); + value = baseTrim(value); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) @@ -71631,9 +78238,12 @@ module.exports = Array.isArray || function (arr) { , 'g'); // Use a sourceURL for easier debugging. + // The sourceURL gets injected into the source that's eval-ed, so be careful + // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in + // and escape the comment, thus injecting code that gets evaled. var sourceURL = '//# sourceURL=' + - ('sourceURL' in options - ? options.sourceURL + (hasOwnProperty.call(options, 'sourceURL') + ? (options.sourceURL + '').replace(/\s/g, ' ') : ('lodash.templateSources[' + (++templateCounter) + ']') ) + '\n'; @@ -71666,10 +78276,16 @@ module.exports = Array.isArray || function (arr) { // If `variable` is not specified wrap a with-statement around the generated // code to add the data object to the top of the scope chain. - var variable = options.variable; + var variable = hasOwnProperty.call(options, 'variable') && options.variable; if (!variable) { source = 'with (obj) {\n' + source + '\n}\n'; } + // Throw an error if a forbidden character was found in `variable`, to prevent + // potential command injection attacks. + else if (reForbiddenIdentifierChars.test(variable)) { + throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); + } + // Cleanup code by stripping empty strings. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) .replace(reEmptyStringMiddle, '$1') @@ -71783,7 +78399,7 @@ module.exports = Array.isArray || function (arr) { function trim(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); + return baseTrim(string); } if (!string || !(chars = baseToString(chars))) { return string; @@ -71818,7 +78434,7 @@ module.exports = Array.isArray || function (arr) { function trimEnd(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrimEnd, ''); + return string.slice(0, trimmedEndIndex(string) + 1); } if (!string || !(chars = baseToString(chars))) { return string; @@ -72372,6 +78988,9 @@ module.exports = Array.isArray || function (arr) { * values against any array or object value, respectively. See `_.isEqual` * for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.0.0 @@ -72387,6 +79006,10 @@ module.exports = Array.isArray || function (arr) { * * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); * // => [{ 'a': 4, 'b': 5, 'c': 6 }] + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matches(source) { return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); @@ -72401,6 +79024,9 @@ module.exports = Array.isArray || function (arr) { * `srcValue` values against any array or object value, respectively. See * `_.isEqual` for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.2.0 @@ -72417,6 +79043,10 @@ module.exports = Array.isArray || function (arr) { * * _.find(objects, _.matchesProperty('a', 4)); * // => { 'a': 4, 'b': 5, 'c': 6 } + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matchesProperty(path, srcValue) { return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); @@ -72640,6 +79270,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **all** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -72666,6 +79300,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **any** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -72685,6 +79323,9 @@ module.exports = Array.isArray || function (arr) { * * func(NaN); * // => false + * + * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) + * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) */ var overSome = createOver(arraySome); @@ -73871,10 +80512,11 @@ module.exports = Array.isArray || function (arr) { baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { - var key = (lodashFunc.name + ''), - names = realNames[key] || (realNames[key] = []); - - names.push({ 'name': methodName, 'func': lodashFunc }); + var key = lodashFunc.name + ''; + if (!hasOwnProperty.call(realNames, key)) { + realNames[key] = []; + } + realNames[key].push({ 'name': methodName, 'func': lodashFunc }); } }); @@ -73938,8 +80580,8 @@ module.exports = Array.isArray || function (arr) { } }.call(this)); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],263:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],283:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var HashBase = require('hash-base') @@ -74087,8 +80729,8 @@ function fnI (a, b, c, d, m, k, s) { module.exports = MD5 -},{"hash-base":243,"inherits":259,"safe-buffer":322}],264:[function(require,module,exports){ -(function (Buffer){ +},{"hash-base":264,"inherits":279,"safe-buffer":345}],284:[function(require,module,exports){ +(function (Buffer){(function (){ // constant-space merkle root calculation algorithm module.exports = function fastRoot (values, digestFn) { if (!Array.isArray(values)) throw TypeError('Expected values Array') @@ -74114,8 +80756,8 @@ module.exports = function fastRoot (values, digestFn) { return results[0] } -}).call(this,require("buffer").Buffer) -},{"buffer":131}],265:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130}],285:[function(require,module,exports){ var bn = require('bn.js'); var brorand = require('brorand'); @@ -74232,7 +80874,7 @@ MillerRabin.prototype.getDivisor = function getDivisor(n, k) { return false; }; -},{"bn.js":90,"brorand":103}],266:[function(require,module,exports){ +},{"bn.js":90,"brorand":103}],286:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -74245,7 +80887,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],267:[function(require,module,exports){ +},{}],287:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -74305,7 +80947,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],268:[function(require,module,exports){ +},{}],288:[function(require,module,exports){ /** * Helpers. */ @@ -74459,8 +81101,100 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } -},{}],269:[function(require,module,exports){ -(function (Buffer){ +},{}],289:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],290:[function(require,module,exports){ +(function (Buffer){(function (){ var createHmac = require('create-hmac') var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs @@ -74542,56 +81276,8 @@ function pbkdf2Sync (password, salt, iterations, keylen, digest) { return DK } -}).call(this,require("buffer").Buffer) -},{"buffer":131,"create-hmac":141}],270:[function(require,module,exports){ -(function (process){ -'use strict'; - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - -}).call(this,require('_process')) -},{"_process":271}],271:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":130,"create-hmac":140}],291:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -74777,7 +81463,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],272:[function(require,module,exports){ +},{}],292:[function(require,module,exports){ exports.publicEncrypt = require('./publicEncrypt') exports.privateDecrypt = require('./privateDecrypt') @@ -74789,7 +81475,7 @@ exports.publicDecrypt = function publicDecrypt (key, buf) { return exports.privateDecrypt(key, buf, true) } -},{"./privateDecrypt":294,"./publicEncrypt":295}],273:[function(require,module,exports){ +},{"./privateDecrypt":315,"./publicEncrypt":316}],293:[function(require,module,exports){ var createHash = require('create-hash') var Buffer = require('safe-buffer').Buffer @@ -74810,47 +81496,49 @@ function i2ops (c) { return out } -},{"create-hash":139,"safe-buffer":322}],274:[function(require,module,exports){ +},{"create-hash":138,"safe-buffer":345}],294:[function(require,module,exports){ +arguments[4][143][0].apply(exports,arguments) +},{"./asn1/api":295,"./asn1/base":297,"./asn1/constants":301,"./asn1/decoders":303,"./asn1/encoders":306,"bn.js":90,"dup":143}],295:[function(require,module,exports){ arguments[4][144][0].apply(exports,arguments) -},{"./asn1/api":275,"./asn1/base":277,"./asn1/constants":281,"./asn1/decoders":283,"./asn1/encoders":286,"bn.js":90,"dup":144}],275:[function(require,module,exports){ +},{"./decoders":303,"./encoders":306,"dup":144,"inherits":279}],296:[function(require,module,exports){ arguments[4][145][0].apply(exports,arguments) -},{"../asn1":274,"dup":145,"inherits":259,"vm":242}],276:[function(require,module,exports){ +},{"../base/reporter":299,"dup":145,"inherits":279,"safer-buffer":346}],297:[function(require,module,exports){ arguments[4][146][0].apply(exports,arguments) -},{"../base":277,"buffer":131,"dup":146,"inherits":259}],277:[function(require,module,exports){ +},{"./buffer":296,"./node":298,"./reporter":299,"dup":146}],298:[function(require,module,exports){ arguments[4][147][0].apply(exports,arguments) -},{"./buffer":276,"./node":278,"./reporter":279,"dup":147}],278:[function(require,module,exports){ +},{"../base/buffer":296,"../base/reporter":299,"dup":147,"minimalistic-assert":286}],299:[function(require,module,exports){ arguments[4][148][0].apply(exports,arguments) -},{"../base":277,"dup":148,"minimalistic-assert":266}],279:[function(require,module,exports){ +},{"dup":148,"inherits":279}],300:[function(require,module,exports){ arguments[4][149][0].apply(exports,arguments) -},{"dup":149,"inherits":259}],280:[function(require,module,exports){ +},{"dup":149}],301:[function(require,module,exports){ arguments[4][150][0].apply(exports,arguments) -},{"../constants":281,"dup":150}],281:[function(require,module,exports){ +},{"./der":300,"dup":150}],302:[function(require,module,exports){ arguments[4][151][0].apply(exports,arguments) -},{"./der":280,"dup":151}],282:[function(require,module,exports){ +},{"../base/buffer":296,"../base/node":298,"../constants/der":300,"bn.js":90,"dup":151,"inherits":279}],303:[function(require,module,exports){ arguments[4][152][0].apply(exports,arguments) -},{"../../asn1":274,"dup":152,"inherits":259}],283:[function(require,module,exports){ +},{"./der":302,"./pem":304,"dup":152}],304:[function(require,module,exports){ arguments[4][153][0].apply(exports,arguments) -},{"./der":282,"./pem":284,"dup":153}],284:[function(require,module,exports){ +},{"./der":302,"dup":153,"inherits":279,"safer-buffer":346}],305:[function(require,module,exports){ arguments[4][154][0].apply(exports,arguments) -},{"./der":282,"buffer":131,"dup":154,"inherits":259}],285:[function(require,module,exports){ +},{"../base/node":298,"../constants/der":300,"dup":154,"inherits":279,"safer-buffer":346}],306:[function(require,module,exports){ arguments[4][155][0].apply(exports,arguments) -},{"../../asn1":274,"buffer":131,"dup":155,"inherits":259}],286:[function(require,module,exports){ +},{"./der":305,"./pem":307,"dup":155}],307:[function(require,module,exports){ arguments[4][156][0].apply(exports,arguments) -},{"./der":285,"./pem":287,"dup":156}],287:[function(require,module,exports){ -arguments[4][157][0].apply(exports,arguments) -},{"./der":285,"dup":157,"inherits":259}],288:[function(require,module,exports){ +},{"./der":305,"dup":156,"inherits":279}],308:[function(require,module,exports){ +arguments[4][159][0].apply(exports,arguments) +},{"bn.js":309,"buffer":130,"dup":159,"randombytes":327}],309:[function(require,module,exports){ arguments[4][158][0].apply(exports,arguments) -},{"bn.js":90,"buffer":131,"dup":158,"randombytes":306}],289:[function(require,module,exports){ -arguments[4][165][0].apply(exports,arguments) -},{"dup":165}],290:[function(require,module,exports){ +},{"buffer":239,"dup":158}],310:[function(require,module,exports){ arguments[4][166][0].apply(exports,arguments) -},{"./certificate":291,"asn1.js":274,"dup":166}],291:[function(require,module,exports){ +},{"dup":166}],311:[function(require,module,exports){ arguments[4][167][0].apply(exports,arguments) -},{"asn1.js":274,"dup":167}],292:[function(require,module,exports){ +},{"./certificate":312,"asn1.js":294,"dup":167}],312:[function(require,module,exports){ arguments[4][168][0].apply(exports,arguments) -},{"browserify-aes":107,"buffer":131,"dup":168,"evp_bytestokey":237}],293:[function(require,module,exports){ +},{"asn1.js":294,"dup":168}],313:[function(require,module,exports){ arguments[4][169][0].apply(exports,arguments) -},{"./aesid.json":289,"./asn1":290,"./fixProc":292,"browserify-aes":107,"buffer":131,"dup":169,"pbkdf2":269}],294:[function(require,module,exports){ +},{"browserify-aes":106,"dup":169,"evp_bytestokey":238,"safe-buffer":345}],314:[function(require,module,exports){ +arguments[4][170][0].apply(exports,arguments) +},{"./aesid.json":310,"./asn1":311,"./fixProc":313,"browserify-aes":106,"dup":170,"pbkdf2":290,"safe-buffer":345}],315:[function(require,module,exports){ var parseKeys = require('parse-asn1') var mgf = require('./mgf') var xor = require('./xor') @@ -74957,7 +81645,7 @@ function compare (a, b) { return dif } -},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"safe-buffer":322}],295:[function(require,module,exports){ +},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(require,module,exports){ var parseKeys = require('parse-asn1') var randomBytes = require('randombytes') var createHash = require('create-hash') @@ -75047,7 +81735,7 @@ function nonZero (len) { return out } -},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"randombytes":306,"safe-buffer":322}],296:[function(require,module,exports){ +},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"randombytes":327,"safe-buffer":345}],317:[function(require,module,exports){ var BN = require('bn.js') var Buffer = require('safe-buffer').Buffer @@ -75061,7 +81749,7 @@ function withPublic (paddedMsg, key) { module.exports = withPublic -},{"bn.js":90,"safe-buffer":322}],297:[function(require,module,exports){ +},{"bn.js":90,"safe-buffer":345}],318:[function(require,module,exports){ module.exports = function xor (a, b) { var len = a.length var i = -1 @@ -75071,7 +81759,7 @@ module.exports = function xor (a, b) { return a } -},{}],298:[function(require,module,exports){ +},{}],319:[function(require,module,exports){ var OPS = require('bitcoin-ops') function encodingLength (i) { @@ -75150,8 +81838,8 @@ module.exports = { decode: decode } -},{"bitcoin-ops":41}],299:[function(require,module,exports){ -(function (process,setImmediate){ +},{"bitcoin-ops":41}],320:[function(require,module,exports){ +(function (process,setImmediate){(function (){ // vim:ts=4:sts=4:sw=4: /*! * @@ -77057,8 +83745,8 @@ return Q; }); -}).call(this,require('_process'),require("timers").setImmediate) -},{"_process":271,"timers":349}],300:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),require("timers").setImmediate) +},{"_process":291,"timers":372}],321:[function(require,module,exports){ /** this contains the max string length for all qr code Versions in Binary Safe / Byte Mode each entry is in the order of error correct level @@ -77111,7 +83799,7 @@ exports.QRCapacityTable = [ ,[2953,2331,1663,1273]//40 ]; -},{}],301:[function(require,module,exports){ +},{}],322:[function(require,module,exports){ /* * copyright 2010-2012 Ryan Day * http://github.com/soldair/node-qrcode @@ -77385,7 +84073,7 @@ QRCodeDraw.prototype = { }; -},{"./qrcapacitytable.js":300,"./qrcode.js":302,"bops":91}],302:[function(require,module,exports){ +},{"./qrcapacitytable.js":321,"./qrcode.js":323,"bops":91}],323:[function(require,module,exports){ var bops = require('bops'); /** @@ -78556,7 +85244,7 @@ QRBitBuffer.prototype = { } }; -},{"bops":91}],303:[function(require,module,exports){ +},{"bops":91}],324:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -78642,7 +85330,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],304:[function(require,module,exports){ +},{}],325:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -78729,16 +85417,24 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],305:[function(require,module,exports){ +},{}],326:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":303,"./encode":304}],306:[function(require,module,exports){ -(function (process,global){ +},{"./decode":324,"./encode":325}],327:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' +// limit of Crypto.getRandomValues() +// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues +var MAX_BYTES = 65536 + +// Node supports requesting up to this number of bytes +// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48 +var MAX_UINT32 = 4294967295 + function oldBrowser () { throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') } @@ -78754,19 +85450,23 @@ if (crypto && crypto.getRandomValues) { function randomBytes (size, cb) { // phantomjs needs to throw - if (size > 65536) throw new Error('requested too many random bytes') - // in case browserify isn't using the Uint8Array version - var rawBytes = new global.Uint8Array(size) + if (size > MAX_UINT32) throw new RangeError('requested too many random bytes') + + var bytes = Buffer.allocUnsafe(size) - // This will not work in older browsers. - // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues if (size > 0) { // getRandomValues fails on IE if size == 0 - crypto.getRandomValues(rawBytes) + if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues + // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues + for (var generated = 0; generated < size; generated += MAX_BYTES) { + // buffer.slice automatically checks if the end is past the end of + // the buffer so we don't have to here + crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES)) + } + } else { + crypto.getRandomValues(bytes) + } } - // XXX: phantomjs doesn't like a buffer being passed here - var bytes = Buffer.from(rawBytes.buffer) - if (typeof cb === 'function') { return process.nextTick(function () { cb(null, bytes) @@ -78776,9 +85476,9 @@ function randomBytes (size, cb) { return bytes } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":271,"safe-buffer":322}],307:[function(require,module,exports){ -(function (process,global){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":291,"safe-buffer":345}],328:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' function oldBrowser () { @@ -78888,11 +85588,138 @@ function randomFillSync (buf, offset, size) { return actualFill(buf, offset, size) } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":271,"randombytes":306,"safe-buffer":322}],308:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":291,"randombytes":327,"safe-buffer":345}],329:[function(require,module,exports){ +'use strict'; + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + +var codes = {}; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } -},{"./lib/_stream_duplex.js":309}],309:[function(require,module,exports){ + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } + + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +module.exports.codes = codes; + +},{}],330:[function(require,module,exports){ +(function (process){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -78913,43 +85740,37 @@ module.exports = require('./lib/_stream_duplex.js'); // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from // Writable. - 'use strict'; - /**/ -var pna = require('process-nextick-args'); -/**/ - -/**/ var objectKeys = Object.keys || function (obj) { var keys = []; + for (var key in obj) { keys.push(key); - }return keys; + } + + return keys; }; /**/ -module.exports = Duplex; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +module.exports = Duplex; var Readable = require('./_stream_readable'); + var Writable = require('./_stream_writable'); -util.inherits(Duplex, Readable); +require('inherits')(Duplex, Readable); { - // avoid scope creep, the keys array can then be collected + // Allow the keys array to be GC'ed. var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { var method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; @@ -78958,18 +85779,19 @@ util.inherits(Duplex, Readable); function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); - Readable.call(this, options); Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; - - if (options && options.writable === false) this.writable = false; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - this.once('end', onend); + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } } Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { @@ -78977,20 +85799,35 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } }); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer -// the no-half-open enforcer function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); + + process.nextTick(onEndNT, this); } function onEndNT(self) { @@ -78998,33 +85835,32 @@ function onEndNT(self) { } Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined || this._writableState === undefined) { return false; } + return this._readableState.destroyed && this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (this._readableState === undefined || this._writableState === undefined) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; this._writableState.destroyed = value; } }); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - pna.nextTick(cb, err); -}; -},{"./_stream_readable":311,"./_stream_writable":313,"core-util-is":137,"inherits":259,"process-nextick-args":270}],310:[function(require,module,exports){ +}).call(this)}).call(this,require('_process')) +},{"./_stream_readable":332,"./_stream_writable":334,"_process":291,"inherits":279}],331:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -79045,35 +85881,27 @@ Duplex.prototype._destroy = function (err, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. - 'use strict'; module.exports = PassThrough; var Transform = require('./_stream_transform'); -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -util.inherits(PassThrough, Transform); +require('inherits')(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); - Transform.call(this, options); } PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":312,"core-util-is":137,"inherits":259}],311:[function(require,module,exports){ -(function (process,global){ +},{"./_stream_transform":333,"inherits":279}],332:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -79094,118 +85922,110 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Readable; - /**/ -var isArray = require('isarray'); -/**/ -/**/ var Duplex; /**/ Readable.ReadableState = ReadableState; - /**/ + var EE = require('events').EventEmitter; -var EElistenerCount = function (emitter, type) { +var EElistenerCount = function EElistenerCount(emitter, type) { return emitter.listeners(type).length; }; /**/ /**/ + + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } - -/**/ - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ + var debugUtil = require('util'); -var debug = void 0; + +var debug; + if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { - debug = function () {}; + debug = function debug() {}; } /**/ -var BufferList = require('./internal/streams/BufferList'); + +var BufferList = require('./internal/streams/buffer_list'); + var destroyImpl = require('./internal/streams/destroy'); + +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + var StringDecoder; +var createReadableStreamAsyncIterator; +var from; -util.inherits(Readable, Stream); +require('inherits')(Readable, Stream); +var errorOrDestroy = destroyImpl.errorOrDestroy; var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); - - // This is a hack to make sure that our error handler is attached before any + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any // userland ones. NEVER DO THIS. This is here only because this code needs // to continue to work with older versions of Node.js that do not include // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; } -function ReadableState(options, stream) { +function ReadableState(options, stream, isDuplex) { Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - // object stream flag. Used to make read(n) ignore n and to + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - - // the point at which it stops calling _read() to fill the buffer + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // A linked list is used to store data chunks instead of an array because the + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than // array.shift() + this.buffer = new BufferList(); this.length = 0; this.pipes = null; @@ -79213,37 +86033,36 @@ function ReadableState(options, stream) { this.flowing = null; this.ended = false; this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted // immediately, or on a later tick. We set this to true at first, because // any actions that shouldn't happen until "later" should generally also // not happen before the first read call. - this.sync = true; - // whenever we return null, then we set a flag to say + this.sync = true; // whenever we return null, then we set a flag to say // that we're awaiting a 'readable' event emission. + this.needReadable = false; this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. - // has it been destroyed - this.destroyed = false; + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') - // Crypto is kind of old and crusty. Historically, its default string + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + this.readingMore = false; this.decoder = null; this.encoding = null; + if (options.encoding) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; this.decoder = new StringDecoder(options.encoding); @@ -79253,17 +86072,16 @@ function ReadableState(options, stream) { function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy - // legacy this.readable = true; if (options) { if (typeof options.read === 'function') this._read = options.read; - if (typeof options.destroy === 'function') this._destroy = options.destroy; } @@ -79271,36 +86089,40 @@ function Readable(options) { } Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined) { return false; } + return this._readableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._readableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; } }); - Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; + Readable.prototype._destroy = function (err, cb) { - this.push(null); cb(err); -}; - -// Manually shove something into the read() buffer. +}; // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. + + Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; var skipChunkCheck; @@ -79308,10 +86130,12 @@ Readable.prototype.push = function (chunk, encoding) { if (!state.objectMode) { if (typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { chunk = Buffer.from(chunk, encoding); encoding = ''; } + skipChunkCheck = true; } } else { @@ -79319,34 +86143,40 @@ Readable.prototype.push = function (chunk, encoding) { } return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; +}; // Unshift should *always* be something directly out of read() + -// Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { return readableAddChunk(this, chunk, null, true, false); }; function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); var state = stream._readableState; + if (chunk === null) { state.reading = false; onEofChunk(stream, state); } else { var er; if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { - stream.emit('error', er); + errorOrDestroy(stream, er); } else if (state.objectMode || chunk && chunk.length > 0) { if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; } else { state.reading = false; + if (state.decoder && !encoding) { chunk = state.decoder.write(chunk); if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); @@ -79356,61 +86186,73 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { } } else if (!addToFront) { state.reading = false; + maybeReadMore(stream, state); } - } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. - return needMoreData(state); + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); } function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; stream.emit('data', chunk); - stream.read(0); } else { // update the buffer info. state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - if (state.needReadable) emitReadable(stream); } + maybeReadMore(stream, state); } function chunkInvalid(state, chunk) { var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); } - return er; -} -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); + return er; } Readable.prototype.isPaused = function () { return this._readableState.flowing === false; -}; +}; // backwards compatibility. + -// backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; return this; -}; +}; // Don't raise the hwm > 1GB + + +var MAX_HWM = 0x40000000; -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. n = MAX_HWM; } else { // Get the next highest power of 2 to prevent increasing hwm excessively in @@ -79423,56 +86265,55 @@ function computeNewHighWaterMark(n) { n |= n >>> 16; n++; } - return n; -} -// This function is designed to be inlinable, so please take care when making + return n; +} // This function is designed to be inlinable, so please take care when making // changes to the function body. + + function howMuchToRead(n, state) { if (n <= 0 || state.length === 0 && state.ended) return 0; if (state.objectMode) return 1; + if (n !== n) { // Only flow one buffer at a time if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. + } // If we're asking for more than the current hwm, then raise the hwm. + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough + if (n <= state.length) return n; // Don't have enough + if (!state.ended) { state.needReadable = true; return 0; } + return state.length; -} +} // you can override either this method, or the async _read(n) below. + -// you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { debug('read: emitReadable', state.length, state.ended); if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } - n = howMuchToRead(n, state); + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. - // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { if (state.length === 0) endReadable(this); return null; - } - - // All the actual chunk generation logic needs to be + } // All the actual chunk generation logic needs to be // *below* the call to _read. The reason is that in certain // synthetic stream cases, such as passthrough streams, _read // may be a completely synchronous operation which may change @@ -79493,33 +86334,34 @@ Readable.prototype.read = function (n) { // 'readable' etc. // // 3. Actually pull the requested chunks out of the buffer and return. - // if we need a readable event, then we need to do some reading. + + var doRead = state.needReadable; - debug('need readable', doRead); + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - // if we currently have less than the highWaterMark, then also read some if (state.length === 0 || state.length - n < state.highWaterMark) { - doRead = true; - debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already + doRead = true; + debug('length less than watermark', doRead); + } // however, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. + + if (state.ended || state.reading) { doRead = false; debug('reading or ended', doRead); } else if (doRead) { debug('do read'); state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } @@ -79527,91 +86369,144 @@ Readable.prototype.read = function (n) { if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { - state.needReadable = true; + state.needReadable = state.length <= state.highWaterMark; n = 0; } else { state.length -= n; + state.awaitDrain = 0; } if (state.length === 0) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. - // If we tried to read() past the EOF, then emit end on the next tick. if (nOrig !== n && state.ended) endReadable(this); } if (ret !== null) this.emit('data', ret); - return ret; }; function onEofChunk(stream, state) { + debug('onEofChunk'); if (state.ended) return; + if (state.decoder) { var chunk = state.decoder.end(); + if (chunk && chunk.length) { state.buffer.push(chunk); state.length += state.objectMode ? 1 : chunk.length; } } + state.ended = true; - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; -// Don't emit readable right away in sync mode, because this can trigger + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger // another read() call => stack overflow. This way, it might trigger // a nextTick recursion warning, but that's not so bad. + + function emitReadable(stream) { var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); state.needReadable = false; + if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + process.nextTick(emitReadable_, stream); } } function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); -// at this point, the user has presumably seen the 'readable' event, + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if // it's in progress. // However, if we're not ended, or reading, and the length < hwm, // then go ahead and try to read some more preemptively. + + function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); + process.nextTick(maybeReadMore_, stream, state); } } function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; debug('maybeReadMore read 0'); stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; + if (len === state.length) // didn't get any data, stop spinning. + break; } - state.readingMore = false; -} -// abstract method. to be overridden in specific implementation classes. + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. + + Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); }; Readable.prototype.pipe = function (dest, pipeOpts) { @@ -79622,24 +86517,26 @@ Readable.prototype.pipe = function (dest, pipeOpts) { case 0: state.pipes = dest; break; + case 1: state.pipes = [state.pipes, dest]; break; + default: state.pipes.push(dest); break; } + state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); - + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { debug('onunpipe'); + if (readable === src) { if (unpipeInfo && unpipeInfo.hasUnpiped === false) { unpipeInfo.hasUnpiped = true; @@ -79651,19 +86548,19 @@ Readable.prototype.pipe = function (dest, pipeOpts) { function onend() { debug('onend'); dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter + } // when the dest drains, it reduces the awaitDrain counter // on the source. This would be more elegant with a .once() // handler in flow(), but adding and removing repeatedly is // too slow. + + var ondrain = pipeOnDrain(src); dest.on('drain', ondrain); - var cleanedUp = false; + function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken + debug('cleanup'); // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); dest.removeListener('finish', onfinish); dest.removeListener('drain', ondrain); @@ -79672,75 +86569,71 @@ Readable.prototype.pipe = function (dest, pipeOpts) { src.removeListener('end', onend); src.removeListener('end', unpipe); src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this + cleanedUp = true; // if the reader is waiting for a drain event from this // specific writer, then it would cause it to never start // flowing again. // So, if this is awaiting a drain, then we just call it now. // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; src.on('data', ondata); + function ondata(chunk) { debug('ondata'); - increasedAwaitDrain = false; var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { + debug('dest.write', ret); + + if (ret === false) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. // => Check whether `dest` is still a piping destination. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; } + src.pause(); } - } - - // if the dest has an error, then stop piping into it. + } // if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. + + function onerror(er) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - // Both close and finish should trigger unpipe, but only once. + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + function onclose() { dest.removeListener('finish', onfinish); unpipe(); } + dest.once('close', onclose); + function onfinish() { debug('onfinish'); dest.removeListener('close', onclose); unpipe(); } + dest.once('finish', onfinish); function unpipe() { debug('unpipe'); src.unpipe(dest); - } + } // tell the dest that it's being piped to - // tell the dest that it's being piped to - dest.emit('pipe', src); - // start the flow if it hasn't been started already. + dest.emit('pipe', src); // start the flow if it hasn't been started already. + if (!state.flowing) { debug('pipe resume'); src.resume(); @@ -79750,10 +86643,11 @@ Readable.prototype.pipe = function (dest, pipeOpts) { }; function pipeOnDrain(src) { - return function () { + return function pipeOnDrainFunctionResult() { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { state.flowing = true; flow(src); @@ -79763,27 +86657,24 @@ function pipeOnDrain(src) { Readable.prototype.unpipe = function (dest) { var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; + if (state.pipesCount === 0) return this; // just one destination. most common case. - // just one destination. most common case. if (state.pipesCount === 1) { // passed in one, but it's not the right one. if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. - if (!dest) dest = state.pipes; - - // got a match. state.pipes = null; state.pipesCount = 0; state.flowing = false; if (dest) dest.emit('unpipe', this, unpipeInfo); return this; - } + } // slow case. multiple pipe destinations. - // slow case. multiple pipe destinations. if (!dest) { // remove all. @@ -79794,80 +86685,139 @@ Readable.prototype.unpipe = function (dest) { state.flowing = false; for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; - } + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + - // try to find the right one. var index = indexOf(state.pipes, dest); if (index === -1) return this; - state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this, unpipeInfo); - return this; -}; - -// set up data events if they are asked for +}; // set up data events if they are asked for // Ensure readable listeners eventually get something + + Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); } else if (ev === 'readable') { - var state = this._readableState; if (!state.endEmitted && !state.readableListening) { state.readableListening = state.needReadable = true; + state.flowing = false; state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { + debug('on readable', state.length, state.reading); + + if (state.length) { emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); } } } return res; }; + Readable.prototype.addListener = Readable.prototype.on; +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} + function nReadingNextTick(self) { debug('readable nexttick read 0'); self.read(0); -} - -// pause() and resume() are remnants of the legacy readable stream API +} // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. + + Readable.prototype.resume = function () { var state = this._readableState; + if (!state.flowing) { - debug('resume'); - state.flowing = true; + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; resume(this, state); } + + state.paused = false; return this; }; function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); + process.nextTick(resume_, stream, state); } } function resume_(stream, state) { + debug('resume', state.reading); + if (!state.reading) { - debug('resume read 0'); stream.read(0); } state.resumeScheduled = false; - state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); @@ -79875,31 +86825,37 @@ function resume_(stream, state) { Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { + + if (this._readableState.flowing !== false) { debug('pause'); this._readableState.flowing = false; this.emit('pause'); } + + this._readableState.paused = true; return this; }; function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} -// wrap an old-style stream as the async data source. + while (state.flowing && stream.read() !== null) { + ; + } +} // wrap an old-style stream as the async data source. // This is *not* part of the readable stream interface. // It is an ugly unfortunate mess of history. + + Readable.prototype.wrap = function (stream) { var _this = this; var state = this._readableState; var paused = false; - stream.on('end', function () { debug('wrapped end'); + if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) _this.push(chunk); @@ -79907,42 +86863,41 @@ Readable.prototype.wrap = function (stream) { _this.push(null); }); - stream.on('data', function (chunk) { debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode - // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; var ret = _this.push(chunk); + if (!ret) { paused = true; stream.pause(); } - }); - - // proxy all the other methods. + }); // proxy all the other methods. // important when wrapping filters and duplexes. + for (var i in stream) { if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { return stream[method].apply(stream, arguments); }; }(i); } - } + } // proxy certain important events. + - // proxy certain important events. for (var n = 0; n < kProxyEvents.length; n++) { stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } - - // when we try to consume some more bytes, simply unpause the + } // when we try to consume some more bytes, simply unpause the // underlying stream. + + this._read = function (n) { debug('wrapped _read', n); + if (paused) { paused = false; stream.resume(); @@ -79952,149 +86907,127 @@ Readable.prototype.wrap = function (stream) { return this; }; +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; +} + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._readableState.highWaterMark; } }); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. -// exposed for testing purposes only. Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. // This function is designed to be inlinable, so please take care when making // changes to the function body. + function fromList(n, state) { // nothing buffered if (state.length === 0) return null; - var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); state.buffer.clear(); } else { // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - - return ret; -} - -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} - -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; + ret = state.buffer.consume(n, state.decoder); } - list.length -= c; return ret; } function endReadable(stream) { var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + debug('endReadable', state.endEmitted); if (!state.endEmitted) { state.ended = true; - pna.nextTick(endReadableNT, state, stream); + process.nextTick(endReadableNT, state, stream); } } function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { state.endEmitted = true; stream.readable = false; stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } } } +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = require('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; +} + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; } + return -1; } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":309,"./internal/streams/BufferList":314,"./internal/streams/destroy":315,"./internal/streams/stream":316,"_process":271,"core-util-is":137,"events":239,"inherits":259,"isarray":261,"process-nextick-args":270,"safe-buffer":322,"string_decoder/":339,"util":104}],312:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":329,"./_stream_duplex":330,"./internal/streams/async_iterator":335,"./internal/streams/buffer_list":336,"./internal/streams/destroy":337,"./internal/streams/from":339,"./internal/streams/state":341,"./internal/streams/stream":342,"_process":291,"buffer":130,"events":241,"inherits":279,"string_decoder/":362,"util":239}],333:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -80115,7 +87048,6 @@ function indexOf(xs, x) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -80157,40 +87089,37 @@ function indexOf(xs, x) { // However, even in such a pathological case, only a single written chunk // would be consumed, and then the rest would wait (un-transformed) until // the results of the previous transformed chunk were consumed. - 'use strict'; module.exports = Transform; -var Duplex = require('./_stream_duplex'); +var _require$codes = require('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +var Duplex = require('./_stream_duplex'); -util.inherits(Transform, Duplex); +require('inherits')(Transform, Duplex); function afterTransform(er, data) { var ts = this._transformState; ts.transforming = false; - var cb = ts.writecb; - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); } ts.writechunk = null; ts.writecb = null; - if (data != null) // single equals check for both `null` and `undefined` this.push(data); - cb(er); - var rs = this._readableState; rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } @@ -80198,9 +87127,7 @@ function afterTransform(er, data) { function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); - Duplex.call(this, options); - this._transformState = { afterTransform: afterTransform.bind(this), needTransform: false, @@ -80208,30 +87135,27 @@ function Transform(options) { writecb: null, writechunk: null, writeencoding: null - }; + }; // start out asking for a readable event once data is transformed. - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. + this._readableState.sync = false; if (options) { if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') this._flush = options.flush; - } + } // When the writable side finishes, then flush out anything remaining. + - // When the writable side finishes, then flush out anything remaining. this.on('prefinish', prefinish); } function prefinish() { var _this = this; - if (typeof this._flush === 'function') { + if (typeof this._flush === 'function' && !this._readableState.destroyed) { this._flush(function (er, data) { done(_this, er, data); }); @@ -80243,9 +87167,7 @@ function prefinish() { Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! +}; // This is the part where you do stuff! // override this function in implementation classes. // 'chunk' is an input chunk. // @@ -80255,8 +87177,10 @@ Transform.prototype.push = function (chunk, encoding) { // Call `cb(err)` when you are done with this chunk. If you pass // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. + + Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -80264,20 +87188,22 @@ Transform.prototype._write = function (chunk, encoding, cb) { ts.writecb = cb; ts.writechunk = chunk; ts.writeencoding = encoding; + if (!ts.transforming) { var rs = this._readableState; if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } -}; - -// Doesn't matter what the args are here. +}; // Doesn't matter what the args are here. // _transform does all the work. // That we got here means that the readable side wants more data. + + Transform.prototype._read = function (n) { var ts = this._transformState; - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + if (ts.writechunk !== null && !ts.transforming) { ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); } else { // mark that we need a transform, so that any data that comes in @@ -80287,30 +87213,24 @@ Transform.prototype._read = function (n) { }; Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); - _this2.emit('close'); }); }; function done(stream, er, data) { if (er) return stream.emit('error', er); - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases // if there's nothing in the write buffer, then that means // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); return stream.push(null); } -},{"./_stream_duplex":309,"core-util-is":137,"inherits":259}],313:[function(require,module,exports){ -(function (process,global,setImmediate){ +},{"../errors":329,"./_stream_duplex":330,"inherits":279}],334:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -80331,35 +87251,29 @@ function done(stream, er, data) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Writable; - /* */ + function WriteReq(chunk, encoding, cb) { this.chunk = chunk; this.encoding = encoding; this.callback = cb; this.next = null; -} - -// It seems a linked list but it is not +} // It seems a linked list but it is not // there will be only 2 of these for each stream + + function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; + this.finish = function () { onCorkedFinish(_this, state); }; @@ -80367,266 +87281,247 @@ function CorkedRequest(state) { /* */ /**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ -/**/ + var Duplex; /**/ Writable.WritableState = WritableState; - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ var internalUtil = { deprecate: require('util-deprecate') }; /**/ /**/ + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } -/**/ - var destroyImpl = require('./internal/streams/destroy'); -util.inherits(Writable, Stream); +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; -function nop() {} +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); +var errorOrDestroy = destroyImpl.errorOrDestroy; - options = options || {}; +require('inherits')(Writable, Stream); - // Duplex streams are both readable and writable, but share +function nop() {} + +function WritableState(options, stream, isDuplex) { + Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - // object stream flag to indicate whether or not this stream + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream // contains buffers or objects. - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - // the point at which write() starts returning false + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); + this.finalCalled = false; // drain event flag. - // if _final has been called - this.finalCalled = false; + this.needDrain = false; // at the start of calling end() - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; + this.ending = false; // when end() has been called, and returned - // has it been destroyed - this.destroyed = false; + this.ended = false; // when 'finish' is emitted - // should we decode strings into buffers before passing to _write? + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - // Crypto is kind of old and crusty. Historically, its default string + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // not an actual buffer we keep track of, but a measurement + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement // of how much we're waiting to get pushed to some underlying // socket or file. - this.length = 0; - // a flag to see when we're in the middle of a write. - this.writing = false; + this.length = 0; // a flag to see when we're in the middle of a write. - // when true all writes will be buffered until .uncork() call - this.corked = 0; + this.writing = false; // when true all writes will be buffered until .uncork() call - // a flag to be able to tell if the onwrite cb is called immediately, + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. - this.sync = true; - // a flag to know if we're processing previously buffered items, which + this.sync = true; // a flag to know if we're processing previously buffered items, which // may call the _write() callback in the same tick, so that we don't // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - // the callback that's passed to _write(chunk,cb) + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { onwrite(stream, er); - }; + }; // the callback that the user supplies to write(chunk,encoding,cb) - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - // the amount that is being written when _write is called. - this.writelen = 0; + this.writecb = null; // the amount that is being written when _write is called. + this.writelen = 0; this.bufferedRequest = null; - this.lastBufferedRequest = null; - - // number of pending user-supplied write callbacks + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - // emit prefinish if the only thing we're waiting for is _write cbs + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs // This is relevant for synchronous Transform streams - this.prefinished = false; - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; + this.prefinished = false; // True if the error was already emitted and should not be thrown again - // count buffered requests - this.bufferedRequestCount = 0; + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. - // allocate the first CorkedRequest, there is always + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; + while (current) { out.push(current); current = current.next; } + return out; }; (function () { try { Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { + get: internalUtil.deprecate(function writableStateBufferGetter() { return this.getBuffer(); }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); } catch (_) {} -})(); - -// Test _writableState for inheritance to account for Duplex streams, +})(); // Test _writableState for inheritance to account for Duplex streams, // whose prototype chain only points to Readable. + + var realHasInstance; + if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { realHasInstance = Function.prototype[Symbol.hasInstance]; Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { + value: function value(object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; - return object && object._writableState instanceof WritableState; } }); } else { - realHasInstance = function (object) { + realHasInstance = function realHasInstance(object) { return object instanceof this; }; } function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - // Writable ctor is applied to Duplexes, too. + Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. // `realHasInstance` is necessary because using plain `instanceof` // would return false, as no `_writableState` property is attached. - // Trying to use the custom `instanceof` for Writable here will also break the // Node.js LazyTransform implementation, which has a non-trivial getter for // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 - this._writableState = new WritableState(options, this); + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. - // legacy. this.writable = true; if (options) { if (typeof options.write === 'function') this._write = options.write; - if (typeof options.writev === 'function') this._writev = options.writev; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - if (typeof options.final === 'function') this._final = options.final; } Stream.call(this); -} +} // Otherwise people can pipe Writable streams, which is just wrong. + -// Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); }; function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb -// Checks that a user-supplied chunk is valid, especially for the particular + errorOrDestroy(stream, er); + process.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular // mode the stream is in. Currently this means that `null` is never accepted // and undefined/non-string values are only allowed in object mode. + + function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; + var er; if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); } + if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; } - return valid; + + return true; } Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer.isBuffer(chunk)) { @@ -80639,21 +87534,16 @@ Writable.prototype.write = function (chunk, encoding, cb) { } if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } - return ret; }; Writable.prototype.cork = function () { - var state = this._writableState; - - state.corked++; + this._writableState.corked++; }; Writable.prototype.uncork = function () { @@ -80661,23 +87551,33 @@ Writable.prototype.uncork = function () { if (state.corked) { state.corked--; - - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); this._writableState.defaultEncoding = encoding; return this; }; +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = Buffer.from(chunk, encoding); } + return chunk; } @@ -80686,29 +87586,28 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } -}); - -// if we're already writing something, then just put this +}); // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. + function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { isBuf = true; encoding = 'buffer'; chunk = newChunk; } } - var len = state.objectMode ? 1 : chunk.length; + var len = state.objectMode ? 1 : chunk.length; state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; if (state.writing || state.corked) { @@ -80720,11 +87619,13 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { callback: cb, next: null }; + if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } + state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); @@ -80738,7 +87639,7 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writecb = cb; state.writing = true; state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } @@ -80748,20 +87649,20 @@ function onwriteError(stream, state, sync, er, cb) { if (sync) { // defer the callback if we are being called synchronously // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen + process.nextTick(cb, er); // this can emit finish, and it will always happen // after error - pna.nextTick(finishMaybe, stream, state); + + process.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; - stream.emit('error', er); + errorOrDestroy(stream, er); } else { // the caller expect this to happen before if // it is async cb(er); stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must + errorOrDestroy(stream, er); // this can emit finish, but finish must // always follow error + finishMaybe(stream, state); } } @@ -80777,21 +87678,18 @@ function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; - + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); onwriteStateUpdate(state); - if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); + var finished = needFinish(state) || stream.destroyed; if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ + process.nextTick(afterWrite, stream, state, finished, cb); } else { afterWrite(stream, state, finished, cb); } @@ -80803,19 +87701,19 @@ function afterWrite(stream, state, finished, cb) { state.pendingcb--; cb(); finishMaybe(stream, state); -} - -// Must force callback to be called on nextTick, so that we don't +} // Must force callback to be called on nextTick, so that we don't // emit 'drain' before the write() consumer gets the 'false' return // value, and has a chance to attach a 'drain' listener. + + function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit('drain'); } -} +} // if there's something in the buffer waiting, then process it + -// if there's something in the buffer waiting, then process it function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; @@ -80826,29 +87724,30 @@ function clearBuffer(stream, state) { var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; - var count = 0; var allBuffers = true; + while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } - buffer.allBuffers = allBuffers; - - doWrite(stream, state, true, state.length, buffer, '', holder.finish); - // doWrite is almost always async, defer these to save a bit of time + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite + state.pendingcb++; state.lastBufferedRequest = null; + if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } + state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one @@ -80857,14 +87756,13 @@ function clearBuffer(stream, state) { var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; - doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then // it means that we need to wait until it does. // also, that means that the chunk and cb are currently // being processed, so move the buffer counter past them. + if (state.writing) { break; } @@ -80878,7 +87776,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); }; Writable.prototype._writev = null; @@ -80895,38 +87793,52 @@ Writable.prototype.end = function (chunk, encoding, cb) { encoding = null; } - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks - // .end() fully uncorks if (state.corked) { state.corked = 1; this.uncork(); - } + } // ignore unnecessary end() calls. - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); + + if (!state.ending) endWritable(this, state, cb); + return this; }; +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); + function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } + function callFinal(stream, state) { stream._final(function (err) { state.pendingcb--; + if (err) { - stream.emit('error', err); + errorOrDestroy(stream, err); } + state.prefinished = true; stream.emit('prefinish'); finishMaybe(stream, state); }); } + function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { + if (typeof stream._final === 'function' && !state.destroyed) { state.pendingcb++; state.finalCalled = true; - pna.nextTick(callFinal, stream, state); + process.nextTick(callFinal, stream, state); } else { state.prefinished = true; stream.emit('prefinish'); @@ -80936,22 +87848,37 @@ function prefinish(stream, state) { function finishMaybe(stream, state) { var need = needFinish(state); + if (need) { prefinish(stream, state); + if (state.pendingcb === 0) { state.finished = true; stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } } } + return need; } function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); + if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); } + state.ended = true; stream.writable = false; } @@ -80959,59 +87886,289 @@ function endWritable(stream, state, cb) { function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; + while (entry) { var cb = entry.callback; state.pendingcb--; cb(err); entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; } Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._writableState === undefined) { return false; } + return this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._writableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._writableState.destroyed = value; } }); - Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; + Writable.prototype._destroy = function (err, cb) { - this.end(); cb(err); }; -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":309,"./internal/streams/destroy":315,"./internal/streams/stream":316,"_process":271,"core-util-is":137,"inherits":259,"process-nextick-args":270,"safe-buffer":322,"timers":349,"util-deprecate":358}],314:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,"_process":291,"buffer":130,"inherits":279,"util-deprecate":381}],335:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +var _Object$setPrototypeO; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var finished = require('./end-of-stream'); + +var kLastResolve = Symbol('lastResolve'); +var kLastReject = Symbol('lastReject'); +var kError = Symbol('error'); +var kEnded = Symbol('ended'); +var kLastPromise = Symbol('lastPromise'); +var kHandlePromise = Symbol('handlePromise'); +var kStream = Symbol('stream'); + +function createIterResult(value, done) { + return { + value: value, + done: done + }; +} + +function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } +} + +function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); +} + +function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; +} + +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; +}), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); +}), _Object$setPrototypeO), AsyncIteratorPrototype); + +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; +}; + +module.exports = createReadableStreamAsyncIterator; +}).call(this)}).call(this,require('_process')) +},{"./end-of-stream":338,"_process":291}],336:[function(require,module,exports){ 'use strict'; +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var _require = require('buffer'), + Buffer = _require.Buffer; + +var _require2 = require('util'), + inspect = _require2.inspect; + +var custom = inspect && inspect.custom || 'inspect'; function copyBuffer(src, target, offset) { - src.copy(target, offset); + Buffer.prototype.copy.call(src, target, offset); } -module.exports = function () { +module.exports = +/*#__PURE__*/ +function () { function BufferList() { _classCallCheck(this, BufferList); @@ -81020,74 +88177,183 @@ module.exports = function () { this.length = 0; } - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; + while (p = p.next) { + ret += s + p.data; + } - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; } - return ret; - }; + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. - return BufferList; -}(); + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":322,"util":104}],315:[function(require,module,exports){ -'use strict'; + break; + } -/**/ + ++c; + } -var pna = require('process-nextick-args'); -/**/ + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; +}(); +},{"buffer":130,"util":239}],337:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; // undocumented cb() API, needed for core, not for public API -// undocumented cb() API, needed for core, not for public API function destroy(err, cb) { var _this = this; @@ -81097,38 +88363,61 @@ function destroy(err, cb) { if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } } - return this; - } - // we set destroyed to true before firing error callbacks in order + return this; + } // we set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks + if (this._readableState) { this._readableState.destroyed = true; - } + } // if this is a duplex stream mark the writable part as destroyed as well + - // if this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function (err) { if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); } } else if (cb) { + process.nextTick(emitCloseNT, _this); cb(err); + } else { + process.nextTick(emitCloseNT, _this); } }); return this; } +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} + +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} + function undestroy() { if (this._readableState) { this._readableState.destroyed = false; @@ -81141,6 +88430,8 @@ function undestroy() { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } @@ -81150,17 +88441,262 @@ function emitErrorNT(self, err) { self.emit('error', err); } +function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} + module.exports = { destroy: destroy, - undestroy: undestroy + undestroy: undestroy, + errorOrDestroy: errorOrDestroy }; -},{"process-nextick-args":270}],316:[function(require,module,exports){ -module.exports = require('events').EventEmitter; +}).call(this)}).call(this,require('_process')) +},{"_process":291}],338:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/end-of-stream with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; -},{"events":239}],317:[function(require,module,exports){ -module.exports = require('./readable').PassThrough +var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; +} + +function noop() {} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} + +module.exports = eos; +},{"../../../errors":329}],339:[function(require,module,exports){ +module.exports = function () { + throw new Error('Readable.from is not available in the browser') +}; + +},{}],340:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/pump with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var eos; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} + +var _require$codes = require('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = require('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} + +function call(fn) { + fn(); +} + +function pipe(from, to) { + return from.pipe(to); +} + +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} + +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} + +module.exports = pipeline; +},{"../../../errors":329,"./end-of-stream":338}],341:[function(require,module,exports){ +'use strict'; + +var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; + +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} + +function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; +} -},{"./readable":318}],318:[function(require,module,exports){ +module.exports = { + getHighWaterMark: getHighWaterMark +}; +},{"../../../errors":329}],342:[function(require,module,exports){ +arguments[4][251][0].apply(exports,arguments) +},{"dup":251,"events":241}],343:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -81168,14 +88704,10 @@ exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); +exports.finished = require('./lib/internal/streams/end-of-stream.js'); +exports.pipeline = require('./lib/internal/streams/pipeline.js'); -},{"./lib/_stream_duplex.js":309,"./lib/_stream_passthrough.js":310,"./lib/_stream_readable.js":311,"./lib/_stream_transform.js":312,"./lib/_stream_writable.js":313}],319:[function(require,module,exports){ -module.exports = require('./readable').Transform - -},{"./readable":318}],320:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); - -},{"./lib/_stream_writable.js":313}],321:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(require,module,exports){ 'use strict' var Buffer = require('buffer').Buffer var inherits = require('inherits') @@ -81340,7 +88872,8 @@ function fn5 (a, b, c, d, e, m, k, s) { module.exports = RIPEMD160 -},{"buffer":131,"hash-base":243,"inherits":259}],322:[function(require,module,exports){ +},{"buffer":130,"hash-base":264,"inherits":279}],345:[function(require,module,exports){ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -81363,6 +88896,8 @@ function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } +SafeBuffer.prototype = Object.create(Buffer.prototype) + // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) @@ -81404,12 +88939,93 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":131}],323:[function(require,module,exports){ +},{"buffer":130}],346:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-disable node/no-deprecated-api */ + +'use strict' + +var buffer = require('buffer') +var Buffer = buffer.Buffer + +var safer = {} + +var key + +for (key in buffer) { + if (!buffer.hasOwnProperty(key)) continue + if (key === 'SlowBuffer' || key === 'Buffer') continue + safer[key] = buffer[key] +} + +var Safer = safer.Buffer = {} +for (key in Buffer) { + if (!Buffer.hasOwnProperty(key)) continue + if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue + Safer[key] = Buffer[key] +} + +safer.Buffer.prototype = Buffer.prototype + +if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) + } + if (value && typeof value.length === 'undefined') { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) + } + return Buffer(value, encodingOrOffset, length) + } +} + +if (!Safer.alloc) { + Safer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) + } + if (size < 0 || size >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + var buf = Buffer(size) + if (!fill || fill.length === 0) { + buf.fill(0) + } else if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + return buf + } +} + +if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process.binding('buffer').kStringMaxLength + } catch (e) { + // we can't determine kStringMaxLength in environments where process.binding + // is unsupported, so let's not set it + } +} + +if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + } + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength + } +} + +module.exports = safer + +}).call(this)}).call(this,require('_process')) +},{"_process":291,"buffer":130}],347:[function(require,module,exports){ 'use strict' module.exports = require('./lib')(require('./lib/elliptic')) -},{"./lib":327,"./lib/elliptic":326}],324:[function(require,module,exports){ -(function (Buffer){ +},{"./lib":351,"./lib/elliptic":350}],348:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict' var toString = Object.prototype.toString @@ -81455,8 +89071,8 @@ exports.isNumberInInterval = function (number, x, y, message) { if (number <= x || number >= y) throw RangeError(message) } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":260}],325:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":280}],349:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var bip66 = require('bip66') @@ -81651,7 +89267,7 @@ exports.signatureImportLax = function (sig) { return { r: r, s: s } } -},{"bip66":40,"safe-buffer":322}],326:[function(require,module,exports){ +},{"bip66":40,"safe-buffer":345}],350:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var createHash = require('create-hash') @@ -81784,7 +89400,10 @@ exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) { tweak = new BN(tweak) if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) - return Buffer.from(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed)) + var point = ecparams.g.mul(tweak).add(pair.pub) + if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) + + return Buffer.from(point.encode(true, compressed)) } exports.publicKeyTweakMul = function (publicKey, tweak, compressed) { @@ -81868,7 +89487,7 @@ exports.sign = function (message, privateKey, noncefn, data) { } exports.verify = function (message, signature, publicKey) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -81878,11 +89497,11 @@ exports.verify = function (message, signature, publicKey) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y}) + return ec.verify(message, sigObj, { x: pair.pub.x, y: pair.pub.y }) } exports.recover = function (message, signature, recovery, compressed) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -81913,7 +89532,7 @@ exports.ecdhUnsafe = function (publicKey, privateKey, compressed) { return Buffer.from(pair.pub.mul(scalar).encode(true, compressed)) } -},{"../messages.json":328,"bn.js":90,"create-hash":139,"elliptic":221,"safe-buffer":322}],327:[function(require,module,exports){ +},{"../messages.json":352,"bn.js":90,"create-hash":138,"elliptic":222,"safe-buffer":345}],351:[function(require,module,exports){ 'use strict' var assert = require('./assert') var der = require('./der') @@ -82160,7 +89779,7 @@ module.exports = function (secp256k1) { } } -},{"./assert":324,"./der":325,"./messages.json":328}],328:[function(require,module,exports){ +},{"./assert":348,"./der":349,"./messages.json":352}],352:[function(require,module,exports){ module.exports={ "COMPRESSED_TYPE_INVALID": "compressed should be a boolean", "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer", @@ -82199,7 +89818,7 @@ module.exports={ "TWEAK_LENGTH_INVALID": "tweak length is invalid" } -},{}],329:[function(require,module,exports){ +},{}],353:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer // prototype class for hash functions @@ -82282,7 +89901,7 @@ Hash.prototype._update = function () { module.exports = Hash -},{"safe-buffer":322}],330:[function(require,module,exports){ +},{"safe-buffer":345}],354:[function(require,module,exports){ var exports = module.exports = function SHA (algorithm) { algorithm = algorithm.toLowerCase() @@ -82299,7 +89918,7 @@ exports.sha256 = require('./sha256') exports.sha384 = require('./sha384') exports.sha512 = require('./sha512') -},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(require,module,exports){ +},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined * in FIPS PUB 180-1 @@ -82395,7 +90014,7 @@ Sha.prototype._hash = function () { module.exports = Sha -},{"./hash":329,"inherits":259,"safe-buffer":322}],332:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],356:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 @@ -82496,7 +90115,7 @@ Sha1.prototype._hash = function () { module.exports = Sha1 -},{"./hash":329,"inherits":259,"safe-buffer":322}],333:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],357:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -82551,7 +90170,7 @@ Sha224.prototype._hash = function () { module.exports = Sha224 -},{"./hash":329,"./sha256":334,"inherits":259,"safe-buffer":322}],334:[function(require,module,exports){ +},{"./hash":353,"./sha256":358,"inherits":279,"safe-buffer":345}],358:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -82688,7 +90307,7 @@ Sha256.prototype._hash = function () { module.exports = Sha256 -},{"./hash":329,"inherits":259,"safe-buffer":322}],335:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],359:[function(require,module,exports){ var inherits = require('inherits') var SHA512 = require('./sha512') var Hash = require('./hash') @@ -82747,7 +90366,7 @@ Sha384.prototype._hash = function () { module.exports = Sha384 -},{"./hash":329,"./sha512":336,"inherits":259,"safe-buffer":322}],336:[function(require,module,exports){ +},{"./hash":353,"./sha512":360,"inherits":279,"safe-buffer":345}],360:[function(require,module,exports){ var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer @@ -83009,7 +90628,7 @@ Sha512.prototype._hash = function () { module.exports = Sha512 -},{"./hash":329,"inherits":259,"safe-buffer":322}],337:[function(require,module,exports){ +},{"./hash":353,"inherits":279,"safe-buffer":345}],361:[function(require,module,exports){ "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; sjcl.cipher.aes=function(a){this.j[0][0][0]||this.m();var b,c,d,e,f=this.j[0][4],h=this.j[1];b=a.length;var g=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.c=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^g<<24,g=g<<1^283*(g>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:h[0][f[c>>>24]]^h[1][f[c>>16&255]]^h[2][f[c>>8&255]]^h[3][f[c& 255]]}; @@ -83042,440 +90661,16 @@ sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(thi sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E4;if(0>d||0>c)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,h,g,l,k=[],m=sjcl.bitArray;for(l=1;32*k.length<(d||1);l++){e=f=a.encrypt(m.concat(b,[l]));for(h=1;h*/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":322}],340:[function(require,module,exports){ +},{}],362:[function(require,module,exports){ +arguments[4][253][0].apply(exports,arguments) +},{"dup":253,"safe-buffer":345}],363:[function(require,module,exports){ module.exports = function (options) { options.signer = options.signer || require('./lib/signer-hmac-only'); return require('./lib/index')(options); } -},{"./lib/index":341,"./lib/signer-hmac-only":342}],341:[function(require,module,exports){ +},{"./lib/index":364,"./lib/signer-hmac-only":365}],364:[function(require,module,exports){ /** * original code from http-signature package by Joyent, Inc. * @@ -83634,7 +90829,7 @@ module.exports = function (options) { }; } -},{"util":360}],342:[function(require,module,exports){ +},{"util":263}],365:[function(require,module,exports){ var createHmac = require('create-hmac'); module.exports = function (stringToSign, options) { @@ -83651,7 +90846,7 @@ module.exports = function (stringToSign, options) { return signature; }; -},{"create-hmac":141}],343:[function(require,module,exports){ +},{"create-hmac":140}],366:[function(require,module,exports){ function Agent() { this._defaults = []; } @@ -83673,7 +90868,7 @@ Agent.prototype._setDefaults = function(req) { module.exports = Agent; -},{}],344:[function(require,module,exports){ +},{}],367:[function(require,module,exports){ /** * Root reference for iframes. */ @@ -84595,7 +91790,7 @@ request.put = function(url, data, fn) { return req; }; -},{"./agent-base":343,"./is-object":345,"./request-base":346,"./response-base":347,"component-emitter":136}],345:[function(require,module,exports){ +},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(require,module,exports){ 'use strict'; /** @@ -84612,7 +91807,7 @@ function isObject(obj) { module.exports = isObject; -},{}],346:[function(require,module,exports){ +},{}],369:[function(require,module,exports){ 'use strict'; /** @@ -85308,7 +92503,7 @@ RequestBase.prototype._setTimeouts = function() { } }; -},{"./is-object":345}],347:[function(require,module,exports){ +},{"./is-object":368}],370:[function(require,module,exports){ 'use strict'; /** @@ -85446,7 +92641,7 @@ ResponseBase.prototype._setStatusProperties = function(status){ this.unprocessableEntity = 422 == status; }; -},{"./utils":348}],348:[function(require,module,exports){ +},{"./utils":371}],371:[function(require,module,exports){ 'use strict'; /** @@ -85519,8 +92714,8 @@ exports.cleanHeader = function(header, changesOrigin){ return header; }; -},{}],349:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ +},{}],372:[function(require,module,exports){ +(function (setImmediate,clearImmediate){(function (){ var nextTick = require('process/browser.js').nextTick; var apply = Function.prototype.apply; var slice = Array.prototype.slice; @@ -85597,8 +92792,8 @@ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : funct exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { delete immediateIds[id]; }; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":271,"timers":349}],350:[function(require,module,exports){ +}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":291,"timers":372}],373:[function(require,module,exports){ module.exports = to_utf8 var out = [] @@ -85673,7 +92868,7 @@ function reduced(list) { return out } -},{}],351:[function(require,module,exports){ +},{}],374:[function(require,module,exports){ var native = require('./native') function getTypeName (fn) { @@ -85785,8 +92980,8 @@ module.exports = { getValueTypeName: getValueTypeName } -},{"./native":354}],352:[function(require,module,exports){ -(function (Buffer){ +},{"./native":377}],375:[function(require,module,exports){ +(function (Buffer){(function (){ var NATIVE = require('./native') var ERRORS = require('./errors') @@ -85879,8 +93074,8 @@ for (var typeName in types) { module.exports = types -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":260,"./errors":351,"./native":354}],353:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(require,module,exports){ var ERRORS = require('./errors') var NATIVE = require('./native') @@ -86142,7 +93337,7 @@ typeforce.TfPropertyTypeError = TfPropertyTypeError module.exports = typeforce -},{"./errors":351,"./extra":352,"./native":354}],354:[function(require,module,exports){ +},{"./errors":374,"./extra":375,"./native":377}],377:[function(require,module,exports){ var types = { Array: function (value) { return value !== null && value !== undefined && value.constructor === Array }, Boolean: function (value) { return typeof value === 'boolean' }, @@ -86165,7 +93360,7 @@ for (var typeName in types) { module.exports = types -},{}],355:[function(require,module,exports){ +},{}],378:[function(require,module,exports){ (function (root) { "use strict"; @@ -86588,28 +93783,38 @@ UChar.udata={ unorm.shimApplied = false; if (!String.prototype.normalize) { - String.prototype.normalize = function(form) { - var str = "" + this; - form = form === undefined ? "NFC" : form; - - if (form === "NFC") { - return unorm.nfc(str); - } else if (form === "NFD") { - return unorm.nfd(str); - } else if (form === "NFKC") { - return unorm.nfkc(str); - } else if (form === "NFKD") { - return unorm.nfkd(str); - } else { - throw new RangeError("Invalid normalization form: " + form); + Object.defineProperty(String.prototype, "normalize", { + enumerable: false, + configurable: true, + writable: true, + value: function normalize (/*form*/) { + + var str = "" + this; + var form = arguments[0] === undefined ? "NFC" : arguments[0]; + + if (this === null || this === undefined) { + throw new TypeError("Cannot call method on " + Object.prototype.toString.call(this)); + } + + if (form === "NFC") { + return unorm.nfc(str); + } else if (form === "NFD") { + return unorm.nfd(str); + } else if (form === "NFKC") { + return unorm.nfkc(str); + } else if (form === "NFKD") { + return unorm.nfkd(str); + } else { + throw new RangeError("Invalid normalization form: " + form); + } } - }; + }); unorm.shimApplied = true; } }(this)); -},{}],356:[function(require,module,exports){ +},{}],379:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -87343,7 +94548,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":357,"punycode":240,"querystring":305}],357:[function(require,module,exports){ +},{"./util":380,"punycode":242,"querystring":326}],380:[function(require,module,exports){ 'use strict'; module.exports = { @@ -87361,8 +94566,8 @@ module.exports = { } }; -},{}],358:[function(require,module,exports){ -(function (global){ +},{}],381:[function(require,module,exports){ +(function (global){(function (){ /** * Module exports. @@ -87431,12 +94636,8 @@ function config (name) { return String(val).toLowerCase() === 'true'; } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],359:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"dup":26}],360:[function(require,module,exports){ -arguments[4][27][0].apply(exports,arguments) -},{"./support/isBuffer":359,"_process":271,"dup":27,"inherits":259}],361:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],382:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer @@ -87520,15 +94721,15 @@ function encodingLength (number) { return ( number < 0xfd ? 1 - : number <= 0xffff ? 3 - : number <= 0xffffffff ? 5 - : 9 + : number <= 0xffff ? 3 + : number <= 0xffffffff ? 5 + : 9 ) } module.exports = { encode: encode, decode: decode, encodingLength: encodingLength } -},{"safe-buffer":322}],362:[function(require,module,exports){ +},{"safe-buffer":345}],383:[function(require,module,exports){ var bundleFn = arguments[3]; var sources = arguments[4]; var cache = arguments[5]; @@ -87610,8 +94811,8 @@ module.exports = function (fn, options) { return worker; }; -},{}],363:[function(require,module,exports){ -(function (Buffer){ +},{}],384:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') function decodeRaw (buffer, version) { @@ -87676,6 +94877,6 @@ module.exports = { encodeRaw: encodeRaw } -}).call(this,require("buffer").Buffer) -},{"bs58check":127,"buffer":131}]},{},[22])(22) +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":126,"buffer":130}]},{},[22])(22) }); diff --git a/build/blocktrail-sdk-with-backup-generator.min.js b/build/blocktrail-sdk-with-backup-generator.min.js index 2e41c0e..c4adbf9 100644 --- a/build/blocktrail-sdk-with-backup-generator.min.js +++ b/build/blocktrail-sdk-with-backup-generator.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).blocktrailSDK=e()}}(function(){var define,module,exports;return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){return i(t[s][1][e]||e)},f,f.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0})})})}),s.then(function(e){o.resolve({has_transactions:e})},function(e){o.reject(e)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){if(null===e.data)return e;var t=n.converter.convertAddressTxs(e);return t.data=t.data.filter(function(e){return!e.confirmations}),t}),r)},_.prototype.addressUnspentOutputs=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(t){return null===t.data?t:n.converter.convertAddressUnspentOutputs(t,e)}),r)},_.prototype.batchAddressUnspentOutputs=function(e,t,r){var n=this;return n.converter instanceof u?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBatchAddressUnspentOutputs(e)}),r):("function"==typeof t&&(r=t,t=null),w(n.dataClient.post("/address/unspent-outputs",t,{addresses:e}),r))},_.prototype.verifyAddress=function(e,t,r){return this.verifyMessage(e,e,t,r)},_.prototype.allBlocks=function(e,t){var r=this;return"function"==typeof e&&(t=e,e=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(e)).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlocks(e)}),t)},_.prototype.block=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlock(e.data)}),t)},_.prototype.blockLatest=function(e){var t=this;return w(t.dataClient.get(t.converter.getUrlForBlock("latest"),null).then(function(e){return t.converter.handleErrors(t,e)}).then(function(e){return null===e.data?e:t.converter.convertBlock(e.data)}),e)},_.prototype.blockTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBlockTxs(e)}),r)},_.prototype.transaction=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(t){return null===t.data?t:r.converter instanceof u?r.dataClient.get(r.converter.getUrlForRawTransaction(e),null).then(function(e){return[t,e.data]}).then(function(e){if(null!==e){var t=e[0],n=e[1];return r.converter.convertTx(t,n)}return e}):r.converter.convertTx(t)}),t)},_.prototype.transactions=function(e,t){var r=this;return r.converter instanceof u?w(r.dataClient.get(r.converter.getUrlForTransactions(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertTxs(e)}),t):w(r.dataClient.post("/transactions",null,e,null,!1),t)},_.prototype.allWebhooks=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/webhooks",e,t)},_.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.post("/webhook",null,{url:e,identifier:t},r)},_.prototype.getLegacyBitcoinCashAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromBase58Check(e,this.network),e}catch(e){}if((t=o.address.fromCashAddress(e,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(t.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(t.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromCashAddress(e,this.network),e}catch(e){}if((t=o.address.fromBase58Check(e,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(t.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(t.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(e,t){return this.blocktrailClient.get("/webhook/"+e,null,t)},_.prototype.updateWebhook=function(e,t,r){return this.blocktrailClient.put("/webhook/"+e,null,t,r)},_.prototype.deleteWebhook=function(e,t){return this.blocktrailClient.delete("/webhook/"+e,null,null,t)},_.prototype.getWebhookEvents=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/webhook/"+e+"/events",t,r)},_.prototype.subscribeTransaction=function(e,t,r,n){var i={event_type:"transaction",transaction:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(e,t,r,n){var i={event_type:"address-transactions",address:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(e,t,r){return t.forEach(function(e){e.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+e+"/events/batch",null,t,r)},_.prototype.subscribeNewBlocks=function(e,t){return this.blocktrailClient.post("/webhook/"+e+"/events",null,{event_type:"block"},t)},_.prototype.unsubscribeAddressTransactions=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/address-transactions/"+t,null,null,r)},_.prototype.unsubscribeTransaction=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/transaction/"+t,null,null,r)},_.prototype.unsubscribeNewBlocks=function(e,t){return this.blocktrailClient.delete("/webhook/"+e+"/block",null,null,t)},_.prototype.getWalletLatestBlock=function(e){return this.blocktrailClient.get("/block/latest",null,e)},_.prototype.initWallet=function(e,t){var r=this;if("object"!=typeof e&&(e={identifier:arguments[0],passphrase:arguments[1]},t=arguments[2]),e.check_backup_key&&"string"!=typeof e.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(t);var a=e.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(t){var i=e.keyIndex||t.key_index;if(e.walletVersion=t.wallet_version,e.check_backup_key&&e.check_backup_key!==t.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(t.backup_public_key[0],r.network),u=n.mapValues(t.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),f=n.mapValues(t.primary_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),h=new c(r,a,e.walletVersion,t.primary_mnemonic,t.encrypted_primary_seed,t.encrypted_secret,f,s,u,i,t.segwit||0,r.testnet,r.regtest,t.checksum,t.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.recoverySecret=t.recovery_secret,e.readOnly?h:h.unlock(e).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(e,t){var r=this;if("object"!=typeof e){var n=arguments[0],o=arguments[1],s=arguments[2];t=arguments[3],"function"==typeof s&&(t=s,s=null),e={identifier:n,passphrase:o,keyIndex:s}}e.walletVersion=e.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(t),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),e.keyIndex=e.keyIndex||0,e.passphrase=e.passphrase||e.password,delete e.password,!e.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;e.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(e){var t=this,r=i.defer();return i.nextTick(function(){if(!e.primaryMnemonic&&!e.primarySeed){if(!e.passphrase&&!e.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;e.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==e.storePrimaryMnemonic&&(e.storePrimaryMnemonic=!0)}e.backupMnemonic||e.backupPublicKey||(e.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),t.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),t.resolveBackupPublicKeyFromOptions(e).then(function(e){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),a=e.keyIndex,u=e.primaryPrivateKey.deriveHardened(a).neutered();return t.storeNewWalletV1(e.identifier,[u.toBase58(),"M/"+a+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storePrimaryMnemonic&&e.primaryMnemonic,s,a,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V1,e.primaryMnemonic,null,null,{keyIndex:u},e.backupPublicKey,f,a,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:e.passphrase,primarySeed:e.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:e.primaryMnemonic,backupMnemonic:e.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)})}),r.promise},_.prototype._createNewWalletV2=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||y(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return function(e,t){return i.when(e).then(function(e){if(e.storeDataOnServer){if(!e.secret){if(!e.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");t(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),e.secret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),e.encryptedSecret=v.AES.encrypt(e.secret,e.passphrase).toString(v.format.OpenSSL)}t(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),e.encryptedPrimarySeed=v.AES.encrypt(e.primarySeed.toString("base64"),e.secret).toString(v.format.OpenSSL),e.recoverySecret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),t(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),e.recoveryEncryptedSecret=v.AES.encrypt(e.secret,e.recoverySecret).toString(v.format.OpenSSL)}return e})}(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),u=e.keyIndex;return t.storeNewWalletV2(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+u+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,u,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V2,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,f,u,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(e.encryptedPrimarySeed,"base64","hex")):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed.toString("hex")):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(e.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:e.encryptedSecret?a.entropyToMnemonic(b.convert(e.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype._createNewWalletV3=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||y(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return t.produceEncryptedDataV3(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),u=e.keyIndex;return t.storeNewWalletV3(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+u+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,u,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V3,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,f,u,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?p.encode(e.encryptedPrimarySeed):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?p.encode(e.recoveryEncryptedSecret):null,encryptedSecret:e.encryptedSecret?p.encode(e.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype.storeNewWalletV1=function(e,t,r,n,i,o,s){var a={identifier:e,wallet_version:c.WALLET_VERSION_V1,primary_public_key:t,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(e,t,r,n,i,o,s,a,u,f){var h={identifier:e,wallet_version:c.WALLET_VERSION_V2,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(e,t,r,n,i,o,s,a,u,f){var h={identifier:e,wallet_version:c.WALLET_VERSION_V3,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e,null,t,r)},_.prototype.upgradeKeyIndex=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/upgrade",null,{key_index:t,primary_public_key:r},n)},_.prototype.getWalletBalance=function(e,t){return this.blocktrailClient.get("/wallet/"+e+"/balance",null,!0,t)},_.prototype.doWalletDiscovery=function(e,t,r){return this.blocktrailClient.get("/wallet/"+e+"/discovery",{gap:t},!0,r)},_.prototype.getNewDerivation=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e+"/path",null,{path:t},r)},_.prototype.deleteWallet=function(e,t,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+e,{force:n},{checksum:t,signature:r},i)},_.prototype.coinSelection=function(e,t,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var u=i.defer();u.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),u.resolve(this.blocktrailClient.post("/wallet/"+e+"/coin-selection",f,t).then(function(e){return[e.utxos,e.fee,e.change,e]},function(e){if(e.message.match(/too low to pay the fee/))throw b.WalletFeeError(e);throw e})),u.promise},_.prototype.feePerKB=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.blocktrailClient.get("/fee-per-kb")),t.promise},_.prototype.sendTransaction=function(e,t,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof t?c.raw_transaction=t:"object"==typeof t&&Object.keys(t).map(function(e){c[e]=t[e]});var u={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(u.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(u.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(e){return String.fromCharCode(e)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+e+"/send",u,c,a)},_.prototype.setupWalletWebhook=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/webhook",null,{url:r,identifier:t},n)},_.prototype.deleteWalletWebhook=function(e,t,r){return this.blocktrailClient.delete("/wallet/"+e+"/webhook/"+t,null,null,r)},_.prototype.walletTransactions=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/transactions",t,!0,r)},_.prototype.walletAddresses=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/addresses",t,!0,r)},_.prototype.labelWalletAddress=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/address/"+t+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(e,t,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:t?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+e+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/utxos",t,!0,r)},_.prototype.allWallets=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/wallets",e,!0,t)},_.prototype.verifyMessage=function(e,t,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(t,this.network.messagePrefix,e,new Buffer(r,"base64"));o.resolve(a)}catch(e){o.reject(e)}return o.promise},_.prototype.faucetWithdrawl=function(e,t,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:e,amount:t},r)},_.prototype.sendRawTransaction=function(e,t){return this.blocktrailClient.post("/send-raw-tx",null,e,t)},_.prototype.price=function(e){return this.blocktrailClient.get("/price",null,!1,e)},t.exports=_}).call(this,e("_process"),e("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:271,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:131,"crypto-js":178,lodash:262,q:299,randombytes:306}],2:[function(e,t,r){var n=function(){};n.prototype.paginationParams=function(e){return e},n.prototype.getUrlForBlock=function(e){return"/block/"+e},n.prototype.getUrlForTransaction=function(e){return"/transaction/"+e},n.prototype.getUrlForBlockTransaction=function(e){return"/block/"+e+"/transactions"},n.prototype.getUrlForAddress=function(e){return"/address/"+e},n.prototype.getUrlForAddressTransactions=function(e){return"/address/"+e+"/transactions"},n.prototype.getUrlForAddressUnspent=function(e){return"/address/"+e+"/unspent-outputs"},n.prototype.convertBlock=function(e){return e},n.prototype.convertBlockTxs=function(e){return e},n.prototype.convertTx=function(e){return e},n.prototype.convertAddressTxs=function(e){return e},n.prototype.convertAddress=function(e){return e},n.prototype.convertAddressUnspentOutputs=function(e){return e},n.prototype.convertBatchAddressUnspentOutputs=function(e){return e},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(e,t){return t},t.exports=n},{}],3:[function(e,t,r){(function(Buffer){var r=e("util"),n=e("assert"),i=e("crypto-js"),o=e("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(e,t,r){return new Buffer(e,t).toString(r)},c=function(e,t){return function(e,t){var r=o.mnemonicToEntropy(e),n=a(r,"hex","base64"),c=i.AES.decrypt(n,t).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(e,t).toString(i.enc.Utf8)},u=function(e,t){return a(c(e,t),"base64","hex")},f=function(e,t){var r=i.AES.encrypt(e,t).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(e,t){return new Buffer(u(e,t),"hex")},s.aesDecryptMnemonicToSeedHex=u,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(e,t){return f(a(e,"hex","base64"),t)},s.aesEncryptSeedBufferToMnemonic=function(e,t){return f(e.toString("base64"),t)},s.V3Crypt={KeyDerivation:e("./keyderivation"),Encryption:e("./encryption"),EncryptionMnemonic:e("./encryption_mnemonic")},s.toSatoshi=function(e){return parseInt((e*s.COIN).toFixed(0),10)},s.toBTC=function(e){return(e/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(e){e.spreadNodeify&&e.spreadDone||(e.spreadDone=function(t,r,n){return e(t).spreadDone(r,n)},e.makePromise.prototype.spreadDone=function(e,t){return this.all().done(function(t){return e.apply(void 0,t)},t)},e.spreadNodeify=function(t,r){return e(t).spreadNodeify(r)},e.makePromise.prototype.spreadNodeify=function(t){if(!t)return this;this.then(function(r){e.nextTick(function(){t.apply(void 0,[null].concat(r))})},function(r){e.nextTick(function(){t(r)})})})},Error.extend=function(e,t){n(e,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=e,this.code=t,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var e,t=0,r=this.length-1;t<=r;++t,--r)e=this[t],this[t]=this[r],this[r]=e;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(e("q")),t.exports=s}).call(this,e("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:131,"crypto-js":178,q:299,util:360}],4:[function(e,t,r){var n=e("./wallet"),i=e("./blocktrail"),o=e("bitcoinjs-lib"),s=function(e,t){this.network=e,this.useNewCashAddr=t};function a(e,t,r){var n;try{n=o.address.toOutputScript(e,t,r)}catch(e){n=null}return n}function c(e){var t;try{t=o.script.toASM(e)}catch(e){t=null}return t}function u(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(e){var t;try{t=o.script.classifyOutput(e)}catch(e){t=null}return t}function h(e){switch(e){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+e)}}function l(e){return new Date(1e3*e).toISOString().replace(/\.000Z$/,"+0000")}function d(e){return e&&1===e.length?e[0]:e}function p(e){var t,r={};for(var n in r.size=e.vsize,r.hash=e.hash,r.block_height=e.block_height,r.time=r.block_time=l(e.block_time),r.block_hash=e.block_hash,r.confirmations=e.confirmations,r.is_coinbase=e.is_coinbase,t=r.is_coinbase?e.outputs[0].value-e.fee:e.inputs_value,r.total_input_value=t,r.total_output_value=e.outputs.reduce(function(e,t){return e+t.value},0),r.total_fee=e.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,e.inputs){var s,a,c,f,p=e.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&e)&&(r+=t),0!==(e>>>=1);)t+=t;return r});var i={chunkSize:4,paddingDummy:129},o=function(e){if(e[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-e.length%i.chunkSize)};i.encode=function(e){r(e instanceof Buffer,"Data must be provided as a Buffer");var t=o(e),i=n.entropyToMnemonic(t+e.toString("hex"));try{n.mnemonicToEntropy(i)}catch(e){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(e){r("string"==typeof e,"Mnemonic must be provided as a string");for(var t=new Buffer(n.mnemonicToEntropy(e),"hex"),i=0;t[i]===this.paddingDummy;)i++;var s=t.slice(i,t.length);if(o(s)!==t.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},t.exports=i}).call(this,e("buffer").Buffer)},{assert:24,bip39:36,buffer:131}],7:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(e,t,i){if(i=i||this.defaultIterations,r(e instanceof Buffer,"Password must be provided as a Buffer"),r(t instanceof Buffer,"Salt must be provided as a Buffer"),r(t.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),t.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(e,t,i,this.keySizeBits/8)}};t.exports=i}).call(this,e("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:131}],8:[function(e,t,r){(function(Buffer){t.exports={digest:function(e,t,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(e,t,r,n).buffer)}}}).call(this,e("buffer").Buffer)},{buffer:131}],9:[function(e,t,r){t.exports={VERSION:"3.7.22"}},{}],10:[function(e,t,r){(function(r){var n=e("./blocktrail"),i=e("lodash"),o=e("url"),s=e("querystring"),a=e("q"),c=e("create-hash"),u=e("superagent"),f=e("superagent-http-signature/index-hmac-only"),h=e("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(e){this.https=e.https,this.host=e.host,this.endpoint=e.endpoint,this.auth=e.auth,this.port=e.port,this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.contentMd5=void 0===e.contentMd5||e.contentMd5,this.params=i.defaults({},e.params),this.headers=i.defaults({},e.headers)}p.qs=function(e){var t=[],r=Object.keys(e);return r.sort(),r.forEach(function(r){var n={};n[r]=e[r],t.push(s.stringify(n))}),t.join("&")},p.prototype.request=function(e,t,r,n,s){this.deferred=a.defer(),this.callback=s||d;var u=o.parse(t,!0),f=p.qs(i.defaults({},r||{},u.query||{},this.params||{}));this.path="".concat(this.endpoint,u.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===e||"DELETE"===e?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",e,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:e,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(e){var t=this,r=e.method,n=!1;"http-signature"===e.auth&&(n=!0,delete e.auth);var o=(t.https?"https://":"http://")+e.hostname+e.path,s=u(r,o);if(!t.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(t.payload),i.forEach(e.headers,function(e,t){s.set(t,e)}),n){if(!t.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return t.deferred.reject(a),t.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:t.apiSecret,keyId:t.apiKey}))}return s.end(function(e,r){var n;if(e){var i=p.handleFailure(e.response&&e.response.body,e.status);return t.deferred.reject(i),t.callback(i,e.response&&e.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!e&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(t){e=t}return n||(n=r.text),e||200===r.status||(e=p.handleFailure(r.text,r.statusCode)),e?t.deferred.reject(e):t.deferred.resolve(n),t.callback(e,n)}),t.deferred},p.handleFailure=function(e,t){var r,n;if("object"==typeof e)r=e;else try{r=JSON.parse(e)}catch(e){}if(r){var i=r.msg||"";i||429===t&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(e){"msg"!==e&&(n[e]=r[e])})}else n=e?new Error(e):new Error("Unknown Server Error");return t&&(n.statusCode=t),p.convertError(n)},p.convertError=function(e){return e.requires_2fa&&!e.requires_email_2fa?new n.WalletMissing2FAError:e.requires_email_2fa?new n.WalletMissingEmail2FAError:e.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:e},t.exports=p}).call(this,e("_process"))},{"./blocktrail":3,_process:271,"create-hash":139,debug:204,lodash:262,q:299,querystring:305,superagent:344,"superagent-http-signature/index-hmac-only":340,url:356}],11:[function(e,t,r){var n=e("lodash"),i=e("./request"),o=e("q"),s=function(t){this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.https=t.https,this.host=t.host,this.port=t.port,this.endpoint=t.endpoint,this.btccom=!!t.btccom,void 0!==t.throttleRequestsTimeout?this.throttleRequestsTimeout=t.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+e("./pkginfo").VERSION},t.defaultHeaders))};s.prototype.throttle=function(){var e=this,t=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return t.resolve(),o.delay(e.throttleRequestsTimeout)}):(this.nextRequest=o.delay(e.throttleRequestsTimeout),t.resolve()):t.resolve(),t.promise},s.prototype.create_request=function(e){return e=n.defaults({},e,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(e)},s.prototype.post=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",e,t,r,n)})},s.prototype.put=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",e,t,r,n)})},s.prototype.get=function(e,t,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",e,t,null,n)})},s.prototype.delete=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",e,t,r,n)})},t.exports=function(e){return new s(e)}},{"./pkginfo":9,"./request":10,lodash:262,q:299}],12:[function(e,t,r){var n=e("../api_client"),i=e("lodash"),o=e("q"),s=e("async"),a=function(e){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,e);var t=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=t.network,this.settings.testnet=t.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(e,t){switch(e.toLowerCase()){case"btc":case"bitcoin":return t?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return t?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+e)}},a.prototype.setPaginationLimit=function(e){this.settings.paginationLimit=e},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(e){return Math.max(e.optimal,e.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(e){var t=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:t.settings.paginationLimit};t.client.batchAddressUnspentOutputs(e,o).then(function(e){i=i.concat(e.data),n++,r()},function(e){console.log("error happened:",e),r(e)})},function(){return null},function(e){e&&console.log("complete, but with errors",e.message);var t={};i.forEach(function(e){var r=e.address;void 0===t[r]&&(t[r]=[]),t[r].push({hash:e.hash,index:e.index,value:e.value,script_hex:e.script_hex})}),r.resolve(t)}),r.promise},a.prototype.batchAddressHasTransactions=function(e){return this.client.batchAddressHasTransactions(e).then(function(e){return e.has_transactions})},t.exports=a},{"../api_client":1,async:28,lodash:262,q:299}],13:[function(e,t,r){var n=e("../blocktrail"),i=e("superagent"),o=e("lodash"),s=e("q"),a=function(e){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===e.host&&e.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,e),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(e){var t=s.defer(),r={addrs:e.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.txid,index:e.vout,value:n.toSatoshi(e.amount),script_hex:e.scriptPubKey,confirmations:e.confirmations})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={addrs:e.join(",")};return this.postEndpoint("addrs/txs",t).then(function(e){return e.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(e){return-1===e[4]?1e5:e[4]<1e-5?1e3:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("tx/send",{rawtx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=s.defer();return i.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=s.defer();return i.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,lodash:262,q:299,superagent:344}],14:[function(e,t,r){e("../blocktrail");var n=e("superagent"),i=e("lodash"),o=e("q"),s=e("bitcoinjs-lib"),a=function(e){if(!("host"in e))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,e)};a.prototype.getBatchUnspentOutputs=function(e){var t=o.defer(),r={address:e};return this.postEndpoint("addressListUnspent",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.tx_hash,index:e.tx_pos,value:e.value,script_hex:s.address.toOutputScript(t,s.networks.bitcoincash),confirmations:1})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={address:e};return this.postEndpoint("addressHasTransactions",t).then(function(e){return e.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(e){return-1===e[4]?1e5:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("publishTx",{tx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=o.defer();return n.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=o.defer();return n.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:262,q:299,superagent:344}],15:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(e){return e?33:65},getLengthForScriptPush:function(e){if(e<75)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(e){if(e<253)return 1;var t;if(e<65535)t=2;else if(e<4294967295)t=4;else{if(!(e<0x10000000000000000))throw new Error("Size of varint too large");t=8}return 1+t},estimateMultisigStackSize:function(e,t){var r,n=[0];for(r=0;r0&&(s.map(function(e){u+=a.getLengthForVarInt(e)+e}),u+=a.getLengthForVarInt(s.length)),[c,u]},estimateInputFromScripts:function(e,t,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(e)){var c=n.script.multisig.output.decode(e);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(e)){var u=n.script.pubKey.output.decode(e);a=this.estimateP2PKStackSize(u)[0]}else{if(!n.script.pubKeyHash.output.check(e))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,t,i)},estimateUtxo:function(e,t){var r=Buffer.from(e.scriptpubkey_hex,"hex"),i=null,o=null;e.redeem_script&&("string"==typeof e.redeem_script?i=Buffer.from(e.redeem_script,"hex"):e.redeem_script instanceof Buffer&&(i=e.redeem_script)),e.witness_script&&("string"==typeof e.witness_script?o=Buffer.from(e.witness_script,"hex"):e.witness_script instanceof Buffer&&(o=e.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var u=n.script.types,f=[u.MULTISIG,u.P2PKH,u.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,t);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(e,t){var r=0,n=0;return e.map(function(e){var o=i.estimateUtxo(e);r+=40+o.scriptSig,t&&(n+=o.witness)}),t&&n>0&&(r+=2+n),r},calculateOutputsSize:function(e){var t=0;return e.map(function(e){var r=i.getLengthForVarInt(e.script.length);t+=8+r+e.script.length}),t},estimateTxWeight:function(e,t){var r=i.calculateOutputsSize(e.outs);return 3*(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!1)+i.getLengthForVarInt(e.outs.length)+r+4)+(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!0)+i.getLengthForVarInt(e.outs.length)+r+4)},estimateTxVsize:function(e,t){return parseInt(Math.ceil(i.estimateTxWeight(e,t)/4),10)}};t.exports=i}).call(this,e("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:131}],16:[function(e,t,r){var n=e("lodash"),i=e("q"),o=e("async"),s=function(e,t){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,t),this.dataClient=e};s.prototype.getUTXOs=function(e){var t=this,r={},s=i.defer();return o.eachSeries(n.chunk(e,t.settings.batchChunkSize),function(e,i){t.settings.logging&&console.log("checking batch of "+e.length+" addresses for UTXOs",e.join(",")),t.dataClient.getBatchUnspentOutputs(e).done(function(e){n.each(e,function(e,t){e.length>0&&(r[t]=e)}),i()},function(e){i(e)})},function(e){e&&console.log("error encountered",e),s.resolve(r)}),s.promise},t.exports=s},{async:28,lodash:262,q:299}],17:[function(e,t,r){(function(e){var r=!!e.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),t.exports=function(){return r}}).call(this,e("_process"))},{_process:271}],18:[function(e,t,r){(function(Buffer){var r=e("lodash"),n=e("assert"),i=e("q"),o=e("async"),s=e("bitcoinjs-lib"),a=e("bitcoinjs-message"),c=e("./blocktrail"),u=e("crypto-js"),f=e("./encryption"),h=e("./encryption_mnemonic"),l=e("./size_estimation"),d=e("bip39"),p="sign",b=function(e,t,i,o,a,c,u,f,h,l,d,p,y,v,g,m,w){this.sdk=e,this.identifier=t,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(u,function(e){return e instanceof s.HDNode})),n(r.every(h,function(e){return e instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=u,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=g,this.secret=null,this.seedHex=null};function y(e,t){var r,n;try{r=s.address.fromBech32(e,t),n=null}catch(e){n=e}if(!n&&r.prefix!==t.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function v(e,t){var r,n;e=e.toLowerCase();try{r=s.address.fromCashAddress(e),n=null}catch(e){n=e}if(n)try{r=s.address.fromCashAddress(t.cashAddrPrefix+":"+e),n=null}catch(e){n=e}if(!n&&r.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix");return[n,r]}function g(e,t){var r,n;try{r=s.address.fromBase58Check(e),n=null}catch(e){n=e}if(!n&&r.version!==t.pubKeyHash&&r.version!==t.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(e,t){var n=this,o=i.defer();return o.promise.nodeify(t),e=r.merge({},e),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(e);case b.WALLET_VERSION_V2:return n.unlockV2(e);case b.WALLET_VERSION_V3:return n.unlockV3(e);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(e){n.primaryPrivateKey=e;var t=n.primaryPrivateKey.getAddress();if(t!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+t+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(e){o.resolve(e)},function(e){o.reject(e)}),o.promise},b.prototype.unlockV1=function(e){var t=this;return e.primaryMnemonic=void 0!==e.primaryMnemonic?e.primaryMnemonic:t.primaryMnemonic,e.secretMnemonic=void 0!==e.secretMnemonic?e.secretMnemonic:t.secretMnemonic,t.sdk.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return t.primarySeed=e.primarySeed,e.primaryPrivateKey})},b.prototype.unlockV2=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(e.primarySeed)r.primarySeed=e.primarySeed;else if(e.secret)try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");e.passphrase=e.passphrase||e.password;try{if(r.secret=u.AES.decrypt(u.format.OpenSSL.parse(e.encryptedSecret),e.passphrase).toString(u.enc.Utf8),!r.secret.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){return i.when().then(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!e.primarySeed){if(e.secret)return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");return e.passphrase=e.passphrase||e.password,delete e.password,r.sdk.promisedDecrypt(new Buffer(e.encryptedSecret,"base64"),new Buffer(e.passphrase)).then(function(e){r.secret=e},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=e.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(e,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(e,n.notify.bind(n)):void 0}).then(function(e){n.resolve(e)},function(e){n.reject(e)}),n.promise},b.prototype._upgradeV2ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.recoveryEncryptedSecret=e.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),recovery_secret:e.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(e){var t=this;return i.when(null).then(function(){if(t.walletVersion===b.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(t.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!t.secret)throw new c.WalletLockedError("No secret");var r,n;if(t.walletVersion===b.WALLET_VERSION_V2)r=u.AES.encrypt(t.secret,e).toString(u.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof e)e=new Buffer(e);else if(!(e instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(t.secret,e),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.fcall(function(){return r.doPasswordChange(e).then(function(e){var t=e[0],n=e[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:t}).then(function(){return r.encryptedSecret=t,{encryptedSecret:n}})}).then(function(e){n.resolve(e)},function(e){n.reject(e)})}),n.promise},b.prototype.getAddressByPath=function(e){return this.getWalletScriptByPath(e).address},b.prototype.getRedeemScriptByPath=function(e){return this.getWalletScriptByPath(e).redeemScript},b.prototype.getWalletScriptByPath=function(e){var t,r,n=this.getPrimaryPublicKey(e),i=this.getBlocktrailPublicKey(e),o=b.deriveByPath(this.backupPublicKey,e.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),u=parseInt(e.split("/")[2]);"bitcoincash"!==this.network&&u===b.CHAIN_BTC_SEGWIT?(t=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(t))):(t=null,r=c);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:t,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[t]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+t+") is unknown to us");this.primaryPublicKeys[t]=b.deriveByPath(this.primaryPrivateKey,"M/"+t+"'","m")}var r=this.primaryPublicKeys[t];return b.deriveByPath(r,e,"M/"+t+"'")},b.prototype.getBlocktrailPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[t])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+t+") is unknown to us");var r=this.blocktrailPublicKeys[t];return b.deriveByPath(r,e,"M/"+t+"'")},b.prototype.upgradeKeyIndex=function(e,t){var n=this,o=i.defer();if(o.promise.nodeify(t),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(e).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,e,[a.toBase58(),"M/"+e+"'"]).then(function(t){return n.keyIndex=e,r.forEach(t.blocktrail_public_keys,function(e,t){n.blocktrailPublicKeys[t]=s.HDNode.fromBase58(e[0],n.network)}),n.primaryPublicKeys[e]=a,!0})),o.promise},b.prototype.getNewAddress=function(e,t){var r=this;"function"==typeof e&&(t=e,e=null);var n=i.defer();if(n.promise.spreadNodeify(t),e!==parseInt(e,10)){if(void 0!==e&&null!==e)return n.reject(new Error("Invalid chain index")),n.promise;e=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+e).then(function(e){var t,n=e.path,i=e.address;try{t=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type&&(r.bypassNewAddressCheck=!1)}catch(t){throw new c.WalletAddressError("Failed to decode address ["+e.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(e.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type){var a;try{a=r.decodeAddress(o)}catch(e){throw new c.WalletAddressError("Error while verifying address from server ["+e.message+"]")}if(a.decoded.hash.toString("hex")!==t.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var u=a.decoded.version===s.script.types.P2PKH&&t.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&t.decoded.version===r.network.scriptHash;if(!u&&!f)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+e.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier).then(function(e){return[e.confirmed,e.unconfirmed]})),t.promise},b.prototype.getInfo=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier)),t.promise},b.prototype.deleteWallet=function(e,t){"function"==typeof e&&(t=e,e=!1);var r=i.defer();if(r.promise.nodeify(t),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,e).then(function(e){return e.deleted})),r.promise},b.prototype.pay=function(e,t,r,n,o,s,a,u){var f=this;"function"==typeof t?(u=t,t=null):"function"==typeof r?(u=r,r=!1):"function"==typeof n?(u=n,n=!0):"function"==typeof o?(u=o,o=null):"function"==typeof s?(u=s,s=null):"function"==typeof a&&(u=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(u),f.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(e,t,r,n,o,a).then(function(e){return e},function(e){l.reject(e)},function(e){l.notify(e)}).spread(function(e,t){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:e.toHex(),base_transaction:e.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,t.map(function(e){return e.path}),h,s,a.prioboost,a).then(function(e){if(l.notify(b.PAY_PROGRESS_DONE),e&&e.complete&&"false"!==e.complete)return e.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(e){throw e}).then(function(e){l.resolve(e)},function(e){l.reject(e)})}),l.promise)},b.prototype.decodeAddress=function(e){return b.getAddressAndType(e,this.network,this.useNewCashAddr)},b.getAddressAndType=function(e,t,r){var n,i,o;function a(r,s){var a=r(e,t);null===a[0]?(n=a[1],i=s):o=a[0]}if(t!==s.networks.bitcoin&&t!==s.networks.testnet&&t!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in t&&r&&a(v,"cashaddr"),n||a(g,"base58"),n)return{address:e,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},b.convertPayToOutputs=function(e,t,r){var n,i=[];if(Array.isArray(e))n=function(e,t,r){if("object"!=typeof t)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(t);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=t.scriptPubKey,r.value=t.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=t.address,r.value=t.value;else{if(2!==n.length||2!==t.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=t[0],r.value=t[1]}};else{if("object"!=typeof e)throw new Error("Invalid input");n=function(e,t,r){if(r.address=e.trim(),r.value=t,r.address===b.OP_RETURN){var n=Buffer.isBuffer(t)?t:new Buffer(t,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(e).forEach(function(o){var a={};if(n(o,e[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var u=b.getAddressAndType(a.address,t,r);a.scriptPubKey=s.address.toOutputScript(u.address,t,r).toString("hex"),delete a.address}catch(e){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+e.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(e,t,n,a,u,f,h){var l=this;"function"==typeof t?(h=t,t=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof u?(h=u,u=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,u=u||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(e,l.network,l.useNewCashAddr)}catch(e){return d.reject(e),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,u,f).spread(function(e,n,f){var d,y,v=[],g=i.defer();return o.waterfall([function(t){var r=e.map(function(e){return e.value}).reduce(function(e,t){return e+t})-h.map(function(e){return e.value}).reduce(function(e,t){return e+t})-n;if(r>2*c.DUST&&r!==f)return t(new c.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));t()},function(e){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),e()},function(t){var r;for(r=0;r0)if(f<=c.DUST)f=0;else if(!t)return g.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return e(r);t=n,e()});e()},function(e){if(f>0){var n={scriptPubKey:s.address.toOutputScript(t,l.network,l.useNewCashAddr),value:f};a?v.splice(r.random(0,v.length),0,n):v.push(n)}e()},function(e){v.forEach(function(e){y.addOutput(e.scriptPubKey,e.value)}),e()},function(t){var r,n,i,o,a;for(g.notify(b.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}t()}],function(t){t?g.reject(new c.WalletSendError(t)):g.resolve([d,e])}),g.promise}))}),d.promise},b.prototype.coinSelection=function(e,t,r,n,o,s){var a;"function"==typeof t?(s=t,t=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),t=void 0===t||t,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(e,this.network,this.useNewCashAddr)}catch(e){var c=i.defer();return c.promise.nodeify(s),c.reject(e),c.promise}return this.sdk.coinSelection(this.identifier,a,t,r,n,o,s)},b.prototype.sendTransaction=function(e,t,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u=i.defer();return u.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,e,t,r,n,o,s).then(function(e){u.resolve(e)},function(e){e.requires_2fa?u.reject(new c.WalletMissing2FAError):e.message.match(/Invalid two_factor_token/)?u.reject(new c.WalletInvalid2FAError):u.reject(e)}),u.promise},b.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,t,e,r)},b.prototype.deleteWebhook=function(e,t){return"function"==typeof e&&(t=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,e,t)},b.prototype.transactions=function(e,t){return this.sdk.walletTransactions(this.identifier,e,t)},b.prototype.maxSpendable=function(e,t,r,n){return"function"==typeof e?(n=e,e=!1):"function"==typeof t?(n=t,t=null):"function"==typeof r&&(n=r,r={}),"object"==typeof e?(r=e,e=!1):"object"==typeof t&&(r=t,t=null),void 0!==(r=r||{}).allowZeroConf&&(e=r.allowZeroConf),void 0!==r.feeStrategy&&(t=r.feeStrategy),t=t||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,e,t,r,n)},b.prototype.addresses=function(e,t){return this.sdk.walletAddresses(this.identifier,e,t)},b.prototype.labelAddress=function(e,t,r){return this.sdk.labelWalletAddress(this.identifier,e,t,r)},b.prototype.utxos=function(e,t){return this.sdk.walletUTXOs(this.identifier,e,t)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(e){return e.sort(function(e,t){return e.toString("hex").localeCompare(t.toString("hex"))}),e},b.estimateIncompleteTxFee=function(e,t){var r=b.estimateIncompleteTxSize(e),n=r/1e3,i=Math.ceil(r/1e3);return t?parseInt(n*t,10):parseInt(i*c.BASE_FEE,10)},b.estimateVsizeFee=function(e,t,r){var n=l.estimateTxVsize(e,t),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},b.estimateIncompleteTxSize=function(e){var t=16;return t+=34*e.outs.length,e.ins.forEach(function(e){var r=e.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var u=s.script.decompile(a),f=u[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=u[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+e)+" using blocktrail key index: "+r+", chain: "+c),u.notify({message:"generating addresses "+p+" -> "+(p+e),increment:e,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,e,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+e+" addresses..."),u.notify({message:"starting fund discovery for "+e+" addresses",increment:e,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(c)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(c)).then(function(h){if(t.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(c=f[u],!g(e[c],t[c],r,n))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function m(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!e&&o.isError(i),c=!e&&i&&!r;if((a&&s&&w(i,r)||c)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=v,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){g(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){g(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){g(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){g(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var E=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":27}],25:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],26:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],27:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,e,n.depth)}function c(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function u(e,t){return e}function f(e,t,n){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return v(i)||(i=f(e,i,n)),i}var o=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(v(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),E(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(t);if(0===s.length){if(S(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(m(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(E(t))return h(t)}var u,w="",k=!1,A=["{","}"];(d(t)&&(k=!0,A=["[","]"]),S(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return m(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),E(t)&&(w=" "+h(t)),0!==s.length||k&&0!=t.length?n<0?m(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=k?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),x(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=b(r)?f(e,c.value,null):f(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function v(e){return"string"==typeof e}function g(e){return void 0===e}function m(e){return w(e)&&"[object RegExp]"===k(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===k(e)}function E(e){return w(e)&&("[object Error]"===k(e)||e instanceof Error)}function S(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(g(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=v,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=g,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:271,inherits:25}],28:[function(e,t,r){(function(e,r){!function(){var n,i,o={};function s(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(e){return"[object Array]"===a.call(e)},u=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=e.length&&r()}u(e,function(e){t(e,s(i))})},o.forEach=o.each,o.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r();var n=0,i=function(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1)>=e.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(e,t,r,n){l(t).apply(null,[e,r,n])},o.forEachLimit=o.eachLimit;var l=function(e){return function(t,r,n){if(n=n||function(){},!t.length||e<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=t.length)return n();for(;s=t.length?n():a())})}()}},d=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.each].concat(t))}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.eachSeries].concat(t))}},b=function(e,t,r,n){if(t=f(t,function(e,t){return{index:t,value:e}}),n){var i=[];e(t,function(e,t){r(e.value,function(r,n){i[e.index]=n,t(r)})},function(e){n(e,i)})}else e(t,function(e,t){r(e.value,function(e){t(e)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(e,t,r,n){return y(t)(e,r,n)};var y=function(e){return function(e,t){return function(){var r=Array.prototype.slice.call(arguments);return t.apply(null,[l(e)].concat(r))}}(e,b)};o.reduce=function(e,t,r,n){o.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(e,t,r,n){var i=f(e,function(e){return e}).reverse();o.reduce(i,t,r,n)},o.foldr=o.reduceRight;var v=function(e,t,r,n){var i=[];e(t=f(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r&&i.push(e),t()})},function(e){n(f(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var g=function(e,t,r,n){var i=[];e(t=f(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r||i.push(e),t()})},function(e){n(f(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.reject=d(g),o.rejectSeries=p(g);var m=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(e){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(e){r(!1)})},o.any=o.some,o.every=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(e){r(!0)})},o.all=o.every,o.sortBy=function(e,t,r){o.map(e,function(e,r){t(e,function(t,n){t?r(t):r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,f(t.sort(function(e,t){var r=e.criteria,n=t.criteria;return rn?1:0}),function(e){return e.value}))})},o.auto=function(e,t){t=t||function(){};var r=h(e),n=r.length;if(!n)return t();var i={},s=[],a=function(e){s.unshift(e)},f=function(){n--,u(s.slice(0),function(e){e()})};a(function(){if(!n){var e=t;t=function(){},e(null,i)}}),u(r,function(r){var n=c(e[r])?e[r]:[e[r]],l=function(e){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),e){var s={};u(h(i),function(e){s[e]=i[e]}),s[r]=n,t(e,s),t=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return t=function(e,t){return e&&i.hasOwnProperty(t)},n=!0,((e=d).reduce?e.reduce(t,n):(u(e,function(e,r,i){n=t(n,e,r,i)}),n))&&!i.hasOwnProperty(r);var e,t,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(e){for(var t=0;t>>1);r(t,e[o])>=0?n=o:i=o-1}return n}(e.tasks,s,r)+1,0,s),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),o.setImmediate(e.process)})}(n,e,t,i)},delete n.unshift,n},o.cargo=function(e,t){var r=!1,n=[],i={tasks:n,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,r){c(e)||(e=[e]),u(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof t?n.splice(0,t):n.splice(0,n.length),a=f(s,function(e){return e.data});i.empty&&i.empty(),r=!0,e(a,function(){r=!1;var e=arguments;u(s,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(e){return function(t){var r=Array.prototype.slice.call(arguments,1);t.apply(null,r.concat([function(t){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&u(r,function(t){console[e](t)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(e,t){var r={},n={};t=t||function(e){return e};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=t.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],e.apply(null,i.concat([function(){r[a]=arguments;var e=n[a];delete n[a];for(var t=0,i=e.length;t2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(e,t){!function r(n){if(n){if(t)return t(n);throw n}e(r)}()},void 0!==t&&t.exports?t.exports=o:void 0!==define&&define.amd?define([],function(){return o}):n.async=o}()}).call(this,e("_process"),e("timers").setImmediate)},{_process:271,timers:349}],29:[function(e,t,r){const Buffer=e("safe-buffer").Buffer;t.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);t.fill(255);for(let r=0;r>>0,u=new Uint8Array(c);for(;e[o];){let n=t[e.charCodeAt(o)];if(255===n)return;let i=0;for(let e=c-1;(0!==n||i>>0,u[e]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");a=i,o++}if(" "===e[o])return;let f=c-a;for(;f!==c&&0===u[f];)f++;const h=Buffer.allocUnsafe(s+(c-f));h.fill(0,0,s);let l=s;for(;f!==c;)h[l++]=u[f++];return h}return{encode:function(t){if(!Buffer.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";let i=0,s=0,a=0;const c=t.length;for(;a!==c&&0===t[a];)a++,i++;const u=(c-a)*o+1>>>0,f=new Uint8Array(u);for(;a!==c;){let e=t[a],n=0;for(let t=u-1;(0!==e||n>>0,f[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");s=n,a++}let h=u-s;for(;h!==u&&0===f[h];)h++;let l=n.repeat(i);for(;h0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=e.indexOf("="))>0?e.length-s:0)>0?e.length-4:e.length,t=0,n=0;t>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(e[t])<<2|r.indexOf(e[t+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(e[t])<<10|r.indexOf(e[t+1])<<4|r.indexOf(e[t+2])>>2,a.push(o>>8&255),a.push(255&o)),a},t.exports.fromByteArray=function(e){var t,n,i,o,s=e.length%3,a="";for(t=0,i=e.length-s;t>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=e[e.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(e[e.length-2]<<8)+e[e.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(e,t,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function c(e){for(var t=1,r=0;r126)throw new Error("Invalid prefix ("+e+")");t=a(t)^n>>5}t=a(t);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+e);var o=e.slice(0,n),s=e.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var u=c(o),f=[],h=0;h=s.length||f.push(d)}if(1!==u)throw new Error("Invalid checksum for "+e);return{prefix:o,words:f}},encode:function(e,t){if(e.length+7+t.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(e=e.toLowerCase()),i=e+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var u=0;u<6;++u)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(e){return u(e,8,5,!0)},fromWords:function(e){return u(e,5,8,!1)}}},{}],32:[function(e,t,r){function BigInteger(e,t,r){if(!(this instanceof BigInteger))return new BigInteger(e,t,r);null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}var n=BigInteger.prototype;n.__bigi=e("../package.json").version,BigInteger.isBigInteger=function(e,t){return e&&e.__bigi&&(!t||e.__bigi===n.__bigi)},BigInteger.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function u(e){return a.charAt(e)}function f(e,t){var r=c[e.charCodeAt(t)];return null==r?-1:r}function h(e){var t=new BigInteger;return t.fromInt(e),t}function l(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function d(e){this.m=e}function p(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function E(e){return e}function S(e){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.convert=function(e){var t=new BigInteger;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},p.prototype.revert=function(e){var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},p.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},n.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+i:this.t=0},n.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&e[n]:f(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},n.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},n.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},n.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},n.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},n.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,f=o[u-1];if(0!=f){var h=f*(1<1?o[u-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),BigInteger.ONE.dlShiftTo(u,g),g.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,v,0,u))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=t.convert(this),o=l(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},n.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=u(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var e=new BigInteger;return BigInteger.ZERO.subTo(this,e),e},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(e){var t=new BigInteger;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},n.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new p(t),this.exp(e,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},n.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},n.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},n.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},n.millerRabin=function(e){var t=this.subtract(BigInteger.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>k.length&&(e=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},n.equals=function(e){return 0==this.compareTo(e)},n.min=function(e){return this.compareTo(e)<0?this:e},n.max=function(e){return this.compareTo(e)>0?this:e},n.and=function(e){var t=new BigInteger;return this.bitwiseTo(e,b,t),t},n.or=function(e){var t=new BigInteger;return this.bitwiseTo(e,y,t),t},n.xor=function(e){var t=new BigInteger;return this.bitwiseTo(e,v,t),t},n.andNot=function(e){var t=new BigInteger;return this.bitwiseTo(e,g,t),t},n.not=function(){for(var e=new BigInteger,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=u;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,v=e.t-1,g=!0,m=new BigInteger;for(i=l(e[v])-1;v>=0;){for(i>=c?b=e[v]>>i-c&u:(b=(e[v]&(1<0&&(b|=e[v-1]>>this.DB+i-c)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),g)s[b].copyTo(o),g=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;v>=0&&0==(e[v]&1<=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(e)>=0;)a.subTo(e,a);for(;a.signum()<0;)a.addTo(e,a);return a},n.pow=function(e){return this.exp(e,new _)},n.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(t=0;t-1});n(i,"Invalid mnemonic");var o=r.map(function(e){return p(t.indexOf(e).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),u=o.slice(s),f=c.match(/(.{1,8})/g).map(function(e){return parseInt(e,2)}),l=new Buffer(f),d=h(l);return n(d===u,"Invalid mnemonic checksum"),l.toString("hex")}function f(e,t){t=t||a;var r=new Buffer(e,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(e){var r=parseInt(e,2);return t[r]}).join(" ")}function h(e){var t=i("sha256").update(e).digest(),r=8*e.length/32;return d([].slice.call(t)).slice(0,r)}function l(e){return"mnemonic"+(s.nfkd(e)||"")}function d(e){return e.map(function(e){return p(e.toString(2),"0",8)}).join("")}function p(e,t,r){for(;e.length>>24]^y[a>>16&255]^v[c>>8&255]^g[255&t]^i[p],f=e[a>>>24]^y[c>>16&255]^v[t>>8&255]^g[255&o]^i[p+1],h=e[c>>>24]^y[t>>16&255]^v[o>>8&255]^g[255&a]^i[p+2],t=e[t>>>24]^y[o>>16&255]^v[a>>8&255]^g[255&c]^i[p+3],p+=4,o=u,a=f,c=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[c>>8&255]<<8^m[255&t]^i[p++],u=o,o=a,a=c,c=t,t=u;return b}function c(e,t){var r,n=s.random.D[e],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;rt&&(e.i[t]=e.i[t]+1|0,!e.i[t]);t++);return e.F.encrypt(e.i)}function l(e,t){return function(){t.apply(e,arguments)}}void 0!==t&&t.exports&&(t.exports=s),"function"==typeof define&&define([],function(){return s}),s.cipher.aes=function(e){this.o[0][0][0]||this.t();var t,r,i,o,a=this.o[0][4],c=this.o[1],u=1;for(4!==(t=e.length)&&6!==t&&8!==t&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==e%t&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(e){return a(this,e,0)},decrypt:function(e){return a(this,e,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var e,t,r,n,i,o,s,a=this.o[0],c=this.o[1],u=a[4],f=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!u[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[t]=o,f[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},s.bitArray={bitSlice:function(e,t,r){return e=s.bitArray.R(e.slice(t/32),32-(31&t)).slice(1),r===i?e:s.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(s.bitArray.bitLength(e)!==s.bitArray.bitLength(t))return o;var r,n=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=s.bitArray.getPartial(o),n.push(s.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},s.codec.utf8String={fromBits:function(e){var t,r,n="",i=s.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],n=0;for(t=0;t>>i)>>>26),6>i?(a=e[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!t;)n+="=";return n},toBits:function(e,t){e=e.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,u=0;for(t&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(e.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),u=i<<32-a):u^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,u,1)),o}},s.codec.base64url={fromBits:function(e){return s.codec.base64.fromBits(e,1,1)},toBits:function(e){return s.codec.base64.toBits(e,1)}},s.hash.sha256=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha256.hash=function(e){return(new s.hash.sha256).update(e).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=512+t&-512;t<=e;t+=512)this.r(r.splice(0,16));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;t*t<=n;t++)if(0==n%t)continue e;8>r&&(this.l[r]=e(Math.pow(n,.5))),this.b[r]=e(Math.pow(n,1/3)),r++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?t=n[e]:(t=n[e+1&15],r=n[e+14&15],t=n[15&e]=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&e]+n[e+9&15]|0),t=t+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=u+t|0,u=c,c=a,s=t+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha512.hash=function(e){return(new s.hash.sha512).update(e).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=1024+t&-1024;t<=e;t+=1024)this.r(r.splice(0,32));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}var r,n=0,i=2;e:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue e;8>n&&(this.l[2*n]=e(Math.pow(i,.5)),this.l[2*n+1]=t(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=e(Math.pow(i,1/3)),this.b[2*n+1]=t(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=u,I=f,x=h,T=l,B=d,P=p,C=b,M=y,O=v,R=g,L=m,j=w,N=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((H=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(e-7)],z=n[2*(e-16)],F=n[2*(e-16)+1];t=t+K+((r=D+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=H)>>>0>>0?1:0),t+=z+((r+=F)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;K=P&M^~P&R;var W=C&O^~C&L,q=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];D=(D=(D=(D=j+((C<<18|P>>>14)^(C<<14|P>>>18)^(P<<23|C>>>9))+((U=N+((P<<18|C>>>14)^(P<<14|C>>>18)^(C<<23|P>>>9)))>>>0>>0?1:0))+(K+((U=U+W)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+H+((r=F+q)>>>0>>0?1:0),j=R,N=L,R=M,L=O,M=P,O=C,P=T+D+((C=B+U|0)>>>0>>0?1:0)|0,T=I,B=x,I=k,x=A,k=E,A=S,E=D+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+B|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+C|0,i[8]=p+P+(b>>>0>>0?1:0)|0,v=i[11]=v+O|0,i[10]=y+M+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+R+(m>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(e){s.mode.ccm.w.push(e)},unListenProgress:function(e){-1<(e=s.mode.ccm.w.indexOf(e))&&s.mode.ccm.w.splice(e,1)},X:function(e){var t,r=s.mode.ccm.w.slice();for(t=0;tf&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=u.clamp(r,8*(15-a)),t=s.mode.ccm.O(e,t,r,i,o,a),c=s.mode.ccm.s(e,c,r,t,o,a),u.concat(c.data,c.tag)},decrypt:function(e,t,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,u=a.bitLength(t),f=a.clamp(t,u-o),h=a.bitSlice(t,u-o);u=(u-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),t=2;4>t&&u>>>8*t;t++);return t<15-c&&(t=15-c),r=a.clamp(r,8*(15-t)),f=s.mode.ccm.s(e,f,r,h,o,t),e=s.mode.ccm.O(e,f.data,r,i,o,t),a.equal(f.tag,e)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(e,t,r,n,i,o){var a=[],c=s.bitArray,u=c.j;if(n=[c.partial(8,(t.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=e.encrypt(n),t.length)for(65279>=(r=c.bitLength(t)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,t),t=0;to||16h&&(s.mode.ccm.X(a/u),h+=l),r[3]++,i=e.encrypt(r),t[a]^=i[0],t[a+1]^=i[1],t[a+2]^=i[2],t[a+3]^=i[3];return{tag:n,data:c.clamp(t,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(e,t,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,u=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=u(e.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),e.encrypt(o(n(o(c,n(c))),a))},K:function(e){return[e[0]<<1^e[1]>>>31,e[1]<<1^e[2]>>>31,e[2]<<1^e[3]>>>31,e[3]<<1^135*(e[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(e,t,r,n,i){var o=t.slice(0);return t=s.bitArray,n=n||[],e=s.mode.gcm.s(!0,e,o,n,r,i||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,a){var c=t.slice(0),u=s.bitArray,f=u.bitLength(c);return a=a||128,i=i||[],a<=f?(t=u.bitSlice(c,f-a),c=u.bitSlice(c,0,f-a)):(t=c,c=[]),e=s.mode.gcm.s(o,e,c,i,r,a),u.equal(e.tag,t)||n(new s.exception.corrupt("gcm: tag doesn't match")),e.data},ba:function(e,t){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=t.slice(0),r=0;128>r;r++){for((n=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(e,t,r){var n,i=r.length;for(t=t.slice(0),n=0;ni&&(e=t.hash(e)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),e=new(o=o||s.misc.hmac)(e);var a,c,u,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=e.encrypt(l.concat(t,[f])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,t,u,e.length].concat(e))}break;case"string":t===i&&(t=e.length),this.f[f].update([o,this.H++,3,t,u,e.length]),this.f[f].update(e);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=t,this.g+=t,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(e){return e=this.L[e!==i?e:this.G],this.n&&this.n>=e?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=e?this.C|this.p:this.p},getProgress:function(e){return e=this.L[e||this.G],this.n>=e?1:this.g>e?1:this.g/e},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(e,t){this.D[e][this.Y++]=t},removeEventListener:function(e,t){var r,n,i=this.D[e],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===t&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=t.iter||64!==t.ts&&96!==t.ts&&128!==t.ts||128!==t.ks&&192!==t.ks&&256!==t.ks||!t.iv||2>t.iv.length||472)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}}},{"safe-buffer":322}],41:[function(e,t,r){t.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(e,t,r){var n=e("./index.json"),i={};for(var o in n){i[n[o]]=o}t.exports=i},{"./index.json":41}],43:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bech32"),i=e("cashaddress"),o=e("bs58check"),s=e("./script"),a=e("./templates"),c=e("./networks"),u=e("typeforce"),f=e("./types");function h(e){var t=o.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function l(e){var t=n.decode(e),r=n.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:Buffer.from(r)}}function d(e){return i.decode(e)}function p(e,t){u(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)}function b(e,t,r){var i=n.toWords(e);return i.unshift(t),n.encode(r,i)}function y(e,t,r){return i.encode(r,t,e)}t.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(e,t,r){if(t=t||c.bitcoin,r=r||!1,"cashAddrPrefix"in t&&r){if(s.pubKeyHash.output.check(e))return y(s.compile(e).slice(3,23),a.types.P2PKH,t.cashAddrPrefix);if(s.scriptHash.output.check(e))return y(s.compile(e).slice(2,22),a.types.P2SH,t.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(e))return p(s.compile(e).slice(3,23),t.pubKeyHash);if(s.scriptHash.output.check(e))return p(s.compile(e).slice(2,22),t.scriptHash)}if(s.witnessPubKeyHash.output.check(e))return b(s.compile(e).slice(2,22),0,t.bech32);if(s.witnessScriptHash.output.check(e))return b(s.compile(e).slice(2,34),0,t.bech32);throw new Error(s.toASM(e)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(e,t,r){var n;if("cashAddrPrefix"in(t=t||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}try{if("pubkeyhash"===(n=d(t.cashAddrPrefix+":"+e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}if(n&&n.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix")}try{if((n=h(e)).version===t.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===t.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(e){}if(!n&&"bech32"in t){try{n=l(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(e+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:127,cashaddress:134,"safe-buffer":322,typeforce:353}],44:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("merkle-lib/fastRoot"),s=e("typeforce"),a=e("./types"),c=e("varuint-bitcoin"),u=e("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var t=0;function r(r){return t+=r,e.slice(t-r,t)}function n(){var r=e.readUInt32LE(t);return t+=4,r}var i=new f;if(i.version=function(){var r=e.readInt32LE(t);return t+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===e.length)return i;function o(){var r=u.fromBuffer(e.slice(t),!0);return t+=r.byteLength(),r}var s,a=(s=c.decode(e,t),t+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&e,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-t),n},f.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},f.prototype.checkProofOfWork=function(){var e=n(this.getHash()),t=f.calculateTarget(this.bits);return e.compare(t)<=0},t.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":129,"merkle-lib/fastRoot":264,"safe-buffer":322,typeforce:353,"varuint-bitcoin":361}],45:[function(e,t,r){var n=e("pushdata-bitcoin"),i=e("varuint-bitcoin");function o(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}t.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(e,t,r){return o(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},{"pushdata-bitcoin":298,"varuint-bitcoin":361}],46:[function(e,t,r){var n=e("create-hash");function i(e){return n("rmd160").update(e).digest()}function o(e){return n("sha256").update(e).digest()}t.exports={hash160:function(e){return i(o(e))},hash256:function(e){return o(o(e))},ripemd160:i,sha1:function(e){return n("sha1").update(e).digest()},sha256:o}},{"create-hash":139}],47:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("create-hmac"),i=e("typeforce"),o=e("./types"),BigInteger=e("bigi"),s=e("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),u=e("ecurve").getCurveByName("secp256k1");function f(e,t,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(t).update(e).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(c).update(t).update(e).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(u.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=u.n.shiftRight(1);t.exports={deterministicGenerateK:f,sign:function(e,t){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=t.toBuffer(32),c=BigInteger.fromBuffer(e),l=u.n,d=u.G;return f(e,a,function(e){var i=d.multiply(e);return!u.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=e.modInverse(l).multiply(c.add(t.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(e,t,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=u.n,s=u.G,a=t.r,c=t.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(e),h=c.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!u.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:u}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":141,ecurve:218,"safe-buffer":322,typeforce:353}],48:[function(e,t,r){var n=e("./address"),i=e("./crypto"),o=e("./ecdsa"),s=e("randombytes"),a=e("typeforce"),c=e("./types"),u=e("wif"),f=e("./networks"),BigInteger=e("bigi"),h=e("ecurve"),l=o.__curve;function ECPair(e,t,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},e){if(e.signum()<=0)throw new Error("Private key must be greater than 0");if(e.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(c.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(e,t){var r=h.Point.decodeFrom(l,e);return new ECPair(null,r,{compressed:r.compressed,network:t})},ECPair.fromWIF=function(e,t){var r=u.decode(e),n=r.version;if(c.Array(t)){if(!(t=t.filter(function(e){return n===e.wif}).pop()))throw new Error("Unknown network version")}else if(t=t||f.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},ECPair.makeRandom=function(e){var t,r=(e=e||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),t=BigInteger.fromBuffer(n)}while(t.signum()<=0||t.compareTo(l.n)>=0);return new ECPair(t,null,e)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");return o.sign(e,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(e,t){return o.verify(e,t,this.Q)},t.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:218,randombytes:306,typeforce:353,wif:363}],49:[function(e,t,r){(function(Buffer){var r=e("bip66"),n=e("typeforce"),i=e("./types"),BigInteger=e("bigi");function o(e,t){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=e,this.s=t}o.parseCompact=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t!==(7&t))throw new Error("Invalid signature parameter");return{compressed:!!(4&t),i:3&t,signature:new o(BigInteger.fromBuffer(e.slice(1,33)),BigInteger.fromBuffer(e.slice(33)))}},o.fromDER=function(e){var t=r.decode(e);return new o(BigInteger.fromDERInteger(t.r),BigInteger.fromDERInteger(t.s))},o.parseScriptSignature=function(e){var t=e.readUInt8(e.length-1),r=-193&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);return{signature:o.fromDER(e.slice(0,-1)),hashType:t}},o.prototype.toCompact=function(e,t){t&&(e+=4),e+=27;var r=Buffer.alloc(65);return r.writeUInt8(e,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var e=Buffer.from(this.r.toDERInteger()),t=Buffer.from(this.s.toDERInteger());return r.encode(e,t)},o.prototype.toScriptSignature=function(e){var t=-193&e;if(t<=0||t>=4)throw new Error("Invalid hashType "+e);var r=Buffer.alloc(1);return r.writeUInt8(e,0),Buffer.concat([this.toDER(),r])},t.exports=o}).call(this,e("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:131,typeforce:353}],50:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bs58check"),i=e("./crypto"),o=e("create-hmac"),s=e("typeforce"),a=e("./types"),c=e("./networks"),BigInteger=e("bigi"),ECPair=e("./ecpair"),u=e("ecurve"),f=u.getCurveByName("secp256k1");function HDNode(e,t){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!e.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=e,this.chainCode=t,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(e,t){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:t}),i)},HDNode.fromSeedHex=function(e,t){return HDNode.fromSeedBuffer(Buffer.from(e,"hex"),t)},HDNode.fromBase58=function(e,t){var r=n.decode(e);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(t)){if(!(i=t.filter(function(e){return o===e.bip32.private||o===e.bip32.public}).pop()))throw new Error("Unknown network version")}else i=t||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=u.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var e=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},HDNode.prototype.sign=function(e){return this.keyPair.sign(e)},HDNode.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},HDNode.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(e){s(a.UInt32,e);var t=e>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),u=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(f.n)>=0)return this.derive(e+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(e+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(e+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,u);return p.depth=this.depth+1,p.index=e,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(e){return s(a.UInt31,e),this.derive(e+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(e){s(a.BIP32Path,e);var t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new Error("Not a master node");t=t.slice(1)}return t.reduce(function(e,t){var r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)},t.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:127,"create-hmac":141,ecurve:218,"safe-buffer":322,typeforce:353}],51:[function(e,t,r){t.exports={Block:e("./block"),ECPair:e("./ecpair"),ECSignature:e("./ecsignature"),HDNode:e("./hdnode"),Transaction:e("./transaction"),TransactionBuilder:e("./transaction_builder"),address:e("./address"),bufferutils:e("./bufferutils"),crypto:e("./crypto"),networks:e("./networks"),opcodes:e("bitcoin-ops"),script:e("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(e,t,r){t.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=e("pushdata-bitcoin"),o=e("typeforce"),s=e("./types"),a=e("./script_number"),c=e("bitcoin-ops"),u=e("bitcoin-ops/map"),f=c.OP_RESERVED;function h(e){return s.Buffer(e)||function(e){return s.Number(e)&&(e===c.OP_0||e>=c.OP_1&&e<=c.OP_16||e===c.OP_1NEGATE)}(e)}function l(e){return s.Array(e)&&e.every(h)}function d(e){return 0===e.length?c.OP_0:1===e.length?e[0]>=1&&e[0]<=16?f+e[0]:129===e[0]?c.OP_1NEGATE:void 0:void 0}function p(e){if(Buffer.isBuffer(e))return e;o(s.Array,e);var t=e.reduce(function(e,t){return Buffer.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+i.encodingLength(t.length)+t.length:e+1},0),r=Buffer.allocUnsafe(t),n=0;if(e.forEach(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,n),void(n+=1);n+=i.encode(r,e.length,n),e.copy(r,n),n+=e.length}else r.writeUInt8(e,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(e){if(s.Array(e))return e;o(s.Buffer,e);for(var t=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(e,r);if(null===a)return[];if((r+=a.size)+a.number>e.length)return[];var u=e.slice(r,r+a.number);r+=a.number;var f=d(u);void 0!==f?t.push(f):t.push(u)}else t.push(n),r+=1}return t}function y(e){var t=-193&e;return t>0&&t<4}t.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(e){return void 0!==c[e]?c[e]:(o(s.Hex,e),Buffer.from(e,"hex"))}))},toASM:function(e){return Buffer.isBuffer(e)&&(e=b(e)),e.map(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return u[e]}).join(" ")},toStack:function(e){return e=b(e),o(l,e),e.map(function(e){return Buffer.isBuffer(e)?e:e===c.OP_0?Buffer.allocUnsafe(0):a.encode(e-f)})},number:e("./script_number"),isCanonicalPubKey:function(e){if(!Buffer.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!Buffer.isBuffer(e)&&!!y(e[e.length-1])&&n.check(e.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var v=e("./templates");for(var g in v)t.exports[g]=v[g]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":298,"safe-buffer":322,typeforce:353}],54:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;t.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),n=Buffer.allocUnsafe(r),i=e<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":322}],55:[function(e,t,r){var n=e("../script").decompile,i=e("./multisig"),o=e("./nulldata"),s=e("./pubkey"),a=e("./pubkeyhash"),c=e("./scripthash"),u=e("./witnesspubkeyhash"),f=e("./witnessscripthash"),h=e("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};t.exports={classifyInput:function(e,t){var r=n(e);return a.input.check(r)?l.P2PKH:i.input.check(r,t)?l.MULTISIG:c.input.check(r,t)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(e){if(u.output.check(e))return l.P2WPKH;if(f.output.check(e))return l.P2WSH;if(a.output.check(e))return l.P2PKH;if(c.output.check(e))return l.P2SH;var t=n(e);return i.output.check(t)?l.MULTISIG:s.output.check(t)?l.P2PK:h.output.check(t)?l.WITNESS_COMMITMENT:o.output.check(t)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return u.input.check(r)?l.P2WPKH:f.input.check(r,t)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:u,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(e,t,r){t.exports={input:e("./input"),output:e("./output")}},{"./input":57,"./output":58}],57:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){return e===o.OP_0||n.isCanonicalSignature(e)}function a(e,t){var r=n.decompile(e);return!(r.length<2)&&(r[0]===o.OP_0&&(t?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function u(e,t){if(i([s],e),t){var r=n.multisig.output.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,e.map(function(e){return e===o.OP_0?c:e}))}function f(e,t){return i(a,e,t),e.slice(1)}t.exports={check:a,decode:function(e,t){return f(n.decompile(e),t)},decodeStack:f,encode:function(e,t){return n.compile(u(e,t))},encodeStack:u}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":322,typeforce:353}],58:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=s.OP_RESERVED;function c(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},t.exports={check:c,decode:function(e,t){var r=n.decompile(e);return o(c,r,t),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(r1&&t[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},t.exports={output:{check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Buffer,e),n.compile([s.OP_RETURN,e])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:353}],60:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function s(e){return i(n.isCanonicalSignature,e),[e]}function a(e){return i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e){return n.compile(s(e))},encodeStack:s}},{"../../script":53,typeforce:353}],62:[function(e,t,r){var n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},t.exports={check:s,decode:function(e){var t=n.decompile(e);return i(s,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:353}],63:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function s(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function a(e){return i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e,t){return n.compile(s(e,t))},encodeStack:s}},{"../../script":53,typeforce:353}],65:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 25===t.length&&t[0]===s.OP_DUP&&t[1]===s.OP_HASH160&&20===t[2]&&t[23]===s.OP_EQUALVERIFY&&t[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_DUP,s.OP_HASH160,e,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],66:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce");function o(e,t){var r=n.decompile(e);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,t),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(e,t){var r=n.compile(t);return[].concat(e,r)}function a(e){return i(o,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}o.toJSON=function(){return"scriptHash input"},t.exports={check:o,decode:function(e){var t=a(n.decompile(e));return t.redeemScriptSig=n.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:a,encode:function(e,t){var r=n.decompile(e);return n.compile(s(r,t))},encodeStack:s}},{"../../script":53,"safe-buffer":322,typeforce:353}],68:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 23===t.length&&t[0]===s.OP_HASH160&&20===t[1]&&t[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_HASH160,e,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],69:[function(e,t,r){t.exports={output:e("./output")}},{"./output":70}],70:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(e){var t=n.compile(e);return t.length>37&&t[0]===s.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},t.exports={check:c,decode:function(e){return o(c,e),n.decompile(e)[1].slice(4,36)},encode:function(e){o(i.Hash256bit,e);var t=Buffer.allocUnsafe(36);return a.copy(t,0),e.copy(t,4),n.compile([s.OP_RETURN,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":322,typeforce:353}],71:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}s.toJSON=function(){return"witnessPubKeyHash input"},t.exports={check:s,decodeStack:function(e){return i(s,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},{"../../script":53,typeforce:353}],73:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 22===t.length&&t[0]===s.OP_0&&20===t[1]}a.toJSON=function(){return"Witness pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_0,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],74:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(e,t,r){var n=e("../scripthash/input");t.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 34===t.length&&t[0]===s.OP_0&&32===t[1]}a.toJSON=function(){return"Witness scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash256bit,e),n.compile([s.OP_0,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:353}],77:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("./script"),s=e("./bufferutils"),a=e("bitcoin-ops"),c=e("typeforce"),u=e("./types"),f=e("varuint-bitcoin");function h(e){var t=e.length;return f.encodingLength(t)+t}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),g={script:d,valueBuffer:v};l.fromBuffer=function(e,t){var r=0;function n(t){return r+=t,e.slice(r-t,r)}function i(){var t=e.readUInt32LE(r);return r+=4,t}function o(){var t=s.readUInt64LE(e,r);return r+=8,t}function a(){var t=f.decode(e,r);return r+=f.decode.bytes,t}function c(){return n(a())}function u(){for(var e=a(),t=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(t).filter(function(e){return e!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(e>=this.outs.length)return y;s.outs.length=e+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(u.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,o)}return this.hashForSignature(e,t,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(e,t){return this.__toBuffer(e,t,!0)},l.prototype.__toBuffer=function(e,t,r){e||(e=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=t||0;function o(t){i+=t.copy(e,i)}function a(t){i=e.writeUInt8(t,i)}function c(t){i=e.writeUInt32LE(t,i)}function u(t){f.encode(t,e,i),i+=f.encode.bytes}function h(e){u(e.length),o(e)}n=this.version,i=e.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),u(this.ins.length),this.ins.forEach(function(e){o(e.hash),c(e.index),h(e.script),c(e.sequence)}),u(this.outs.length),this.outs.forEach(function(t){var r;t.valueBuffer?o(t.valueBuffer):(r=t.value,i=s.writeUInt64LE(e,r,i)),h(t.script)}),d&&this.ins.forEach(function(e){var t;u((t=e.witness).length),t.forEach(h)}),c(this.locktime),void 0!==t?e.slice(t,i):e},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(e,t){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[e].script=t},l.prototype.setWitness=function(e,t){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[e].witness=t},t.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,typeforce:353,"varuint-bitcoin":361}],78:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./address"),o=e("./crypto"),s=e("./script"),a=e("./networks"),c=e("bitcoin-ops"),u=e("typeforce"),f=e("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=e("./ecpair"),p=e("./ecsignature"),b=e("./transaction");function y(e){return-1!==l.indexOf(e)}function v(e){return-1!==d.indexOf(e)}function g(e,t){if(0===e.length&&0===t.length)return{};var r,n,i,a,c,u,f,l,d,p,b=!1,g=!1,m=!1,w=s.decompile(e);s.classifyInput(w,!0)===h.P2SH&&(m=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(t,!0);if(_===h.P2WSH){if(u=t[t.length-1],f=s.classifyOutput(u),g=!0,b=!0,0===e.length){if(r=s.witnessScriptHash.output.encode(o.sha256(u)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(u)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(u)))throw new Error("unsupported witness script");a=u,i=f,p=t.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=t[t.length-1],S=o.hash160(E);if(0===e.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=t}else if(c){if(!v(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(e),p=w;var k=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=t.slice(1).map(function(e){return 0===e.length?void 0:e})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=c,A.redeemScriptType=l),g&&(A.witnessScript=u,A.witnessScriptType=f),A}function m(e,t,r){u(f.Buffer,e);var n=s.decompile(e);t||(t=s.classifyOutput(e));var i=[];switch(t){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:i,scriptType:t,signatures:i.map(function(){})}}function w(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(e,t,r,n,i){var a,c,l,d,p,b,y,v,g,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(e,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=b=a.scriptType,g=i}else if(r){if(w(e,p=o.hash160(r)),!(a=m(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,g=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,y=o.sha256(i)),!(a=m(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,v=b=a.scriptType,g=i}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(c=e.prevOutType,l=e.prevOutScript,!(a=m(e.prevOutScript,e.prevOutType,t)).pubKeys)return;E=e.prevOutType===h.P2WPKH,v=c,g=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(t)),h.P2PKH,t),E=!1,v=c=h.P2PKH,g=l;if(void 0!==n||E){if(u(f.Satoshi,n),void 0!==e.value&&e.value!==n)throw new Error("Input didn't match witnessValue");e.value=n}v===h.P2WPKH&&(g=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(g))),_&&(e.redeemScript=r,e.redeemScriptType=d),S&&(e.witnessScript=i,e.witnessScriptType=b),e.pubKeys=a.pubKeys,e.signatures=a.signatures,e.signScript=g,e.signType=v,e.prevOutScript=l,e.prevOutType=c,e.witness=E}function E(e,t,r,n){if(e===h.P2PKH){if(1===t.length&&Buffer.isBuffer(t[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&Buffer.isBuffer(t[0]))return s.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map(function(e){return e||c.OP_0}),n||(t=t.filter(function(e){return e!==c.OP_0})),s.multisig.input.encodeStack(t)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(e,t){this.prevTxMap={},this.network=e||a.bitcoin,this.maximumFeeRate=t||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&void 0!==e.witness}function A(e){return e.readUInt8(e.length-1)}S.prototype.enableBitcoinCash=function(e){void 0===e&&(e=!0),this.bitcoinCash=e},S.prototype.enableBitcoinGold=function(e){void 0===e&&(e=!0),this.bitcoinGold=e},S.prototype.setLockTime=function(e){if(u(f.UInt32,e),this.inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},S.prototype.setVersion=function(e){u(f.UInt32,e),this.tx.version=e},S.fromTransaction=function(e,t,r){var n=new S(t);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(e.version),n.setLockTime(e.locktime),e.outs.forEach(function(e){n.addOutput(e.script,e.value)}),e.ins.forEach(function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness,value:e.value})}),n.inputs.forEach(function(t,n){!function(e,t,r,n,i){if(e.signType===h.MULTISIG&&e.signScript&&e.pubKeys.length!==e.signatures.length){var o=e.signatures.concat();e.signatures=e.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,u){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=t.hashForCashSignature(r,e.signScript,n,h.hashType);break;case b.FORKID_BTG:f=t.hashForGoldSignature(r,e.signScript,n,h.hashType);break;default:f=e.witness?t.hashForWitnessV0(r,e.signScript,n,h.hashType):t.hashForSignature(r,e.signScript,h.hashType)}return!!c.verify(f,h.signature)&&(o[u]=void 0,a=s,!0)}),a})}}(t,e,n,t.value,r)}),n},S.prototype.addInput=function(e,t,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof e)e=n(Buffer.from(e,"hex"));else if(e instanceof b){var s=e.outs[t];i=s.script,o=s.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(e,t,r){if(b.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=g(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!e)throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];y(r)&&(n=E(r,e.signatures,e.pubKeys,t));var o=!1;if(r===s.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");y(e.redeemScriptType)&&(n=E(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(o=!0,r=e.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,e.signatures,e.pubKeys,t);break;case s.types.P2WSH:if(!t&&!y(e.witnessScriptType))throw new Error("Impossible to sign this type");y(e.witnessScriptType)&&((i=E(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return o&&n.push(e.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,e);if(!e&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},S.prototype.sign=function(e,t,r,n,i,o){if(t.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);n=n||b.SIGHASH_ALL;var s=this.inputs[e];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=t.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(e,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(e,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(e,s.signScript,i,n):this.tx.hashForSignature(e,s.signScript,n),!s.pubKeys.some(function(e,r){if(!c.equals(e))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!t.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=t.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(e){return void 0===e.signatures||e.signatures.every(function(e){return!e||A(e)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?e<=t:void 0)})})},S.prototype.__overMaximumFees=function(e){return(this.inputs.reduce(function(e,t){return e+(t.value>>>0)},0)-this.tx.outs.reduce(function(e,t){return e+t.value},0))/e>this.maximumFeeRate},t.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":129,"safe-buffer":322,typeforce:353}],79:[function(e,t,r){var n=e("typeforce"),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(e){return n.UInt53(e)&&e<=s},UInt31:function(e){return n.UInt32(e)&&e<=i}};for(var l in n)h[l]=n[l];t.exports=h},{typeforce:353}],80:[function(e,t,r){(function(Buffer){var r=e("bs58check"),n=e("buffer-equals"),i=e("create-hash"),o=e("secp256k1"),s=e("varuint-bitcoin");function a(e,t){var r=s.encodingLength(e.length),n=new Buffer(t.length+r+e.length);return n.write(t,0),s.encode(e.length,n,t.length),n.write(e,t.length+r),function(e){var t=i("sha256").update(e).digest();return i("sha256").update(t).digest()}(n)}t.exports={magicHash:a,sign:function(e,t,r,n){var i=a(e,t),s=o.sign(i,r);return function(e,t,r){return r&&(t+=4),Buffer.concat([new Buffer([t+27]),e])}(s.signature,s.recovery,n)},verify:function(e,t,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var u,f,h=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&t),recovery:3&t,signature:e.slice(1)}}(c),l=a(e,t),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(u=d,f=i("sha256").update(u).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this,e("buffer").Buffer)},{bs58check:83,buffer:131,"buffer-equals":128,"create-hash":139,secp256k1:323,"varuint-bitcoin":361}],81:[function(e,t,r){t.exports=function(e){for(var t={},r=e.length,n=e.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var u=0;e[u]===n&&u0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===t[c]&&c=0;--u)a+=e[n[u]];return a},decodeUnsafe:o,decode:function(e){var t=o(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(e,t,r){var n=e("base-x");t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(e,t,r){(function(Buffer){"use strict";var r=e("bs58"),n=e("create-hash");function i(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}function o(e){var t=e.slice(0,-4),r=e.slice(-4),n=i(t);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return t}function s(e){var t=r.decodeUnsafe(e);if(t)return o(new Buffer(t))}t.exports={encode:function(e){var t=i(e);return r.encode(Buffer.concat([e,t],e.length+4))},decode:function(e){var t=r.decode(e),n=o(new Buffer(t));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this,e("buffer").Buffer)},{bs58:82,buffer:131,"create-hash":139}],84:[function(e,t,r){(function(r){var n=e("async"),i=e("lodash"),o=e("fs"),s=e("./branding-logo"),a=e("./qrCode-browser"),c=e("./pdf_writer"),u=e("bowser"),f=function(e,t,r,n){var o=this;t=t||{},r=r||{},n=n||{},o.identifier=e,o.backupInfo=t,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],t.blocktrailPublicKeys&&i.each(t.blocktrailPublicKeys,function(e,t){o.blocktrailPublicKeys.push({keyIndex:t,pubKey:e,path:"M/"+t+"'"})})};f.saveAsSupported=function(){if(u.browser.ios||u.browser.blackberry||u.browser.firefoxos||u.browser.webos||u.browser.bada||u.browser.tizen||u.browser.sailfish)return!1;if(u.browser.android){if(!u.browser.chrome)return!1;if(u.browser.version.split(".")[0]<41)return!1;if(u.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(e){var t=this,s={identifier:t.identifier,backupInfo:t.backupInfo,totalPubKeys:t.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(t.extraInfo,function(e,t){return"string"!=typeof e?e:{title:t,value:e}}),options:t.options};n.forEach(Object.keys(t.blocktrailPublicKeys),function(e,r){var n=t.blocktrailPublicKeys[e];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(e,t){n.qr=t,r(e)})},function(n){if(n)return e(n);var a;i.each(t.blocktrailPublicKeys,function(e){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+e.keyIndex+" ",s.pubKeysHtml+="Path: "+e.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(t){return e(t)}e(null,a(s))})},f.prototype.generatePDF=function(e){var t=this,r=new c,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(e){t.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(t.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+t.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(t.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),t.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.primaryMnemonic)})}),t.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.backupMnemonic)})}),t.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.encryptedPrimarySeed)})}),t.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.backupSeed)})}),t.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(t.blocktrailPublicKeys),function(e,r){var n=t.blocktrailPublicKeys[e];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(e,t){n.qr=t,r(e)})},function(n){if(n)return e(n);Object.keys(t.blocktrailPublicKeys).forEach(function(e,n){var i=t.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),t.extraInfo&&i.each(t.extraInfo,function(e,t){var n,i;"string"!=typeof e?(n=e.title,i=e.subtitle,e=e.value):n=t,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(e)})})}),e()})):e()},function(e){t.backupInfo.encryptedSecret&&t.options.page2&&(t.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(t.backupInfo.encryptedSecret)})})),e()},function(e){t.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),e()}],function(t){if(t)return e(t);e(null,r.doc)})}catch(t){return void e(t)}},t.exports=f}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:238,lodash:89}],85:[function(e,t,r){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(e,t,r){var n=function(e){var t=jsPDF;if(void 0===t)throw new Error("jsPDF not found");e=e||{},this.doc=new t("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==e.margin?e.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(e,t){this.font.push(e),this.doc.setFont(this.font[this.font.length-1]),t&&t(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(e,t,r){this.fontSize.push(e),this.lineMargin.push(t),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(e,t){this.textColor.push(e),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),t&&t(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(e,t,r,n){var i=this;"function"==typeof t?(n=t,t=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(e,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(e){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(e,i.margin+(t||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(t||0),i.yPos);n&&n()},n.prototype.HR=function(e,t){var r=e||0,n=this.docWidth-this.margin-this.margin-(e||0),i=t||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(e,t,r,n){this.doc.line(e+this.margin,t+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(e,t,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(e,t,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(e){this.yPos+=e||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(e){this.setFontSize(24,[12,8],e)},n.prototype.FONT_SIZE_SUBHEADER=function(e){this.setFontSize(18,[8,5],e)},n.prototype.FONT_SIZE_NORMAL=function(e){this.setFontSize(13,[2,2],e)},n.prototype.FONT_SIZE_SMALL=function(e){this.setFontSize(10,[2,2],e)},n.prototype.TEXT_COLOR_BLACK=function(e){this.setTextColor([0,0,0],e)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(e){this.setTextColor([150,150,150],e)},n.prototype.TEXT_COLOR_GREY=function(e){this.setTextColor([51,51,51],e)},n.prototype.TEXT_COLOR_RED=function(e){this.setTextColor([255,0,0],e)},t.exports=n},{}],87:[function(e,t,r){var n=e("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(e,t,r){this.init(),this.qrcodedraw.draw(this.canvasEl,e,t,r)},i.prototype.toDataURL=function(e,t,r){this.draw(e,t,function(e,t){if(e)return r?r(e):null;r(null,t.toDataURL("image/jpeg"))})},t.exports=new i},{"qrcode-canvas":301}],88:[function(e,t,r){t.exports=e("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(e,t,r){(function(e){(function(){var n,i,o,s="3.1.0",a=1,c=2,u=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,v="...",g=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",I="[object Array]",x="[object Boolean]",T="[object Date]",B="[object Error]",P="[object Function]",C="[object Number]",M="[object Object]",O="[object RegExp]",R="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",N="[object Float64Array]",D="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",W="[object Uint32Array]",q=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,J=RegExp(Y.source),Z=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,ee=/<%=([\s\S]+?)%>/g,te=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ne=/^\s*function[ \n\r\t]+\w/,ie=/^0[xX]/,oe=/^\[object .+?Constructor\]$/,se=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ae=/($^)/,ce=/[.*+?^${}()|[\]\/\\]/g,ue=RegExp(ce.source),fe=/\bthis\b/,he=/['\n\r\u2028\u2029\\]/g,le=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),de=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pe=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],be=-1,ye={};ye[j]=ye[N]=ye[D]=ye[U]=ye[H]=ye[K]=ye[z]=ye[F]=ye[W]=!0,ye[A]=ye[I]=ye[L]=ye[x]=ye[T]=ye[B]=ye[P]=ye["[object Map]"]=ye[C]=ye[M]=ye[O]=ye["[object Set]"]=ye[R]=ye["[object WeakMap]"]=!1;var ve={};ve[A]=ve[I]=ve[L]=ve[x]=ve[T]=ve[j]=ve[N]=ve[D]=ve[U]=ve[H]=ve[C]=ve[M]=ve[O]=ve[R]=ve[K]=ve[z]=ve[F]=ve[W]=!0,ve[B]=ve[P]=ve["[object Map]"]=ve["[object Set]"]=ve["[object WeakMap]"]=!1;var ge={leading:!1,maxWait:0,trailing:!1},me={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},we={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_e={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ee={function:!0,object:!0},Se={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ke=Ee[typeof window]&&window!==(this&&this.window)?window:this,Ae=Ee[typeof r]&&r&&!r.nodeType&&r,Ie=Ee[typeof t]&&t&&!t.nodeType&&t,xe=Ae&&Ie&&"object"==typeof e&&e;!xe||xe.global!==xe&&xe.window!==xe&&xe.self!==xe||(ke=xe);var Te=Ie&&Ie.exports===Ae&&Ae;function Be(e,t){if(e!==t){var r=e==e,n=t==t;if(e>t||!r||void 0===e&&n)return 1;if(e-1;);return r}function Le(e,t){for(var r=e.length;r--&&t.indexOf(e.charAt(r))>-1;);return r}function je(e,t){return Be(e.criteria,t.criteria)||e.index-t.index}function Ne(e,t){for(var r=-1,n=e.criteria,i=t.criteria,o=n.length;++r=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function We(e,t){for(var r=-1,n=e.length,i=-1,o=[];++r>>1,Ct=bt?bt.BYTES_PER_ELEMENT:0,Mt=we.pow(2,53)-1,Ot=pt&&new pt;function Rt(e){if(ze(e)&&!Wn(e)){if(e instanceof Lt)return e;if(Ze.call(e,"__wrapped__"))return new Lt(e.__wrapped__,e.__chain__,Kt(e.__actions__))}return new Lt(e)}function Lt(e,t,r){this.__actions__=r||[],this.__chain__=!!t,this.__wrapped__=e}var jt=Rt.support={};function Nt(e){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=xt,this.views=null,this.wrapped=e}function Dt(){this.__data__={}}function Ut(e){var t=e?e.length:0;for(this.data={hash:vt(null),set:new ft};t--;)this.push(e[t])}function Ht(e,t){var r=e.data;return("string"==typeof t||Xn(t)?r.set.has(t):r.hash[t])?0:-1}function Kt(e,t){var n=-1,i=e.length;for(t||(t=r(i));++nn&&(n=i)}return n}function Gt(e,t,r,n){var i=-1,o=e.length;for(n&&o&&(r=e[++i]);++i=200&&Ur(t),c=t.length;a&&(o=Ht,s=!1,t=a);e:for(;++iu))return!1;for(;h&&++co?0:o+t),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),c=[];a?(n=Ht,o=!1):(s=!1,a=t?[]:c);e:for(;++r>>1,s=e[o];(r?s<=t:s3&&Jr(arguments[1],arguments[2],arguments[3])&&(t=2),t>3&&"function"==typeof arguments[t-2])var n=Or(arguments[--t-1],arguments[t--],5);else t>2&&"function"==typeof arguments[t-1]&&(n=arguments[--t]);for(var i=0;++ii)||c===n&&c===o)&&(i=c,o=e)}),o}(r,n,t)}}function Fr(e,t,i,o,s,p,y,v,g,m){var w=t&b,_=t&a,E=t&c,S=t&f,k=t&u,A=t&h,I=!E&&Kr(e),x=e;return function u(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=u.placeholder,B=We(b,T);if((f-=B.length)=(t=+t)||!gt(t))return"";var i=t-n;return pi(r=null==r?" ":r+"",it(i/r.length)).slice(0,i)}function qr(e,t,n,i,o,s,f,y){var v=t&c;if(!v&&!Yn(e))throw new Ie(S);var g=i?i.length:0;if(g||(t&=~(l|d),i=o=null),g-=o?o.length:0,t&d){var m=i,w=o;i=o=null}var _=!v&&Gr(e),E=[e,t,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(e,t){var r=e[1],n=t[1],i=r|n,o=b|p,s=a|c,f=o|s|u|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?e:t)[7],v=(l?e:t)[8],g=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&e%1==0&&e-1&&e%1==0&&e<=Mt}function Qr(e){return e==e&&(0===e?1/e>0:!Xn(e))}function $r(e,t){e=cn(e);for(var r=-1,n=t.length,i={};++r0){if(++tn>=g)return e}else tn=0;return Ar(e,t)});function on(e){var t,r;return Rt.support,!(!ze(e)||$e.call(e)!=M||!(Ze.call(e,"constructor")||"function"!=typeof(t=e.constructor)||t instanceof t))&&(pr(e,function(e,t){r=t}),void 0===r||Ze.call(e,r))}function sn(e){for(var t=si(e),r=t.length,n=r&&e.length,i=Rt.support,o=n&&Zr(n)&&(Wn(e)||i.nonEnumArgs&&Fn(e)),s=-1,a=[];++s>>0,i=r(n);++t-1:Yr(e,t,r)>-1)}var _n=Nr(function(e,t,r){Ze.call(e,r)?++e[r]:e[r]=1});function En(e,t,r){var n=Wn(e)?Ft:cr;return"function"==typeof t&&void 0===r||(t=Vr(t,r,3)),n(e,t)}function Sn(e,t,r){return(Wn(e)?Wt:ur)(e,t=Vr(t,r,3))}function kn(e,t,r){if(Wn(e)){var i=hn(e,t,r);return i>-1?e[i]:n}return fr(e,t=Vr(t,r,3),sr)}function An(e,t,r){return"function"==typeof t&&void 0===r&&Wn(e)?zt(e,t):sr(e,Or(t,r,3))}function In(e,t,r){return"function"==typeof t&&void 0===r&&Wn(e)?function(e,t){for(var r=e.length;r--&&!1!==t(e[r],r,e););return e}(e,t):ar(e,Or(t,r,3))}var xn=Nr(function(e,t,r){Ze.call(e,r)?e[r].push(t):e[r]=[t]}),Tn=Nr(function(e,t,r){e[r]=t});function Bn(e,t,r){return(Wn(e)?qt:wr)(e,t=Vr(t,r,3))}var Pn=zr(Vt),Cn=zr(function(e){for(var t=-1,r=e.length,n=xt;++t0?e[Sr(0,i-1)]:n}var o=jn(e);return o.length=_t(t<0?0:+t||0,o.length),o}function jn(e){for(var t=-1,n=(e=an(e)).length,i=r(n);++t0?r=t.apply(this,arguments):t=null,r}}function Hn(e,t,r){var i,o,s,a,c,u,f,h=0,l=!1,d=!0;if(!Yn(e))throw new Ie(S);if(t=t<0?0:t,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&wt(+r.maxWait||0,t),d="trailing"in r?r.trailing:d);function b(){var r=t-(Dn()-a);if(r<=0||r>t){o&&ot(o);var l=f;o=u=f=n,l&&(h=Dn(),s=e.apply(c,i),u||o||(i=c=null))}else u=ht(b,r)}function y(){u&&ot(u),o=u=f=n,(d||l!==t)&&(h=Dn(),s=e.apply(c,i),u||o||(i=c=null))}function v(){if(i=arguments,a=Dn(),c=this,f=d&&(u||!p),!1===l)var r=p&&!u;else{o||p||(h=a);var n=l-(a-h),v=n<=0||n>l;v?(o&&(o=ot(o)),h=a,s=e.apply(c,i)):o||(o=ht(y,n))}return v&&u?u=ot(u):u||t===l||(u=ht(b,t)),r&&(v=!0,s=e.apply(c,i)),!v||u||o||(i=c=null),s}return v.cancel=function(){u&&ot(u),o&&ot(o),o=u=f=n},v}function Kn(){var e=arguments,t=e.length-1;if(t<0)return function(){};if(!Ft(e,Yn))throw new Ie(S);return function(){for(var r=t,n=e[r].apply(this,arguments);r--;)n=e[r].call(this,n);return n}}function zn(e,t){if(!Yn(e)||t&&!Yn(t))throw new Ie(S);var r=function(){var n=r.cache,i=t?t.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=e.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function Fn(e){return Zr(ze(e)?e.length:n)&&$e.call(e)==A||!1}var Wn=yt||function(e){return ze(e)&&Zr(e.length)&&$e.call(e)==I||!1};function qn(e){return e&&1===e.nodeType&&ze(e)&&$e.call(e).indexOf("Element")>-1||!1}function Vn(e){return ze(e)&&"string"==typeof e.message&&$e.call(e)==B||!1}jt.dom||(qn=function(e){return e&&1===e.nodeType&&ze(e)&&!Qn(e)||!1});var Gn=St||function(e){return"number"==typeof e&>(e)};function Yn(e){return"function"==typeof e||!1}function Xn(e){var t=typeof e;return"function"==t||e&&"object"==t||!1}function Jn(e){return null!=e&&($e.call(e)==P?tt.test(Xe.call(e)):ze(e)&&oe.test(e)||!1)}function Zn(e){return"number"==typeof e||ze(e)&&$e.call(e)==C||!1}(Yn(/x/)||dt&&!Yn(dt))&&(Yn=function(e){return $e.call(e)==P});var Qn=at?function(e){if(!e||$e.call(e)!=M)return!1;var t=e.valueOf,r=Jn(t)&&(r=at(t))&&at(r);return r?e==r||at(e)==r:on(e)}:on;function $n(e){return ze(e)&&$e.call(e)==O||!1}function ei(e){return"string"==typeof e||ze(e)&&$e.call(e)==R||!1}function ti(e){return ze(e)&&Zr(e.length)&&ye[$e.call(e)]||!1}function ri(e){return er(e,si(e))}var ni=Dr(Qt);function ii(e){return vr(e,si(e))}var oi=mt?function(e){if(e)var t=e.constructor,r=e.length;return"function"==typeof t&&t.prototype===e||"function"!=typeof e&&r&&Zr(r)?sn(e):Xn(e)?mt(e):[]}:sn;function si(e){if(null==e)return[];Xn(e)||(e=Ee(e));var t=e.length;t=t&&Zr(t)&&(Wn(e)||jt.nonEnumArgs&&Fn(e))&&t||0;for(var n=e.constructor,i=-1,o="function"==typeof n&&n.prototype==e,s=r(t),a=t>0;++i2){var i=Ir(arguments,2),o=We(i,e.placeholder);n|=l}return qr(t,n,r,i,o)},Rt.bindAll=function(e){return function(e,t){for(var r=-1,n=t.length;++r1?hr(arguments,!1,!1,1):ii(e))},Rt.bindKey=function e(t,r){var n=a|c;if(arguments.length>2){var i=Ir(arguments,2),o=We(i,e.placeholder);n|=l}return qr(r,n,t,i,o)},Rt.callback=_i,Rt.chain=gn,Rt.chunk=function(e,t,n){t=(n?Jr(e,t,n):null==t)?1:wt(+t||1,1);for(var i=0,o=e?e.length:0,s=-1,a=r(it(o/t));i=120&&Ur(t&&s)))}r=e.length;var a=e[0],c=-1,u=a?a.length:0,f=[],h=n[0];e:for(;++c-1;)lt.call(e,i,1);return e},Rt.pullAt=function(e){return function(e,t){var r=t.length,n=$t(e,t);for(t.sort(Be);r--;){var i=parseFloat(t[r]);if(i!=o&&Xr(i)){var o=i;lt.call(e,i,1)}}return n}(e||[],hr(arguments,!1,!1,1))},Rt.range=function(e,t,n){n&&Jr(e,t,n)&&(t=n=null),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var i=-1,o=wt(it((t-e)/(n||1)),0),s=r(o);++i3&&Jr(t[1],t[2],t[3])&&(t=[e,t[1]]);var i=-1,o=e?e.length:0,s=hr(t,!1,!1,1),a=Zr(o)?r(o):[];return sr(e,function(e,t,o){for(var c=s.length,u=r(c);c--;)u[c]=null==e?n:e[s[c]];a[++i]={criteria:u,index:i,value:e}}),Ce(a,Ne)},Rt.take=function(e,t,r){return e&&e.length?((r?Jr(e,t,r):null==t)&&(t=1),Ir(e,0,t<0?0:t)):[]},Rt.takeRight=function(e,t,r){var n=e?e.length:0;return n?((r?Jr(e,t,r):null==t)&&(t=1),Ir(e,(t=n-(+t||0))<0?0:t)):[]},Rt.takeRightWhile=function(e,t,r){var n=e?e.length:0;if(!n)return[];for(t=Vr(t,r,3);n--&&t(e[n],n,e););return Ir(e,n+1)},Rt.takeWhile=function(e,t,r){var n=e?e.length:0;if(!n)return[];var i=-1;for(t=Vr(t,r,3);++i=0&&e.indexOf(t,r)==r},Rt.escape=function(e){return(e=Me(e))&&Z.test(e)?e.replace(X,Ue):e},Rt.escapeRegExp=hi,Rt.every=En,Rt.find=kn,Rt.findIndex=hn,Rt.findKey=function(e,t,r){return fr(e,t=Vr(t,r,3),br,!0)},Rt.findLast=function(e,t,r){return fr(e,t=Vr(t,r,3),ar)},Rt.findLastIndex=function(e,t,r){var n=e?e.length:0;for(t=Vr(t,r,3);n--;)if(t(e[n],n,e))return n;return-1},Rt.findLastKey=function(e,t,r){return fr(e,t=Vr(t,r,3),yr,!0)},Rt.findWhere=function(e,t){return kn(e,_r(t))},Rt.first=ln,Rt.has=function(e,t){return!!e&&Ze.call(e,t)},Rt.identity=Si,Rt.includes=wn,Rt.indexOf=dn,Rt.isArguments=Fn,Rt.isArray=Wn,Rt.isBoolean=function(e){return!0===e||!1===e||ze(e)&&$e.call(e)==x||!1},Rt.isDate=function(e){return ze(e)&&$e.call(e)==T||!1},Rt.isElement=qn,Rt.isEmpty=function(e){if(null==e)return!0;var t=e.length;return Zr(t)&&(Wn(e)||ei(e)||Fn(e)||ze(e)&&Yn(e.splice))?!t:!oi(e).length},Rt.isEqual=function(e,t,r,i){if(!(r="function"==typeof r&&Or(r,i,3))&&Qr(e)&&Qr(t))return e===t;var o=r?r(e,t):n;return void 0===o?gr(e,t,r):!!o},Rt.isError=Vn,Rt.isFinite=Gn,Rt.isFunction=Yn,Rt.isMatch=function(e,t,n,i){var o=oi(t),s=o.length;if(!(n="function"==typeof n&&Or(n,i,3))&&1==s){var a=o[0],c=t[a];if(Qr(c))return null!=e&&c===e[a]&&Ze.call(e,a)}for(var u=r(s),f=r(s);s--;)c=u[s]=t[o[s]],f[s]=Qr(c);return mr(e,o,u,f,n)},Rt.isNaN=function(e){return Zn(e)&&e!=+e},Rt.isNative=Jn,Rt.isNull=function(e){return null===e},Rt.isNumber=Zn,Rt.isObject=Xn,Rt.isPlainObject=Qn,Rt.isRegExp=$n,Rt.isString=ei,Rt.isTypedArray=ti,Rt.isUndefined=function(e){return void 0===e},Rt.kebabCase=li,Rt.last=function(e){var t=e?e.length:0;return t?e[t-1]:n},Rt.lastIndexOf=function(e,t,r){var n=e?e.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?wt(n+r,0):_t(r||0,n-1))+1;else if(r){var o=e[i=Cr(e,t,!0)-1];return(t==t?t===o:o!=o)?i:-1}if(t!=t)return Ke(e,i,!0);for(;i--;)if(e[i]===t)return i;return-1},Rt.max=Pn,Rt.min=Cn,Rt.noConflict=function(){return t._=et,this},Rt.noop=Ii,Rt.now=Dn,Rt.pad=function(e,t,r){t=+t;var n=(e=Me(e)).length;if(n>=t||!gt(t))return e;var i=(t-n)/2,o=st(i);return(r=Wr("",it(i),r)).slice(0,o)+e+r},Rt.padLeft=function(e,t,r){return(e=Me(e))&&Wr(e,t,r)+e},Rt.padRight=function(e,t,r){return(e=Me(e))&&e+Wr(e,t,r)},Rt.parseInt=di,Rt.random=function(e,t,r){r&&Jr(e,t,r)&&(t=r=null);var n=null==e,i=null==t;if(null==r&&(i&&"boolean"==typeof e?(r=e,e=1):"boolean"==typeof t&&(r=t,i=!0)),n&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,r||e%1||t%1){var o=At();return _t(e+o*(t-e+parseFloat("1e-"+((o+"").length-1))),t)}return Sr(e,t)},Rt.reduce=On,Rt.reduceRight=Rn,Rt.repeat=pi,Rt.result=function(e,t,r){var i=null==e?n:e[t];return void 0===i&&(i=r),Yn(i)?i.call(e):i},Rt.runInContext=e,Rt.size=function(e){var t=e?e.length:0;return Zr(t)?t:oi(e).length},Rt.snakeCase=yi,Rt.some=Nn,Rt.sortedIndex=function(e,t,r,n){var i=Vr(r);return i===tr&&null==r?Cr(e,t):Mr(e,t,i(r,n,1))},Rt.sortedLastIndex=function(e,t,r,n){var i=Vr(r);return i===tr&&null==r?Cr(e,t,!0):Mr(e,t,i(r,n,1),!0)},Rt.startCase=vi,Rt.startsWith=function(e,t,r){return e=Me(e),r=null==r?0:_t(r<0?0:+r||0,e.length),e.lastIndexOf(t,r)==r},Rt.template=function(e,t,r){var i=Rt.templateSettings;r&&Jr(e,t,r)&&(t=r=null),e=Me(e);var o,s,a=Qt(Qt({},(t=Qt(Qt({},r||t),i,Zt)).imports),i.imports,Zt),c=oi(a),u=Br(a,c),f=0,h=t.interpolate||ae,l="__p += '",d=Se((t.escape||ae).source+"|"+h.source+"|"+(h===ee?te:ae).source+"|"+(t.evaluate||ae).source+"|$","g"),p="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++be+"]")+"\n";e.replace(d,function(t,r,n,i,a,c){return n||(n=i),l+=e.slice(f,c).replace(he,He),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=c+t.length,t}),l+="';\n";var b=t.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(q,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return me(c,p+"return "+l).apply(n,u)});if(y.source=l,Vn(y))throw y;return y},Rt.trim=gi,Rt.trimLeft=function(e,t,r){var n=e;return(e=Me(e))?(r?Jr(n,t,r):null==t)?e.slice(qe(e)):e.slice(Re(e,t+"")):e},Rt.trimRight=function(e,t,r){var n=e;return(e=Me(e))?(r?Jr(n,t,r):null==t)?e.slice(0,Ve(e)+1):e.slice(0,Le(e,t+"")+1):e},Rt.trunc=function(e,t,r){r&&Jr(e,t,r)&&(t=null);var n=y,i=v;if(null!=t)if(Xn(t)){var o="separator"in t?t.separator:o;n="length"in t?+t.length||0:n,i="omission"in t?Me(t.omission):i}else n=+t||0;if(n>=(e=Me(e)).length)return e;var s=n-i.length;if(s<1)return i;var a=e.slice(0,s);if(null==o)return a+i;if($n(o)){if(e.slice(s).search(o)){var c,u,f=e.slice(0,s);for(o.global||(o=Se(o.source,(re.exec(o)||"")+"g")),o.lastIndex=0;c=o.exec(f);)u=c.index;a=a.slice(0,null==u?s:u)}}else if(e.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Rt.unescape=function(e){return(e=Me(e))&&J.test(e)?e.replace(Y,Ge):e},Rt.uniqueId=function(e){var t=++Qe;return Me(e)+t},Rt.words=mi,Rt.all=En,Rt.any=Nn,Rt.contains=wn,Rt.detect=kn,Rt.foldl=On,Rt.foldr=Rn,Rt.head=ln,Rt.include=wn,Rt.inject=On,Ai(Rt,(bi={},br(Rt,function(e,t){Rt.prototype[t]||(bi[t]=e)}),bi),!1),Rt.sample=Ln,Rt.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return Ln(t,e)}):Ln(this.value())},Rt.VERSION=s,zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){Rt[e].placeholder=Rt}),zt(["filter","map","takeWhile"],function(e,t){var r=t==w;Nt.prototype[e]=function(e,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||t==E&&i.dir<0,s.push({iteratee:Vr(e,n,3),type:t}),i}}),zt(["drop","take"],function(e,t){var r=e+"Count",n=e+"While";Nt.prototype[e]=function(n){n=null==n?1:wt(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=t?_t(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:e+(i.dir<0?"Right":"")});return i},Nt.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()},Nt.prototype[e+"RightWhile"]=function(e,t){return this.reverse()[n](e,t).reverse()}}),zt(["first","last"],function(e,t){var r="take"+(t?"Right":"");Nt.prototype[e]=function(){return this[r](1).value()[0]}}),zt(["initial","rest"],function(e,t){var r="drop"+(t?"":"Right");Nt.prototype[e]=function(){return this[r](1)}}),zt(["pluck","where"],function(e,t){var r=t?"filter":"map",n=t?_r:Er;Nt.prototype[e]=function(e){return this[r](n(t?e:e+""))}}),Nt.prototype.dropWhile=function(e,t){var r,n,i=this.dir<0;return e=Vr(e,t,3),this.filter(function(t,o,s){return r=r&&(i?on),n=o,r||(r=!e(t,o,s))})},Nt.prototype.reject=function(e,t){return e=Vr(e,t,3),this.filter(function(t,r,n){return!e(t,r,n)})},Nt.prototype.slice=function(e,t){var r=(e=null==e?0:+e||0)<0?this.takeRight(-e):this.drop(e);return void 0!==t&&(r=(t=+t||0)<0?r.dropRight(-t):r.take(t-e)),r},br(Nt.prototype,function(e,t){var r=Rt[t],n=/^(?:first|last)$/.test(t);Rt.prototype[t]=function(){var t=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=t instanceof Nt,c=a&&!s;if(n&&!o)return c?e.call(t):r.call(Rt,this.value());var u=function(e){var t=[e];return ct.apply(t,i),r.apply(Rt,t)};if(a||Wn(t)){var f=c?t:new Nt(this),h=e.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[u],thisArg:Rt}),new Lt(h,o)}return this.thru(u)}}),zt(["concat","join","pop","push","shift","sort","splice","unshift"],function(e){var t=xe[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(e);Rt.prototype[e]=function(){var e=arguments;return n&&!this.__chain__?t.apply(this.value(),e):this[r](function(r){return t.apply(r,e)})}}),Nt.prototype.clone=function(){var e=this.actions,t=this.iteratees,r=this.views,n=new Nt(this.wrapped);return n.actions=e?Kt(e):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=t?Kt(t):null,n.takeCount=this.takeCount,n.views=r?Kt(r):null,n},Nt.prototype.reverse=function(){if(this.filtered){var e=new Nt(this);e.dir=-1,e.filtered=!0}else(e=this.clone()).dir*=-1;return e},Nt.prototype.value=function(){var e=this.wrapped.value();if(!Wn(e))return Pr(e,this.actions);var t=this.dir,r=t<0,n=function(e,t,r){for(var n=-1,i=r?r.length:0;++n=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function a(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.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)},o.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)},o.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=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.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 o=e.length-r,s=o%n,c=Math.min(o,o-s)+r,u=0,f=r;f1&&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?""};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],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 h(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],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,t.length-1),d=Math.max(0,u-e.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-h.length]+h+r:h+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.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],d=f[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).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")},o.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},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==Buffer),this.toArrayLike(Buffer,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,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,a,c="le"===t,u=new e(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a=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},o.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},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.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;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.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<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.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 o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],B=8191&T,P=T>>>13,C=0|s[7],M=8191&C,O=C>>>13,R=0|s[8],L=8191&R,j=R>>>13,N=0|s[9],D=8191&N,U=N>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],W=8191&F,q=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,fe=0|a[8],he=8191&fe,le=fe>>>13,de=0|a[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;u=((o=Math.imul(l,z))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var ve=(u+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,q)|0)+Math.imul(l,W)|0))<<13)|0;u=((o=o+Math.imul(l,q)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,q)|0;var ge=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,W)|0,i=(i=i+Math.imul(v,q)|0)+Math.imul(g,W)|0,o=o+Math.imul(g,q)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var me=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;u=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,q)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var we=(u+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,$)|0))<<13)|0;u=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,q)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,q)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0;var _e=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;u=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(B,K),i=(i=Math.imul(B,z))+Math.imul(P,K)|0,o=Math.imul(P,z),n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,q)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,q)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(g,$)|0,o=o+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,o=o+Math.imul(b,ne)|0;var Ee=(u+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(l,oe)|0))<<13)|0;u=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(O,K)|0,o=Math.imul(O,z),n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,q)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,q)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0;var Se=(u+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(l,ce)|0))<<13)|0;u=((o=o+Math.imul(l,ue)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(M,W)|0,i=(i=i+Math.imul(M,q)|0)+Math.imul(O,W)|0,o=o+Math.imul(O,q)|0,n=n+Math.imul(B,G)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(b,ce)|0,o=o+Math.imul(b,ue)|0;var ke=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;u=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,q)|0)+Math.imul(j,W)|0,o=o+Math.imul(j,q)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,Y)|0,n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,Z)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(v,ce)|0,i=(i=i+Math.imul(v,ue)|0)+Math.imul(g,ce)|0,o=o+Math.imul(g,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var Ae=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;u=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,W),i=(i=Math.imul(D,q))+Math.imul(U,W)|0,o=Math.imul(U,q),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Z)|0,n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,ue)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(g,he)|0,o=o+Math.imul(g,le)|0;var Ie=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;u=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,n=n+Math.imul(S,ce)|0,i=(i=i+Math.imul(S,ue)|0)+Math.imul(k,ce)|0,o=o+Math.imul(k,ue)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var xe=(u+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,be)|0)+Math.imul(g,pe)|0))<<13)|0;u=((o=o+Math.imul(g,be)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,se)|0,n=n+Math.imul(I,ce)|0,i=(i=i+Math.imul(I,ue)|0)+Math.imul(x,ce)|0,o=o+Math.imul(x,ue)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,le)|0;var Te=(u+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,$),i=(i=Math.imul(D,ee))+Math.imul(U,$)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,se)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,se)|0,n=n+Math.imul(B,ce)|0,i=(i=i+Math.imul(B,ue)|0)+Math.imul(P,ce)|0,o=o+Math.imul(P,ue)|0,n=n+Math.imul(I,he)|0,i=(i=i+Math.imul(I,le)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,le)|0;var Be=(u+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(k,pe)|0))<<13)|0;u=((o=o+Math.imul(k,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,se)|0,n=n+Math.imul(M,ce)|0,i=(i=i+Math.imul(M,ue)|0)+Math.imul(O,ce)|0,o=o+Math.imul(O,ue)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(P,he)|0,o=o+Math.imul(P,le)|0;var Pe=(u+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,be)|0)+Math.imul(x,pe)|0))<<13)|0;u=((o=o+Math.imul(x,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,se))+Math.imul(U,oe)|0,o=Math.imul(U,se),n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,ue)|0)+Math.imul(j,ce)|0,o=o+Math.imul(j,ue)|0,n=n+Math.imul(M,he)|0,i=(i=i+Math.imul(M,le)|0)+Math.imul(O,he)|0,o=o+Math.imul(O,le)|0;var Ce=(u+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(P,pe)|0))<<13)|0;u=((o=o+Math.imul(P,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,ce),i=(i=Math.imul(D,ue))+Math.imul(U,ce)|0,o=Math.imul(U,ue),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(j,he)|0,o=o+Math.imul(j,le)|0;var Me=(u+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,be)|0)+Math.imul(O,pe)|0))<<13)|0;u=((o=o+Math.imul(O,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(U,he)|0,o=Math.imul(U,le);var Oe=(u+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,be)|0)+Math.imul(j,pe)|0))<<13)|0;u=((o=o+Math.imul(j,be)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863;var Re=(u+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,be))+Math.imul(U,pe)|0))<<13)|0;return u=((o=Math.imul(U,be))+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,c[0]=ye,c[1]=ve,c[2]=ge,c[3]=me,c[4]=we,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=ke,c[9]=Ae,c[10]=Ie,c[11]=xe,c[12]=Te,c[13]=Be,c[14]=Pe,c[15]=Ce,c[16]=Me,c[17]=Oe,c[18]=Re,0!==u&&(c[19]=u,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(l=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?l(this,e,t):r<63?h(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,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=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<=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},o.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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,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 a,c=n.length-i.length;if("mod"!==t){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.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),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.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},o.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;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),c=new o(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(c)):(r.isub(t),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(t.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}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(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new _(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function m(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},i(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new g;else if("p192"===e)t=new m;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return b[e]=t,t},_.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=t.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,_),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:104}],91:[function(e,t,r){var n={};function i(e,t){for(var r in e)t[r]=e[r]}t.exports=n,n.from=e("./from.js"),n.to=e("./to.js"),n.is=e("./is.js"),n.subarray=e("./subarray.js"),n.join=e("./join.js"),n.copy=e("./copy.js"),n.create=e("./create.js"),i(e("./read.js"),n),i(e("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(e,t,r){t.exports=function(e,t,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?e.length:o)===i)return;if(0===t.length||0===e.length)return;o>e.length&&(o=e.length);t.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(e){for(var t,r,n=[],i=0,o=e.length;i>>4).toString(16),r+=(15&t).toString(16);return r},utf8:function(e){return i(e)},base64:function(e){return n.fromByteArray(e)}}},{"base64-js":30,"to-utf8":350}],101:[function(e,t,r){t.exports={writeUInt8:function(e,t,r){return e[r]=t},writeInt8:function(e,t,r){return e[r]=t<0?t+256:t},writeUInt16LE:function(e,t,r){return n.get(e).setUint16(r+e.byteOffset,t,!0)},writeUInt32LE:function(e,t,r){return n.get(e).setUint32(r+e.byteOffset,t,!0)},writeInt16LE:function(e,t,r){return n.get(e).setInt16(r+e.byteOffset,t,!0)},writeInt32LE:function(e,t,r){return n.get(e).setInt32(r+e.byteOffset,t,!0)},writeFloatLE:function(e,t,r){return n.get(e).setFloat32(r+e.byteOffset,t,!0)},writeDoubleLE:function(e,t,r){return n.get(e).setFloat64(r+e.byteOffset,t,!0)},writeUInt16BE:function(e,t,r){return n.get(e).setUint16(r+e.byteOffset,t,!1)},writeUInt32BE:function(e,t,r){return n.get(e).setUint32(r+e.byteOffset,t,!1)},writeInt16BE:function(e,t,r){return n.get(e).setInt16(r+e.byteOffset,t,!1)},writeInt32BE:function(e,t,r){return n.get(e).setInt32(r+e.byteOffset,t,!1)},writeFloatBE:function(e,t,r){return n.get(e).setFloat32(r+e.byteOffset,t,!1)},writeDoubleBE:function(e,t,r){return n.get(e).setFloat64(r+e.byteOffset,t,!1)}};var n=e("./mapped.js")},{"./mapped.js":97}],102:[function(e,t,r){!function(e,r){void 0!==t&&t.exports?t.exports.browser=r():"function"==typeof define&&define.amd?define(r):this.bowser=r()}(0,function(){var e=!0;function t(t){function r(e){var r=t.match(e);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(t)&&/android/i.test(t),c=r(/edge\/(\d+(\.\d+)?)/i),u=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(t),h=!f&&/[^-]mobi/i.test(t);/opera|opr/i.test(t)?n={name:"Opera",opera:e,version:u||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?(n={name:"Windows Phone",windowsphone:e},c?(n.msedge=e,n.version=c):(n.msie=e,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?n={name:"Internet Explorer",msie:e,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?n={name:"Microsoft Edge",msedge:e,version:c}:/chrome|crios|crmo/i.test(t)?n={name:"Chrome",chrome:e,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},u&&(n.version=u)):/sailfish/i.test(t)?n={name:"Sailfish",sailfish:e,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?n={name:"SeaMonkey",seamonkey:e,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(n={name:"Firefox",firefox:e,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(n.firefoxos=e)):/silk/i.test(t)?n={name:"Amazon Silk",silk:e,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:u}:/phantom/i.test(t)?n={name:"PhantomJS",phantom:e,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?n={name:"BlackBerry",blackberry:e,version:u||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(n={name:"WebOS",webos:e,version:u||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(n.touchpad=e)):n=/bada/i.test(t)?{name:"Bada",bada:e,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?{name:"Tizen",tizen:e,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||u}:/safari/i.test(t)?{name:"Safari",safari:e,version:u}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=t.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(t)?(n.name=n.name||"Webkit",n.webkit=e,!n.version&&u&&(n.version=u)):!n.opera&&/gecko\//i.test(t)&&(n.name=n.name||"Gecko",n.gecko=e,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=e,n.ios=e):n.android=e;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=e:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=e),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=e:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=e:n.x=e,n}var r=t("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(e){for(var t=0;t>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[v++],s=u[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[v++],a=u[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[v++],c=u[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[v++],d=o,p=s,b=a,y=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[v++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[v++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[v++],c=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[v++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[s]=u,n[u]=s;var f=e[s],h=e[f],l=e[h],d=257*e[u]^16843008*u;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===s?s=a=1:(s=f^e[e[e[l^f]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=n(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/t|0]<<24):t>6&&o%t==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-t]^c}for(var u=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u},c.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},t.exports.AES=c},{"safe-buffer":322}],106:[function(e,t,r){var n=e("./aes"),Buffer=e("safe-buffer").Buffer,i=e("cipher-base"),o=e("inherits"),s=e("./ghash"),a=e("buffer-xor"),c=e("./incr32");function u(e,t,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(t);var u=this._cipher.encryptBlock(a);this._ghash=new s(u),r=function(e,t,r){if(12===t.length)return e._finID=Buffer.concat([t,Buffer.from([0,0,0,1])]),Buffer.concat([t,Buffer.from([0,0,0,2])]);var n=new s(r),i=t.length,o=i%16;n.update(t),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,u=Buffer.alloc(8);u.writeUIntBE(a,0,8),n.update(u),e._finID=n.state;var f=Buffer.from(e._finID);return c(f),f}(this,r,u),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}o(u,i),u.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=Buffer.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return h(e,n.key,n.iv)},r.createDecipheriv=h},{"./aes":105,"./authCipher":106,"./modes":118,"./streamCipher":121,"cipher-base":135,evp_bytestokey:237,inherits:259,"safe-buffer":322}],109:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),Buffer=e("safe-buffer").Buffer,o=e("./streamCipher"),s=e("cipher-base"),a=e("./aes"),c=e("evp_bytestokey");function u(e,t,r){s.call(this),this._cache=new h,this._cipher=new a.AES(t),this._prev=Buffer.from(r),this._mode=e,this._autopadding=!0}e("inherits")(u,s),u.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=Buffer.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new u(s.module,t,r)}u.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=Buffer.concat([this.cache,e])},h.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},h.prototype.flush=function(){for(var e=16-this.cache.length,t=Buffer.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(e){var t;for(this.cache=Buffer.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,e,0,t])),this.state},t.exports=o},{"safe-buffer":322}],111:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],112:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":130}],113:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-xor");function i(e,t,r){var i=t.length,o=n(t,e._cache);return e._cache=e._cache.slice(i),e._prev=Buffer.concat([e._prev,r?t:o]),o}r.encrypt=function(e,t,r){for(var n,o=Buffer.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=Buffer.allocUnsafe(0)),!(e._cache.length<=t.length)){o=Buffer.concat([o,i(e,t,r)]);break}n=e._cache.length,o=Buffer.concat([o,i(e,t.slice(0,n),r)]),t=t.slice(n)}return o}},{"buffer-xor":130,"safe-buffer":322}],114:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;function n(e,t,r){for(var n,o,s,a=-1,c=0;++a<8;)n=e._cipher.encryptBlock(e._prev),o=t&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,e._prev=i(e._prev,r?o:s);return c}function i(e,t){var r=e.length,n=-1,i=Buffer.allocUnsafe(e.length);for(e=Buffer.concat([e,Buffer.from([t])]);++n>7;return i}r.encrypt=function(e,t,r){for(var i=t.length,o=Buffer.allocUnsafe(i),s=-1;++so)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),n=s(r),i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function l(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return N(e).length;default:if(i)return n?-1:j(e).length;t=(""+t).toLowerCase(),i=!0}}function d(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function p(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,i){if(U(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),u=e.slice(t,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return g(this,e,t,r);case"latin1":case"binary":return m(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function A(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function C(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,o){return t=+t,r>>>=0,o||C(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,o){return t=+t,r>>>=0,o||C(e,0,r,8),i.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function N(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function U(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function H(e){return e!=e}},{"base64-js":132,ieee754:257}],132:[function(e,t,r){"use strict";r.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){for(var t,r=u(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),c=0,f=s>0?n-4:n,h=0;h>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===s&&(t=i[e.charCodeAt(h)]<<2|i[e.charCodeAt(h+1)]>>4,a[c++]=255&t);1===s&&(t=i[e.charCodeAt(h)]<<10|i[e.charCodeAt(h+1)]<<4|i[e.charCodeAt(h+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],133:[function(e,t,r){"use strict";for(var BigInteger=e("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),t.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),t.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),t.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),t.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(e){for(var t=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+e);if(0===n)throw new Error("Missing prefix for "+e);var a=e.slice(0,n),c=e.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=c.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+e);return{prefix:a,words:l}},encode:function(e,t){if(e.length+o+1+t.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(e=e.toLowerCase()),s=e+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=u(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&t||t>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,e>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&e),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+u.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:u.scriptType,prefix:t.prefix,hash:Buffer.from(c.slice(1))}},encode:function(e,t,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(t in s))throw new Error("Unsupported script type");return r.encode(e,r.toWords(c(t,n)))}}}).call(this,e("buffer").Buffer)},{"./base32":133,buffer:131}],135:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("stream").Transform,i=e("string_decoder").StringDecoder;function o(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(o,n),o.prototype.update=function(e,t,r){"string"==typeof e&&(e=Buffer.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},o.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},o.prototype._finalOrDigest=function(e){var t=this.__final()||Buffer.alloc(0);return e&&(t=this._toString(t,e,!0)),t},o.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new i(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=o},{inherits:259,"safe-buffer":322,stream:338,string_decoder:241}],136:[function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}void 0!==t&&(t.exports=n),n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;ir)?t=("rmd160"===e?new a:c(e)).update(t).digest():t.lengths?t=e(t):t.length>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(i=new Buffer(2))[0]=o,i[1]=n.length,this._createEncoderBuffer([i,n]);for(var a=1,c=n.length;c>=256;c>>=8)a++;(i=new Buffer(2+a))[0]=o,i[1]=128|a;c=1+a;for(var u=n.length;u>0;c--,u>>=8)i[c]=255&u;return this._createEncoderBuffer([i,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new Buffer(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var i=0;for(n=0;n=128;o>>=7)i++}var s=new Buffer(i),a=s.length-1;for(n=e.length-1;n>=0;n--){o=e[n];for(s[a--]=127&o;(o>>=7)>0;)s[a--]=128|127&o}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[u(n.getFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(n.getFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new Buffer(r)}if(Buffer.isBuffer(e)){var n=e.length;0===e.length&&n++;var i=new Buffer(n);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var o=e;o>=256;o>>=8)n++;for(o=(i=new Array(n)).length-1;o>=0;o--)i[o]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new Buffer(i))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0||!i.umod(e.prime1)||!i.umod(e.prime2);)i=new r(n(t));return i}t.exports=i,i.getr=o}).call(this,e("buffer").Buffer)},{"bn.js":90,buffer:131,randombytes:306}],159:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":160}],160:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],161:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],162:[function(e,t,r){(function(Buffer){var r=e("create-hash"),n=e("stream"),i=e("inherits"),o=e("./sign"),s=e("./verify"),a=e("./algorithms.json");function c(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function u(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){return new c(e)}function h(e){return new u(e)}Object.keys(a).forEach(function(e){a[e].id=new Buffer(a[e].id,"hex"),a[e.toLowerCase()]=a[e]}),i(c,n.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=o(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},i(u,n.Writable),u.prototype._write=function(e,t,r){this._hash.update(e),r()},u.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},u.prototype.verify=function(e,t,r){"string"==typeof t&&(t=new Buffer(t,r)),this.end();var n=this._hash.digest();return s(t,n,e,this._signType,this._tag)},t.exports={Sign:f,Verify:h,createSign:f,createVerify:h}}).call(this,e("buffer").Buffer)},{"./algorithms.json":160,"./sign":163,"./verify":164,buffer:131,"create-hash":139,inherits:259,stream:338}],163:[function(e,t,r){(function(Buffer){var r=e("create-hmac"),n=e("browserify-rsa"),i=e("elliptic").ec,o=e("bn.js"),s=e("parse-asn1"),a=e("./curves.json");function c(e,t,n,i){if((e=new Buffer(e.toArray())).length0&&r.ishrn(n),r}function f(e,t,n){var i,o;do{for(i=new Buffer(0);8*i.length=t)throw new Error("invalid sig")}t.exports=function(e,t,a,c,u){var f=i(a);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=o[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var s=new n(i),a=r.data.subjectPrivateKey.data;return s.verify(t,e,a)}(e,t,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,n){var o=n.data.p,a=n.data.q,c=n.data.g,u=n.data.pub_key,f=i.signature.decode(e,"der"),h=f.s,l=f.r;s(h,a),s(l,a);var d=r.mont(o),p=h.invm(a);return 0===c.toRed(d).redPow(new r(t).mul(p).mod(a)).fromRed().mul(u.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(o).mod(a).cmp(l)}(e,t,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=Buffer.concat([u,t]);for(var h=f.modulus.byteLength(),l=[1],d=0;t.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=e[r],y=e[b],v=e[y],g=257*e[p]^16843008*p;s[r]=g<<24|g>>>8,a[r]=g<<16|g>>>16,c[r]=g<<8|g>>>24,u[r]=g;g=16843009*v^65537*y^257*b^16843008*r;f[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,l[p]=g<<8|g>>>24,d[p]=g,r?(r=b^e[e[e[v^b]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],u=0;u>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,f,h,l,d,o);r=e[t+1];e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,s,a){for(var c=this._nRounds,u=e[t]^r[0],f=e[t+1]^r[1],h=e[t+2]^r[2],l=e[t+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&u]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[u>>>8&255]^s[255&f]^r[d++],g=n[l>>>24]^i[u>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];u=b,f=y,h=v,l=g}b=(a[u>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&f])^r[d++],g=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];e[t]=b,e[t+1]=y,e[t+2]=v,e[t+3]=g},keySize:8});t.AES=r._createHelper(b)}(),e.AES},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],171:[function(e,t,r){var n,i;n=this,i=function(e){e.lib.Cipher||function(t){var r=e,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),u=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?m:v}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),d=h.CBC=function(){var e=l.extend();function r(e,r,n){var i=this._iv;if(i){var o=i;this._iv=t}else o=this._prevBlock;for(var s=0;s>>2];e.sigBytes-=t}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode=n.call(r,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(t);else n=t;return n.toString(c)},parse:function(e){var t=c.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return b.create({ciphertext:t,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),g=(r.kdf={}).OpenSSL={execute:function(e,t,r,n){n||(n=o.random(8));var i=u.create({keySize:t+r}).compute(e,n),s=o.create(i.words.slice(t),4*r);return i.sigBytes=4*t,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,v.decrypt.call(this,e,t,i.key,n)}})}()},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],172:[function(e,t,r){var n,i;n=this,i=function(){var e=e||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={},o=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)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||c).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 o=0;o>>2]>>>24-o%4*8&255;t[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>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=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){t=t;var 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)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},f=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],174:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.WordArray,n=t.enc;n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,n=[],i=0;i>>1]|=e.charCodeAt(i)<<16-i%2*16;return r.create(n,2*t)}};function i(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o>>1]|=i(e.charCodeAt(o)<<16-o%2*16);return r.create(n,2*t)}}}(),e.enc.Utf16},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],175:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,u=0;u>>2]|=e[i]<<24-i%4*8;r.call(this,n,t)}else r.apply(this,arguments)}).prototype=t}}(),e.lib.WordArray},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],180:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],d=e[t+2],p=e[t+3],b=e[t+4],y=e[t+5],v=e[t+6],g=e[t+7],m=e[t+8],w=e[t+9],_=e[t+10],E=e[t+11],S=e[t+12],k=e[t+13],A=e[t+14],I=e[t+15],x=o[0],T=o[1],B=o[2],P=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=u(T=u(T=u(T=u(T,B=u(B,P=u(P,x=u(x,T,B,P,s,7,a[0]),T,B,c,12,a[1]),x,T,d,17,a[2]),P,x,p,22,a[3]),B=u(B,P=u(P,x=u(x,T,B,P,b,7,a[4]),T,B,y,12,a[5]),x,T,v,17,a[6]),P,x,g,22,a[7]),B=u(B,P=u(P,x=u(x,T,B,P,m,7,a[8]),T,B,w,12,a[9]),x,T,_,17,a[10]),P,x,E,22,a[11]),B=u(B,P=u(P,x=u(x,T,B,P,S,7,a[12]),T,B,k,12,a[13]),x,T,A,17,a[14]),P,x,I,22,a[15]),B=f(B,P=f(P,x=f(x,T,B,P,c,5,a[16]),T,B,v,9,a[17]),x,T,E,14,a[18]),P,x,s,20,a[19]),B=f(B,P=f(P,x=f(x,T,B,P,y,5,a[20]),T,B,_,9,a[21]),x,T,I,14,a[22]),P,x,b,20,a[23]),B=f(B,P=f(P,x=f(x,T,B,P,w,5,a[24]),T,B,A,9,a[25]),x,T,p,14,a[26]),P,x,m,20,a[27]),B=f(B,P=f(P,x=f(x,T,B,P,k,5,a[28]),T,B,d,9,a[29]),x,T,g,14,a[30]),P,x,S,20,a[31]),B=h(B,P=h(P,x=h(x,T,B,P,y,4,a[32]),T,B,m,11,a[33]),x,T,E,16,a[34]),P,x,A,23,a[35]),B=h(B,P=h(P,x=h(x,T,B,P,c,4,a[36]),T,B,b,11,a[37]),x,T,g,16,a[38]),P,x,_,23,a[39]),B=h(B,P=h(P,x=h(x,T,B,P,k,4,a[40]),T,B,s,11,a[41]),x,T,p,16,a[42]),P,x,v,23,a[43]),B=h(B,P=h(P,x=h(x,T,B,P,w,4,a[44]),T,B,S,11,a[45]),x,T,I,16,a[46]),P,x,d,23,a[47]),B=l(B,P=l(P,x=l(x,T,B,P,s,6,a[48]),T,B,g,10,a[49]),x,T,A,15,a[50]),P,x,y,21,a[51]),B=l(B,P=l(P,x=l(x,T,B,P,S,6,a[52]),T,B,p,10,a[53]),x,T,_,15,a[54]),P,x,c,21,a[55]),B=l(B,P=l(P,x=l(x,T,B,P,m,6,a[56]),T,B,I,10,a[57]),x,T,v,15,a[58]),P,x,k,21,a[59]),B=l(B,P=l(P,x=l(x,T,B,P,b,6,a[60]),T,B,E,10,a[61]),x,T,d,15,a[62]),P,x,w,21,a[63]),o[0]=o[0]+x|0,o[1]=o[1]+T|0,o[2]=o[2]+B|0,o[3]=o[3]+P|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,s){var a=e+(t&r|~t&n)+i+s;return(a<>>32-o)+t}function f(e,t,r,n,i,o,s){var a=e+(t&n|r&~n)+i+s;return(a<>>32-o)+t}function h(e,t,r,n,i,o,s){var a=e+(t^r^n)+i+s;return(a<>>32-o)+t}function l(e,t,r,n,i,o,s){var a=e+(r^(t|~n))+i+s;return(a<>>32-o)+t}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),e.MD5},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],181:[function(e,t,r){var n,i;n=this,i=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var t=e>>16&255,r=e>>8&255,n=255&e;255===t?(t=0,255===r?(r=0,255===n?n=0:++n):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=n}else e+=1<<24;return e}var n=t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(e){0===(e[0]=r(e[0]))&&(e[1]=r(e[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],187:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso10126={pad:function(t,r){var n=4*r,i=n-t.sigBytes%n;t.concat(e.lib.WordArray.random(i-1)).concat(e.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],188:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso97971={pad:function(t,r){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,r)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],189:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],190:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){for(var t=e.words,r=e.sigBytes-1;!(t[r>>>2]>>>24-r%4*8&255);)r--;e.sigBytes=r+1}},e.pad.ZeroPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172}],191:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a,c;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=a.create(r.hasher,e),o=i.create(),s=i.create([1]),c=o.words,u=s.words,f=r.keySize,h=r.iterations;c.length>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;n[0]^=u,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=u,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.RabbitLegacy=r._createHelper(s)}(),e.RabbitLegacy},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],193:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=[],i=[],o=[],s=t.algo.Rabbit=r.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(t){var o=t.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;i[0]^=u,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=u,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.Rabbit=r._createHelper(s)}(),e.Rabbit},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],194:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,i=n.RC4=r.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=t[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[r],e[r]=o,n|=e[(e[t]+e[r])%256]<<24-8*i}return this._i=t,this._j=r,n}t.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});t.RC4Drop=r._createHelper(s)}(),e.RC4},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":171,"./core":172,"./enc-base64":173,"./evpkdf":175,"./md5":180}],195:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,I,x,T=this._hash.words,B=h.words,P=l.words,C=a.words,M=c.words,O=u.words,R=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],I=_=T[4];for(r=0;r<80;r+=1)x=o+e[t+C[r]]|0,x+=r<16?p(s,d,w)+B[0]:r<32?b(s,d,w)+B[1]:r<48?y(s,d,w)+B[2]:r<64?v(s,d,w)+B[3]:g(s,d,w)+B[4],x=(x=m(x|=0,O[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=x,x=E+e[t+M[r]]|0,x+=r<16?g(S,k,A)+P[0]:r<32?v(S,k,A)+P[1]:r<48?y(S,k,A)+P[2]:r<64?b(S,k,A)+P[3]:p(S,k,A)+P[4],x=(x=m(x|=0,R[r]))+I|0,E=I,I=A,A=m(k,10),k=S,S=x;x=T[1]+d+A|0,T[1]=T[2]+w+I|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=x},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function b(e,t,r){return e&t|~e&r}function y(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function g(e,t,r){return e^(t|~r)}function m(e,t){return e<>>32-t}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),e.RIPEMD160},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],196:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s;return r=(t=e).lib,n=r.WordArray,i=r.Hasher,o=[],s=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|e[t+u];else{var f=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=f<<1|f>>>31}var h=(n<<5|n>>>27)+c+o[u];h+=u<20?1518500249+(i&s|~i&a):u<40?1859775393+(i^s^a):u<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(s),t.HmacSHA1=i._createHmacHelper(s),e.SHA1},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],197:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o;return r=(t=e).lib.WordArray,n=t.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=i._doFinalize.call(this);return e.sigBytes-=4,e}}),t.SHA224=i._createHelper(o),t.HmacSHA224=i._createHmacHelper(o),e.SHA224},"object"==typeof r?t.exports=r=i(e("./core"),e("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],i):i(n.CryptoJS)},{"./core":172,"./sha256":198}],198:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(a[i]=r(t.pow(n,.5))),c[i]=r(t.pow(n,1/3)),i++),n++}();var u=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)u[d]=0|e[t+d];else{var p=u[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[d-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[d]=b+u[d-7]+v+u[d-16]}var g=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+c[d]+u[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),e.SHA256},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":172}],199:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],u=[],f=[];!function(){for(var e=1,t=0,r=0;r<24;r++){c[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)u[e+5*t]=t+(2*e+3*t)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],g=h[(l+1)%5],m=g.high,w=g.low;for(d=v.high^(m<<1|w>>>31),p=v.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[u[_]];A.high=d,A.low=p}var I=h[0],x=r[0];I.high=x.high,I.low=x.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],B=h[_],P=h[(l+1)%5+5*b],C=h[(l+2)%5+5*b];T.high=B.high^~P.high&C.high,T.low=B.low^~P.low&C.low}T=r[0];var M=f[a];T.high^=M.high,T.low^=M.low}},_doFinalize:function(){var e=this._data,r=e.words,n=(this._nDataBytes,8*e.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(t.ceil((n+1)/o)*o>>>5)-1]|=128,e.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),u.push(d),u.push(l)}return new i.init(u,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),e.SHA3},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":172,"./x64-core":203}],200:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).x64,n=r.Word,i=r.WordArray,o=t.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=16,e}}),t.SHA384=s._createHelper(a),t.HmacSHA384=s._createHmacHelper(a),e.SHA384},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core"),e("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],i):i(n.CryptoJS)},{"./core":172,"./sha512":201,"./x64-core":203}],201:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.Hasher,n=t.x64,i=n.Word,o=n.WordArray,s=t.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var e=0;e<80;e++)u[e]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,v=o.high,g=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,I=h.low,x=l.high,T=l.low,B=d,P=p,C=b,M=y,O=v,R=g,L=m,j=w,N=_,D=E,U=S,H=k,K=A,z=I,F=x,W=T,q=0;q<80;q++){var V=u[q];if(q<16)var G=V.high=0|e[t+2*q],Y=V.low=0|e[t+2*q+1];else{var X=u[q-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),ee=u[q-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ie=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),oe=u[q-7],se=oe.high,ae=oe.low,ce=u[q-16],ue=ce.high,fe=ce.low;G=(G=(G=Q+se+((Y=$+ae)>>>0<$>>>0?1:0))+ne+((Y=Y+ie)>>>0>>0?1:0))+ue+((Y=Y+fe)>>>0>>0?1:0);V.high=G,V.low=Y}var he,le=N&U^~N&K,de=D&H^~D&z,pe=B&C^B&O^C&O,be=P&M^P&R^M&R,ye=(B>>>28|P<<4)^(B<<30|P>>>2)^(B<<25|P>>>7),ve=(P>>>28|B<<4)^(P<<30|B>>>2)^(P<<25|B>>>7),ge=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),me=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),we=c[q],_e=we.high,Ee=we.low,Se=F+ge+((he=W+me)>>>0>>0?1:0),ke=ve+be;F=K,W=z,K=U,z=H,U=N,H=D,N=L+(Se=(Se=(Se=Se+le+((he=he+de)>>>0>>0?1:0))+_e+((he=he+Ee)>>>0>>0?1:0))+G+((he=he+Y)>>>0>>0?1:0))+((D=j+he|0)>>>0>>0?1:0)|0,L=O,j=R,O=C,R=M,C=B,M=P,B=Se+(ye+pe+(ke>>>0>>0?1:0))+((P=he+ke|0)>>>0>>0?1:0)|0}p=n.low=p+P,n.high=d+B+(p>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var v=t("./templates");for(var g in v)e.exports[g]=v[g]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),g={script:d,valueBuffer:v};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function v(t){return-1!==d.indexOf(t)}function g(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,g=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),g=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!v(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),g&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,v,g,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=b=a.scriptType,g=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,g=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,v=b=a.scriptType,g=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,v=u,g=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,v=u=h.P2PKH,g=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}v===h.P2WPKH&&(g=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(g))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=g,t.signType=v,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=g(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!v(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,v="...",g=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",x="[object Array]",I="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",F="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,Z=RegExp(Y.source),J=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[q]=yt[F]=!0,yt[A]=yt[x]=yt[L]=yt[I]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var vt={};vt[A]=vt[x]=vt[L]=vt[I]=vt[T]=vt[j]=vt[D]=vt[N]=vt[U]=vt[H]=vt[P]=vt[C]=vt[R]=vt[O]=vt[K]=vt[z]=vt[q]=vt[F]=!0,vt[M]=vt[B]=vt["[object Map]"]=vt["[object Set]"]=vt["[object WeakMap]"]=!1;var gt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,xt=Et[typeof e]&&e&&!e.nodeType&&e,It=At&&xt&&"object"==typeof t&&t;!It||It.global!==It&&It.window!==It&&It.self!==It||(kt=It);var Tt=xt&&xt.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function Ft(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!Fn(t)){if(t instanceof Le)return t;if(Jt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=Ie,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ve(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Zr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function qr(t,e,i,o,s,p,y,v,g,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,x=!E&&Kr(t),I=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=Ft(b,T);if((f-=M.length)=(e=+e)||!ge(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var v=e&u;if(!v&&!Yn(t))throw new xt(S);var g=i?i.length:0;if(g||(e&=~(l|d),i=o=null),g-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!v&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],v=(l?t:e)[8],g=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=g)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Jt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Jt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Jr(n)&&(Fn(t)||i.nonEnumArgs&&qn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Jt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=Fn(t)?qe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(Fn(t)?Fe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(Fn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?ze(t,e):sr(t,Rr(e,r,3))}function xn(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var In=Dr(function(t,e,r){Jt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(Fn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=Ie;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new xt(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function v(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),v=n<=0||n>l;v?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return v&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(v=!0,s=t.apply(u,i)),!v||c||o||(i=u=null),s}return v.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},v}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!qe(t,Yn))throw new xt(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new xt(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function qn(t){return Jr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var Fn=ye||function(t){return zt(t)&&Jr(t.length)&&$t.call(t)==x||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ge(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Zn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Jn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Zn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Jr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return vr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Jr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Jr(e)&&(Fn(t)||je.nonEnumArgs&&qn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=gn,Oe.chunk=function(t,e,n){e=(n?Zr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Zr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Zr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Jr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return xr(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Jt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=qn,Oe.isArray=Fn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==I||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Jr(e)&&(Fn(t)||ti(t)||qn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?gr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Jt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Jn(t)&&t!=+t},Oe.isNative=Zn,Oe.isNull=function(t){return null===t},Oe.isNumber=Jn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=xi,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ge(e))return t;var i=(e-n)/2,o=se(i);return(r=Fr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&Fr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+Fr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Zr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Jr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=vi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Zr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Je)).imports),i.imports,Je),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=gi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Zr(t,e,r)&&(e=null);var n=y,i=v;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||Fn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=It[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!Fn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(g,v),g.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[v++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[v++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[v++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[v++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[v++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[v++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[v++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[v++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return g(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function v(t,e,r){return y(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):v(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],v=t[y],g=257*t[p]^16843008*p;s[r]=g<<24|g>>>8,a[r]=g<<16|g>>>16,u[r]=g<<8|g>>>24,c[r]=g;g=16843009*v^65537*y^257*b^16843008*r;f[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,l[p]=g<<8|g>>>24,d[p]=g,r?(r=b^t[t[t[v^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],g=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=v,l=g}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],g=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:v}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,v.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],v=t[e+6],g=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],I=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,I=c(I,T,M,B,s,7,a[0]),T,M,u,12,a[1]),I,T,d,17,a[2]),B,I,p,22,a[3]),M=c(M,B=c(B,I=c(I,T,M,B,b,7,a[4]),T,M,y,12,a[5]),I,T,v,17,a[6]),B,I,g,22,a[7]),M=c(M,B=c(B,I=c(I,T,M,B,m,7,a[8]),T,M,w,12,a[9]),I,T,_,17,a[10]),B,I,E,22,a[11]),M=c(M,B=c(B,I=c(I,T,M,B,S,7,a[12]),T,M,k,12,a[13]),I,T,A,17,a[14]),B,I,x,22,a[15]),M=f(M,B=f(B,I=f(I,T,M,B,u,5,a[16]),T,M,v,9,a[17]),I,T,E,14,a[18]),B,I,s,20,a[19]),M=f(M,B=f(B,I=f(I,T,M,B,y,5,a[20]),T,M,_,9,a[21]),I,T,x,14,a[22]),B,I,b,20,a[23]),M=f(M,B=f(B,I=f(I,T,M,B,w,5,a[24]),T,M,A,9,a[25]),I,T,p,14,a[26]),B,I,m,20,a[27]),M=f(M,B=f(B,I=f(I,T,M,B,k,5,a[28]),T,M,d,9,a[29]),I,T,g,14,a[30]),B,I,S,20,a[31]),M=h(M,B=h(B,I=h(I,T,M,B,y,4,a[32]),T,M,m,11,a[33]),I,T,E,16,a[34]),B,I,A,23,a[35]),M=h(M,B=h(B,I=h(I,T,M,B,u,4,a[36]),T,M,b,11,a[37]),I,T,g,16,a[38]),B,I,_,23,a[39]),M=h(M,B=h(B,I=h(I,T,M,B,k,4,a[40]),T,M,s,11,a[41]),I,T,p,16,a[42]),B,I,v,23,a[43]),M=h(M,B=h(B,I=h(I,T,M,B,w,4,a[44]),T,M,S,11,a[45]),I,T,x,16,a[46]),B,I,d,23,a[47]),M=l(M,B=l(B,I=l(I,T,M,B,s,6,a[48]),T,M,g,10,a[49]),I,T,A,15,a[50]),B,I,y,21,a[51]),M=l(M,B=l(B,I=l(I,T,M,B,S,6,a[52]),T,M,p,10,a[53]),I,T,_,15,a[54]),B,I,u,21,a[55]),M=l(M,B=l(B,I=l(I,T,M,B,m,6,a[56]),T,M,x,10,a[57]),I,T,v,15,a[58]),B,I,k,21,a[59]),M=l(M,B=l(B,I=l(I,T,M,B,b,6,a[60]),T,M,E,10,a[61]),I,T,d,15,a[62]),B,I,w,21,a[63]),o[0]=o[0]+I|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,I,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)I=o+t[e+P[r]]|0,I+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?v(s,d,w)+M[3]:g(s,d,w)+M[4],I=(I=m(I|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=I,I=E+t[e+C[r]]|0,I+=r<16?g(S,k,A)+B[0]:r<32?v(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],I=(I=m(I|=0,O[r]))+x|0,E=x,x=A,A=m(k,10),k=S,S=I;I=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=I},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function v(t,e,r){return t&r|e&~r}function g(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+v+c[d-16]}var g=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],g=h[(l+1)%5],m=g.high,w=g.low;for(d=v.high^(m<<1|w>>>31),p=v.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var x=h[0],I=r[0];x.high=I.high,x.low=I.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,v=o.high,g=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,I=l.high,T=l.low,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=x,q=I,F=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],Z=X.high,J=X.low,Q=(Z>>>1|J<<31)^(Z>>>8|J<<24)^Z>>>7,$=(J>>>1|Z<<31)^(J>>>8|Z<<24)^(J>>>7|Z<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),vt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=q+gt+((ht=F+mt)>>>0>>0?1:0),kt=vt+bt;q=K,F=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0

>>0?1:0),y=i.low=y+M,i.high=b+C+(y>>>0>>0?1:0),g=o.low=g+R,o.high=v+O+(g>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+D,a.high=_+N+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),I=h.low=I+z,h.high=A+K+(I>>>0>>0?1:0),T=l.low=T+W,l.high=x+F+(T>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});t.SHA512=r._createHelper(f),t.HmacSHA512=r._createHmacHelper(f)}(),e.SHA512},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":172,"./x64-core":203}],202:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib,n=r.WordArray,i=r.BlockCipher,o=t.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=s[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var u=i[o]=[],f=c[o];for(r=0;r<24;r++)u[r/6|0]|=t[(a[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=t[28+(a[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^i[c])&f[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},r.enable(i())}).call(this,e("_process"))},{"./debug":205,_process:271}],205:[function(e,t,r){var n;function i(e){function t(){if(t.enabled){var e=t,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=s.r28shl(r,a),i=s.r28shl(i,a),s.pc2(r,i,e.keys,o)}},c.prototype._update=function(e,t,r,n){var i=this._desState,o=s.readUInt32BE(e,t),a=s.readUInt32BE(e,t+4);s.ip(o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,a,i.tmp,0):this._decrypt(i,o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],s.writeUInt32BE(r,o,n),s.writeUInt32BE(r,a,n+4)},c.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}s.rip(a,o,n,i)},c.prototype._decrypt=function(e,t,r,n,i){for(var o=r,a=t,c=e.keys.length-2;c>=0;c-=2){var u=e.keys[c],f=e.keys[c+1];s.expand(o,e.tmp,0),u^=e.tmp[0],f^=e.tmp[1];var h=s.substitute(u,f),l=o;o=(a^s.permute(h))>>>0,a=l}s.rip(o,a,n,i)}},{"../des":206,inherits:259,"minimalistic-assert":266}],210:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),s=o.Cipher,a=o.DES;function c(e){s.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[a.create({type:"encrypt",key:r}),a.create({type:"decrypt",key:i}),a.create({type:"encrypt",key:o})]:[a.create({type:"decrypt",key:o}),a.create({type:"encrypt",key:i}),a.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(c,s),t.exports=c,c.create=function(e){return new c(e)},c.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},c.prototype._pad=a.prototype._pad,c.prototype._unpad=a.prototype._unpad},{"../des":206,inherits:259,"minimalistic-assert":266}],211:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=t>>>a+s&1,i<<=1,i|=e>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=t>>>a+s&1,o<<=1,o|=e>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),t.cmp(c)){if(!t.cmp(u))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":265,randombytes:306}],215:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],216:[function(e,t,r){var n=e("assert"),BigInteger=e("bigi"),Point=e("./point");function i(e,t,r,n,i,o,s){this.p=e,this.a=t,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=e.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),Point.fromAffine(this,t,n)},i.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},i.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=t.pow(3).add(n.multiply(t)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},t.exports=i},{"./point":220,assert:24,bigi:34}],217:[function(e,t,r){t.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],218:[function(e,t,r){var Point=e("./point"),n=e("./curve"),i=e("./names");t.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":216,"./names":219,"./point":220}],219:[function(e,t,r){var BigInteger=e("bigi"),n=e("./curves.json"),i=e("./curve");t.exports=function(e){var t=n[e];if(!t)return null;var r=new BigInteger(t.p,16),o=new BigInteger(t.a,16),s=new BigInteger(t.b,16),a=new BigInteger(t.n,16),c=new BigInteger(t.h,16),u=new BigInteger(t.Gx,16),f=new BigInteger(t.Gy,16);return new i(r,o,s,u,f,a,c)}},{"./curve":216,"./curves.json":217,bigi:34}],220:[function(e,t,r){var n=e("assert"),Buffer=e("safe-buffer").Buffer,BigInteger=e("bigi"),i=BigInteger.valueOf(3);function Point(e,t,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=e,this.x=t,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(e,t,r){return new Point(e,t,r,BigInteger.ONE)},Point.prototype.equals=function(e){return e===this||(this.curve.isInfinity(this)?this.curve.isInfinity(e):this.curve.isInfinity(e)?this.curve.isInfinity(this):0===e.y.multiply(this.z).subtract(this.y.multiply(e.z)).mod(this.curve.p).signum()&&0===e.x.multiply(this.z).subtract(this.x.multiply(e.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var e=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,e,this.z)},Point.prototype.add=function(e){if(this.curve.isInfinity(this))return e;if(this.curve.isInfinity(e))return this;var t=this.x,r=this.y,n=e.x,o=e.y.multiply(this.z).subtract(r.multiply(e.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(t.multiply(e.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),u=t.multiply(a),f=o.square().multiply(this.z),h=f.subtract(u.shiftLeft(1)).multiply(e.z).subtract(c).multiply(s).mod(this.curve.p),l=u.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(f.multiply(o)).multiply(e.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(e.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var e=this.x,t=this.y,r=t.multiply(this.z).mod(this.curve.p),n=r.multiply(t).mod(this.curve.p),o=this.curve.a,s=e.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),u=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,u)},Point.prototype.multiply=function(e){if(this.curve.isInfinity(this))return this;if(0===e.signum())return this.curve.infinity;for(var t=e,r=t.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=t.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var s=e.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(t)),--n}return i},Point.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var t,r=this.affineX,n=this.affineY,i=this.curve.pLength;return e?(t=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((t=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(t,1+i)),r.toBuffer(i).copy(t,1),t},Point.decodeFrom=function(e,t){var r,i=t.readUInt8(0),o=4!==i,s=Math.floor((e.p.bitLength()+7)/8),a=BigInteger.fromBuffer(t.slice(1,1+s));if(o){n.equal(t.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=e.pointFromX(c,a)}else{n.equal(t.length,1+s+s,"Invalid sequence length");var u=BigInteger.fromBuffer(t.slice(1+s));r=Point.fromAffine(e,a,u)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},t.exports=Point},{assert:24,bigi:34,"safe-buffer":322}],221:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":236,"./elliptic/curve":224,"./elliptic/curves":227,"./elliptic/ec":228,"./elliptic/eddsa":231,"./elliptic/utils":235,brorand:103}],222:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,s=i.getJSF,a=i.assert;function c(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=c;t--)u=(u<<1)+n[t];s.push(u)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(c=0;c=0;u--){for(t=0;u>=0&&0===s[u];u--)t++;if(u>=0&&t++,c=c.dblp(t),u<0)break;var f=s[u];a(0!==f),c="affine"===e.type?f>0?c.mixedAdd(i[f-1>>1]):c.mixedAdd(i[-f-1>>1].neg()):f>0?c.add(i[f-1>>1]):c.add(i[-f-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,u=this._wnafT3,f=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===a[d]&&1===a[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[d],r[p]);f=Math.max(v[0].length,f),u[d]=new Array(f),u[p]=new Array(f);for(var g=0;g=0;h--){for(var S=0;h>=0;){var k=!0;for(g=0;g=0&&S++,_=_.dblp(S),h<0)break;for(g=0;g0?A=c[g][I-1>>1]:I<0&&(A=c[g][-I-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),s=o.redSub(r),a=n.redSub(t),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},Point.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(u=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(u.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),c=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(c),t=s.redMul(u.redSub(o)),r=s.redMul(c)}}else{var u=i.redAdd(o);a=this.curve._mulC(this.z).redSqr(),c=u.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(u)).redMul(c),t=this.curve._mulC(u).redMul(i.redISub(o)),r=u.redMul(c)}return this.curve.point(e,t,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(t),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(u,f,l,h)},Point.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),s=this.y.redMul(e.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(t=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(t=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,t,r)},Point.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],224:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":222,"./edwards":223,"./mont":225,"./short":226}],225:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),s=n.base,a=e("../../elliptic").utils;function c(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(c,s),t.exports=c,c.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(Point,s.BasePoint),c.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},c.prototype.point=function(e,t){return new Point(this,e,t)},c.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1]||e.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),s=i.redMul(n),a=t.z.redMul(o.redAdd(s).redSqr()),c=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],226:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),s=e("inherits"),a=n.base,c=i.utils.assert;function u(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(u,a),t.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],c(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,i,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),v=new o(1),g=0;0!==l.cmpn(0);){var m=d.div(l);u=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=v.sub(m.mul(b));if(!n&&u.cmp(h)<0)t=c.neg(),r=p,n=u.neg(),i=f;else if(n&&2==++g)break;c=u,d=l,l=u,y=p,p=f,v=b,b=w}s=u.neg(),a=f;var _=n.sqr().add(i.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:c.add(u).neg()}},u.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Point.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),l=c.redSqr().redIAdd(f).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":221,"../curve":224,"bn.js":90,inherits:259}],227:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),s=e("../elliptic"),a=s.utils.assert;function c(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":221,"./precomputed/secp256k1":234,"hash.js":244}],228:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),s=o.utils.assert,a=e("./key"),c=e("./signature");function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(s(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=u,u.prototype.keyPair=function(e){return new a(this,e)},u.prototype.keyFromPrivate=function(e,t){return a.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return a.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),u=e.toArray("be",s),f=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(v=v.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),g^=1),new c({r:y,s:v,recoveryParam:g})}}}}}},u.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),f=u.mul(e).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(f,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},u.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),u=t.r,f=t.s,h=1&r,l=r>>1;if(u.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");u=l?this.curve.pointFromX(u.add(this.curve.n),h):this.curve.pointFromX(u,h);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),b=f.mul(d).umod(o);return this.g.mulAdd(p,u,b)},u.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":221,"./key":229,"./signature":230,"bn.js":90,"hmac-drbg":256}],229:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":221,"bn.js":90}],230:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var c=a(e,r);if(e.length!==c+r.place)return!1;var u=e.slice(r.place,c+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===u[0]&&128&u[1]&&(u=u.slice(1)),this.r=new n(s),this.s=new n(u),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,t.length),(n=n.concat(t)).push(2),u(n,r.length);var o=n.concat(r),s=[48];return u(s,o.length),s=s.concat(o),i.encode(s,e)}},{"../../elliptic":221,"bn.js":90}],231:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,s=o.assert,a=o.parseBytes,c=e("./key"),u=e("./signature");function f(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,c=1;c0||t.cmpn(-i)>0;){var o,s,a,c=e.andln(3)+n&3,u=t.andln(3)+i&3;3===c&&(c=-1),3===u&&(u=-1),o=0==(1&c)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==u?c:-c,r[0].push(o),s=0==(1&u)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==c?u:-u,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":90,"minimalistic-assert":266,"minimalistic-crypto-utils":267}],236:[function(e,t,r){t.exports={_from:"elliptic@^6.2.3",_id:"elliptic@6.4.1",_inBundle:!1,_integrity:"sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.2.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.2.3",saveSpec:null,fetchSpec:"^6.2.3"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",_shasum:"c2d0b7776911b86722c632c3c06c60f2f819939a",_spec:"elliptic@^6.2.3",_where:"/work/blocktrail-sdk-nodejs/node_modules/secp256k1",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.1"}},{}],237:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,r,i){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),t&&(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var u=new n;u.update(c),u.update(e),t&&u.update(t),c=u.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,c.length),c.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,c.length-f);c.copy(a,l,f,f+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":263,"safe-buffer":322}],238:[function(e,t,r){arguments[4][104][0].apply(r,arguments)},{dup:104}],239:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(s(r=this._events[e]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(u=r.slice()).length,c=0;c0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(a=s;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],240:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,u=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,v="-",g=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(e){throw new RangeError(_[e])}function I(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+I((e=e.replace(w,".")).split("."),t).join(".")}function T(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)}).join("")}function P(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function C(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>E*l>>1;n+=f)e=S(e/E);return S(n+(E+1)*e/(e+d))}function M(e){var t,r,n,i,o,s,a,c,d,p,g,m=[],w=e.length,_=0,E=y,k=b;for((r=e.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(g=e.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:f)>=f||c>S((u-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(u/(p=f-d))&&A("overflow"),s*=p;k=C(_-o,t=m.length+1,0==o),S(_/t)>u-E&&A("overflow"),E+=S(_/t),_%=t,m.splice(_++,0,E)}return B(m)}function O(e){var t,r,n,i,o,s,a,c,d,p,g,m,w,_,E,I=[];for(m=(e=T(e)).length,t=y,r=0,o=b,s=0;s=t&&gS((u-r)/(w=n+1))&&A("overflow"),r+=(a-t)*w,t=a,s=0;su&&A("overflow"),g==t){for(c=r,d=f;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=c-p,_=f-p,I.push(k(P(p+E%_,0))),c=S(E/_);I.push(k(P(c,0))),o=C(r,w,n==i),r=0,++n}++r,++t}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:B},decode:M,encode:O,toASCII:function(e){return x(e,function(e){return m.test(e)?"xn--"+O(e):e})},toUnicode:function(e){return x(e,function(e){return g.test(e)?M(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return a});else if(i&&o)if(t.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],241:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=Buffer.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(Buffer.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=a,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=u,this.end=f,t=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":322}],242:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i},{inherits:259,"safe-buffer":322,stream:338}],244:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":255}],255:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(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}r.inherits=i,r.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),i=0;i>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,u=t;return c+=(u=u+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,u){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,u){return t+n+o+a+u>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:259,"minimalistic-assert":266}],256:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*b}},{}],258:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r>>1,D=[["ary",E],["bind",b],["bindKey",y],["curry",g],["curryRight",m],["flip",k],["partial",w],["partialRight",_],["rearg",S]],U="[object Arguments]",H="[object Array]",K="[object AsyncFunction]",z="[object Boolean]",F="[object Date]",W="[object DOMException]",q="[object Error]",V="[object Function]",G="[object GeneratorFunction]",Y="[object Map]",X="[object Number]",J="[object Null]",Z="[object Object]",Q="[object Proxy]",$="[object RegExp]",ee="[object Set]",te="[object String]",re="[object Symbol]",ne="[object Undefined]",ie="[object WeakMap]",oe="[object WeakSet]",se="[object ArrayBuffer]",ae="[object DataView]",ce="[object Float32Array]",ue="[object Float64Array]",fe="[object Int8Array]",he="[object Int16Array]",le="[object Int32Array]",de="[object Uint8Array]",pe="[object Uint8ClampedArray]",be="[object Uint16Array]",ye="[object Uint32Array]",ve=/\b__p \+= '';/g,ge=/\b(__p \+=) '' \+/g,me=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,Ee=RegExp(we.source),Se=RegExp(_e.source),ke=/<%-([\s\S]+?)%>/g,Ae=/<%([\s\S]+?)%>/g,Ie=/<%=([\s\S]+?)%>/g,xe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Te=/^\w*$/,Be=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pe=/[\\^$.*+?()[\]{}|]/g,Ce=RegExp(Pe.source),Me=/^\s+|\s+$/g,Oe=/^\s+/,Re=/\s+$/,Le=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,je=/\{\n\/\* \[wrapped with (.+)\] \*/,Ne=/,? & /,De=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ue=/\\(\\)?/g,He=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ke=/\w*$/,ze=/^[-+]0x[0-9a-f]+$/i,Fe=/^0b[01]+$/i,We=/^\[object .+?Constructor\]$/,qe=/^0o[0-7]+$/i,Ve=/^(?:0|[1-9]\d*)$/,Ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,Xe=/['\n\r\u2028\u2029\\]/g,Je="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qe="[\\ud800-\\udfff]",$e="["+Ze+"]",et="["+Je+"]",tt="\\d+",rt="[\\u2700-\\u27bf]",nt="[a-z\\xdf-\\xf6\\xf8-\\xff]",it="[^\\ud800-\\udfff"+Ze+tt+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ot="\\ud83c[\\udffb-\\udfff]",st="[^\\ud800-\\udfff]",at="(?:\\ud83c[\\udde6-\\uddff]){2}",ct="[\\ud800-\\udbff][\\udc00-\\udfff]",ut="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ft="(?:"+nt+"|"+it+")",ht="(?:"+ut+"|"+it+")",lt="(?:"+et+"|"+ot+")"+"?",dt="[\\ufe0e\\ufe0f]?"+lt+("(?:\\u200d(?:"+[st,at,ct].join("|")+")[\\ufe0e\\ufe0f]?"+lt+")*"),pt="(?:"+[rt,at,ct].join("|")+")"+dt,bt="(?:"+[st+et+"?",et,at,ct,Qe].join("|")+")",yt=RegExp("['’]","g"),vt=RegExp(et,"g"),gt=RegExp(ot+"(?="+ot+")|"+bt+dt,"g"),mt=RegExp([ut+"?"+nt+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[$e,ut,"$"].join("|")+")",ht+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[$e,ut+ft,"$"].join("|")+")",ut+"?"+ft+"+(?:['’](?:d|ll|m|re|s|t|ve))?",ut+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt,pt].join("|"),"g"),wt=RegExp("[\\u200d\\ud800-\\udfff"+Je+"\\ufe0e\\ufe0f]"),_t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],St=-1,kt={};kt[ce]=kt[ue]=kt[fe]=kt[he]=kt[le]=kt[de]=kt[pe]=kt[be]=kt[ye]=!0,kt[U]=kt[H]=kt[se]=kt[z]=kt[ae]=kt[F]=kt[q]=kt[V]=kt[Y]=kt[X]=kt[Z]=kt[$]=kt[ee]=kt[te]=kt[ie]=!1;var At={};At[U]=At[H]=At[se]=At[ae]=At[z]=At[F]=At[ce]=At[ue]=At[fe]=At[he]=At[le]=At[Y]=At[X]=At[Z]=At[$]=At[ee]=At[te]=At[re]=At[de]=At[pe]=At[be]=At[ye]=!0,At[q]=At[V]=At[ie]=!1;var It={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xt=parseFloat,Tt=parseInt,Bt="object"==typeof e&&e&&e.Object===Object&&e,Pt="object"==typeof self&&self&&self.Object===Object&&self,Ct=Bt||Pt||Function("return this")(),Mt="object"==typeof r&&r&&!r.nodeType&&r,Ot=Mt&&"object"==typeof t&&t&&!t.nodeType&&t,Rt=Ot&&Ot.exports===Mt,Lt=Rt&&Bt.process,jt=function(){try{var e=Ot&&Ot.require&&Ot.require("util").types;return e||Lt&&Lt.binding&&Lt.binding("util")}catch(e){}}(),Nt=jt&&jt.isArrayBuffer,Dt=jt&&jt.isDate,Ut=jt&&jt.isMap,Ht=jt&&jt.isRegExp,Kt=jt&&jt.isSet,zt=jt&&jt.isTypedArray;function Ft(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Wt(e,t,r,n){for(var i=-1,o=null==e?0:e.length;++i-1}function Jt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n-1;);return r}function gr(e,t){for(var r=e.length;r--&&or(t,e[r],0)>-1;);return r}var mr=fr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),wr=fr({"&":"&","<":"<",">":">",'"':""","'":"'"});function _r(e){return"\\"+It[e]}function Er(e){return wt.test(e)}function Sr(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function kr(e,t){return function(r){return e(t(r))}}function Ar(e,t){for(var r=-1,n=e.length,i=0,o=[];++r",""":'"',"'":"'"});var Cr=function e(t){var r,Je=(t=null==t?Ct:Cr.defaults(Ct.Object(),t,Cr.pick(Ct,Et))).Array,Ze=t.Date,Qe=t.Error,$e=t.Function,et=t.Math,tt=t.Object,rt=t.RegExp,nt=t.String,it=t.TypeError,ot=Je.prototype,st=$e.prototype,at=tt.prototype,ct=t["__core-js_shared__"],ut=st.toString,ft=at.hasOwnProperty,ht=0,lt=(r=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",dt=at.toString,pt=ut.call(tt),bt=Ct._,gt=rt("^"+ut.call(ft).replace(Pe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Rt?t.Buffer:n,wt=t.Symbol,It=t.Uint8Array,Bt=Buffer?Buffer.allocUnsafe:n,Pt=kr(tt.getPrototypeOf,tt),Mt=tt.create,Ot=at.propertyIsEnumerable,Lt=ot.splice,jt=wt?wt.isConcatSpreadable:n,rr=wt?wt.iterator:n,fr=wt?wt.toStringTag:n,Mr=function(){try{var e=Do(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),Or=t.clearTimeout!==Ct.clearTimeout&&t.clearTimeout,Rr=Ze&&Ze.now!==Ct.Date.now&&Ze.now,Lr=t.setTimeout!==Ct.setTimeout&&t.setTimeout,jr=et.ceil,Nr=et.floor,Dr=tt.getOwnPropertySymbols,Ur=Buffer?Buffer.isBuffer:n,Hr=t.isFinite,Kr=ot.join,zr=kr(tt.keys,tt),Fr=et.max,Wr=et.min,qr=Ze.now,Vr=t.parseInt,Gr=et.random,Yr=ot.reverse,Xr=Do(t,"DataView"),Jr=Do(t,"Map"),Zr=Do(t,"Promise"),Qr=Do(t,"Set"),$r=Do(t,"WeakMap"),en=Do(tt,"create"),tn=$r&&new $r,rn={},nn=fs(Xr),on=fs(Jr),sn=fs(Zr),an=fs(Qr),cn=fs($r),un=wt?wt.prototype:n,fn=un?un.valueOf:n,hn=un?un.toString:n;function ln(e){if(xa(e)&&!ya(e)&&!(e instanceof yn)){if(e instanceof bn)return e;if(ft.call(e,"__wrapped__"))return hs(e)}return new bn(e)}var dn=function(){function e(){}return function(t){if(!Ia(t))return{};if(Mt)return Mt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function pn(){}function bn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function yn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=L,this.__views__=[]}function vn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Rn(e,t,r,i,o,s){var a,c=t&f,u=t&h,d=t&l;if(r&&(a=o?r(e,i,o,s):r(e)),a!==n)return a;if(!Ia(e))return e;var p=ya(e);if(p){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ft.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!c)return to(e,a)}else{var b=Ko(e),y=b==V||b==G;if(wa(e))return Xi(e,c);if(b==Z||b==U||y&&!o){if(a=u||y?{}:Fo(e),!c)return u?function(e,t){return ro(e,Ho(e),t)}(e,function(e,t){return e&&ro(t,ic(t),e)}(a,e)):function(e,t){return ro(e,Uo(e),t)}(e,Pn(a,e))}else{if(!At[b])return o?e:{};a=function(e,t,r){var n,i,o,s=e.constructor;switch(t){case se:return Ji(e);case z:case F:return new s(+e);case ae:return function(e,t){var r=t?Ji(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case ce:case ue:case fe:case he:case le:case de:case pe:case be:case ye:return Zi(e,r);case Y:return new s;case X:case te:return new s(e);case $:return(o=new(i=e).constructor(i.source,Ke.exec(i))).lastIndex=i.lastIndex,o;case ee:return new s;case re:return n=e,fn?tt(fn.call(n)):{}}}(e,b,c)}}s||(s=new _n);var v=s.get(e);if(v)return v;if(s.set(e,a),Ma(e))return e.forEach(function(n){a.add(Rn(n,t,r,n,e,s))}),a;if(Ta(e))return e.forEach(function(n,i){a.set(i,Rn(n,t,r,i,e,s))}),a;var g=p?n:(d?u?Co:Po:u?ic:nc)(e);return qt(g||e,function(n,i){g&&(n=e[i=n]),xn(a,i,Rn(n,t,r,i,e,s))}),a}function Ln(e,t,r){var i=r.length;if(null==e)return!i;for(e=tt(e);i--;){var o=r[i],s=t[o],a=e[o];if(a===n&&!(o in e)||!s(a))return!1}return!0}function jn(e,t,r){if("function"!=typeof e)throw new it(s);return ns(function(){e.apply(n,r)},t)}function Nn(e,t,r,n){var o=-1,s=Xt,a=!0,c=e.length,u=[],f=t.length;if(!c)return u;r&&(t=Zt(t,pr(r))),n?(s=Jt,a=!1):t.length>=i&&(s=yr,a=!1,t=new wn(t));e:for(;++o-1},gn.prototype.set=function(e,t){var r=this.__data__,n=Tn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},mn.prototype.clear=function(){this.size=0,this.__data__={hash:new vn,map:new(Jr||gn),string:new vn}},mn.prototype.delete=function(e){var t=jo(this,e).delete(e);return this.size-=t?1:0,t},mn.prototype.get=function(e){return jo(this,e).get(e)},mn.prototype.has=function(e){return jo(this,e).has(e)},mn.prototype.set=function(e,t){var r=jo(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(e){return this.__data__.set(e,a),this},wn.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.clear=function(){this.__data__=new gn,this.size=0},_n.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},_n.prototype.get=function(e){return this.__data__.get(e)},_n.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.set=function(e,t){var r=this.__data__;if(r instanceof gn){var n=r.__data__;if(!Jr||n.length0&&r(a)?t>1?Fn(a,t-1,r,n,i):Qt(i,a):n||(i[i.length]=a)}return i}var Wn=so(),qn=so(!0);function Vn(e,t){return e&&Wn(e,t,nc)}function Gn(e,t){return e&&qn(e,t,nc)}function Yn(e,t){return Yt(t,function(t){return Sa(e[t])})}function Xn(e,t){for(var r=0,i=(t=qi(t,e)).length;null!=e&&rt}function $n(e,t){return null!=e&&ft.call(e,t)}function ei(e,t){return null!=e&&t in tt(e)}function ti(e,t,r){for(var i=r?Jt:Xt,o=e[0].length,s=e.length,a=s,c=Je(s),u=1/0,f=[];a--;){var h=e[a];a&&t&&(h=Zt(h,pr(t))),u=Wr(h.length,u),c[a]=!r&&(t||o>=120&&h.length>=120)?new wn(a&&h):n}h=e[0];var l=-1,d=c[0];e:for(;++l=a)return c;var u=r[n];return c*("desc"==u?-1:1)}}return e.index-t.index}(e,t,r)})}function vi(e,t,r){for(var n=-1,i=t.length,o={};++n-1;)a!==e&&Lt.call(a,c,1),Lt.call(e,c,1);return e}function mi(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;qo(i)?Lt.call(e,i,1):Ni(e,i)}}return e}function wi(e,t){return e+Nr(Gr()*(t-e+1))}function _i(e,t){var r="";if(!e||t<1||t>M)return r;do{t%2&&(r+=e),(t=Nr(t/2))&&(e+=e)}while(t);return r}function Ei(e,t){return is($o(e,t,Bc),e+"")}function Si(e){return Sn(lc(e))}function ki(e,t){var r=lc(e);return as(r,On(t,0,r.length))}function Ai(e,t,r,i){if(!Ia(e))return e;for(var o=-1,s=(t=qi(t,e)).length,a=s-1,c=e;null!=c&&++oi?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Je(i);++n>>1,s=e[o];null!==s&&!Ra(s)&&(r?s<=t:s=i){var f=t?null:Eo(e);if(f)return Ir(f);a=!1,o=yr,u=new wn}else u=t?[]:c;e:for(;++n=i?e:Bi(e,t,r)}var Yi=Or||function(e){return Ct.clearTimeout(e)};function Xi(e,t){if(t)return e.slice();var r=e.length,n=Bt?Bt(r):new e.constructor(r);return e.copy(n),n}function Ji(e){var t=new e.constructor(e.byteLength);return new It(t).set(new It(e)),t}function Zi(e,t){var r=t?Ji(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Qi(e,t){if(e!==t){var r=e!==n,i=null===e,o=e==e,s=Ra(e),a=t!==n,c=null===t,u=t==t,f=Ra(t);if(!c&&!f&&!s&&e>t||s&&a&&u&&!c&&!f||i&&a&&u||!r&&u||!o)return 1;if(!i&&!s&&!f&&e1?r[o-1]:n,a=o>2?r[2]:n;for(s=e.length>3&&"function"==typeof s?(o--,s):n,a&&Vo(r[0],r[1],a)&&(s=o<3?n:s,o=1),t=tt(t);++i-1?o[s?t[a]:a]:n}}function ho(e){return Bo(function(t){var r=t.length,i=r,o=bn.prototype.thru;for(e&&t.reverse();i--;){var a=t[i];if("function"!=typeof a)throw new it(s);if(o&&!c&&"wrapper"==Oo(a))var c=new bn([],!0)}for(i=c?i:r;++i1&&g.reverse(),h&&uc))return!1;var f=s.get(e);if(f&&s.get(t))return f==t;var h=-1,l=!0,b=r&p?new wn:n;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(Le,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return qt(D,function(r){var n="_."+r[0];t&r[1]&&!Xt(e,n)&&e.push(n)}),e.sort()}(function(e){var t=e.match(je);return t?t[1].split(Ne):[]}(n),r)))}function ss(e){var t=0,r=0;return function(){var i=qr(),o=T-(i-r);if(r=i,o>0){if(++t>=x)return arguments[0]}else t=0;return e.apply(n,arguments)}}function as(e,t){var r=-1,i=e.length,o=i-1;for(t=t===n?i:t;++r1?e[t-1]:n;return Cs(e,r="function"==typeof r?(e.pop(),r):n)});function Ds(e){var t=ln(e);return t.__chain__=!0,t}function Us(e,t){return t(e)}var Hs=Bo(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,o=function(t){return Mn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof yn&&qo(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:Us,args:[o],thisArg:n}),new bn(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e})):this.thru(o)});var Ks=no(function(e,t,r){ft.call(e,r)?++e[r]:Cn(e,r,1)});var zs=fo(bs),Fs=fo(ys);function Ws(e,t){return(ya(e)?qt:Dn)(e,Lo(t,3))}function qs(e,t){return(ya(e)?Vt:Un)(e,Lo(t,3))}var Vs=no(function(e,t,r){ft.call(e,r)?e[r].push(t):Cn(e,r,[t])});var Gs=Ei(function(e,t,r){var n=-1,i="function"==typeof t,o=ga(e)?Je(e.length):[];return Dn(e,function(e){o[++n]=i?Ft(t,e,r):ri(e,t,r)}),o}),Ys=no(function(e,t,r){Cn(e,r,t)});function Xs(e,t){return(ya(e)?Zt:hi)(e,Lo(t,3))}var Js=no(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var Zs=Ei(function(e,t){if(null==e)return[];var r=t.length;return r>1&&Vo(e,t[0],t[1])?t=[]:r>2&&Vo(t[0],t[1],t[2])&&(t=[t[0]]),yi(e,Fn(t,1),[])}),Qs=Rr||function(){return Ct.Date.now()};function $s(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,ko(e,E,n,n,n,n,t)}function ea(e,t){var r;if("function"!=typeof t)throw new it(s);return e=Ha(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var ta=Ei(function(e,t,r){var n=b;if(r.length){var i=Ar(r,Ro(ta));n|=w}return ko(e,n,t,r,i)}),ra=Ei(function(e,t,r){var n=b|y;if(r.length){var i=Ar(r,Ro(ra));n|=w}return ko(t,n,e,r,i)});function na(e,t,r){var i,o,a,c,u,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof e)throw new it(s);function b(t){var r=i,s=o;return i=o=n,h=t,c=e.apply(s,r)}function y(e){var r=e-f;return f===n||r>=t||r<0||d&&e-h>=a}function v(){var e=Qs();if(y(e))return g(e);u=ns(v,function(e){var r=t-(e-f);return d?Wr(r,a-(e-h)):r}(e))}function g(e){return u=n,p&&i?b(e):(i=o=n,c)}function m(){var e=Qs(),r=y(e);if(i=arguments,o=this,f=e,r){if(u===n)return function(e){return h=e,u=ns(v,t),l?b(e):c}(f);if(d)return u=ns(v,t),b(f)}return u===n&&(u=ns(v,t)),c}return t=za(t)||0,Ia(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Fr(za(r.maxWait)||0,t):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){u!==n&&Yi(u),h=0,i=f=o=u=n},m.flush=function(){return u===n?c:g(Qs())},m}var ia=Ei(function(e,t){return jn(e,1,t)}),oa=Ei(function(e,t,r){return jn(e,za(t)||0,r)});function sa(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new it(s);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(sa.Cache||mn),r}function aa(e){if("function"!=typeof e)throw new it(s);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}sa.Cache=mn;var ca=Vi(function(e,t){var r=(t=1==t.length&&ya(t[0])?Zt(t[0],pr(Lo())):Zt(Fn(t,1),pr(Lo()))).length;return Ei(function(n){for(var i=-1,o=Wr(n.length,r);++i=t}),ba=ni(function(){return arguments}())?ni:function(e){return xa(e)&&ft.call(e,"callee")&&!Ot.call(e,"callee")},ya=Je.isArray,va=Nt?pr(Nt):function(e){return xa(e)&&Zn(e)==se};function ga(e){return null!=e&&Aa(e.length)&&!Sa(e)}function ma(e){return xa(e)&&ga(e)}var wa=Ur||zc,_a=Dt?pr(Dt):function(e){return xa(e)&&Zn(e)==F};function Ea(e){if(!xa(e))return!1;var t=Zn(e);return t==q||t==W||"string"==typeof e.message&&"string"==typeof e.name&&!Pa(e)}function Sa(e){if(!Ia(e))return!1;var t=Zn(e);return t==V||t==G||t==K||t==Q}function ka(e){return"number"==typeof e&&e==Ha(e)}function Aa(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=M}function Ia(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xa(e){return null!=e&&"object"==typeof e}var Ta=Ut?pr(Ut):function(e){return xa(e)&&Ko(e)==Y};function Ba(e){return"number"==typeof e||xa(e)&&Zn(e)==X}function Pa(e){if(!xa(e)||Zn(e)!=Z)return!1;var t=Pt(e);if(null===t)return!0;var r=ft.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ut.call(r)==pt}var Ca=Ht?pr(Ht):function(e){return xa(e)&&Zn(e)==$};var Ma=Kt?pr(Kt):function(e){return xa(e)&&Ko(e)==ee};function Oa(e){return"string"==typeof e||!ya(e)&&xa(e)&&Zn(e)==te}function Ra(e){return"symbol"==typeof e||xa(e)&&Zn(e)==re}var La=zt?pr(zt):function(e){return xa(e)&&Aa(e.length)&&!!kt[Zn(e)]};var ja=mo(fi),Na=mo(function(e,t){return e<=t});function Da(e){if(!e)return[];if(ga(e))return Oa(e)?Br(e):to(e);if(rr&&e[rr])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[rr]());var t=Ko(e);return(t==Y?Sr:t==ee?Ir:lc)(e)}function Ua(e){return e?(e=za(e))===C||e===-C?(e<0?-1:1)*O:e==e?e:0:0===e?e:0}function Ha(e){var t=Ua(e),r=t%1;return t==t?r?t-r:t:0}function Ka(e){return e?On(Ha(e),0,L):0}function za(e){if("number"==typeof e)return e;if(Ra(e))return R;if(Ia(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ia(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Me,"");var r=Fe.test(e);return r||qe.test(e)?Tt(e.slice(2),r?2:8):ze.test(e)?R:+e}function Fa(e){return ro(e,ic(e))}function Wa(e){return null==e?"":Li(e)}var qa=io(function(e,t){if(Jo(t)||ga(t))ro(t,nc(t),e);else for(var r in t)ft.call(t,r)&&xn(e,r,t[r])}),Va=io(function(e,t){ro(t,ic(t),e)}),Ga=io(function(e,t,r,n){ro(t,ic(t),e,n)}),Ya=io(function(e,t,r,n){ro(t,nc(t),e,n)}),Xa=Bo(Mn);var Ja=Ei(function(e,t){e=tt(e);var r=-1,i=t.length,o=i>2?t[2]:n;for(o&&Vo(t[0],t[1],o)&&(i=1);++r1),t}),ro(e,Co(e),r),n&&(r=Rn(r,f|h|l,xo));for(var i=t.length;i--;)Ni(r,t[i]);return r});var cc=Bo(function(e,t){return null==e?{}:function(e,t){return vi(e,t,function(t,r){return $a(e,r)})}(e,t)});function uc(e,t){if(null==e)return{};var r=Zt(Co(e),function(e){return[e]});return t=Lo(t),vi(e,r,function(e,r){return t(e,r[0])})}var fc=So(nc),hc=So(ic);function lc(e){return null==e?[]:br(e,nc(e))}var dc=co(function(e,t,r){return t=t.toLowerCase(),e+(r?pc(t):t)});function pc(e){return Ec(Wa(e).toLowerCase())}function bc(e){return(e=Wa(e))&&e.replace(Ge,mr).replace(vt,"")}var yc=co(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),vc=co(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),gc=ao("toLowerCase");var mc=co(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()});var wc=co(function(e,t,r){return e+(r?" ":"")+Ec(t)});var _c=co(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),Ec=ao("toUpperCase");function Sc(e,t,r){return e=Wa(e),(t=r?n:t)===n?function(e){return _t.test(e)}(e)?function(e){return e.match(mt)||[]}(e):function(e){return e.match(De)||[]}(e):e.match(t)||[]}var kc=Ei(function(e,t){try{return Ft(e,n,t)}catch(e){return Ea(e)?e:new Qe(e)}}),Ac=Bo(function(e,t){return qt(t,function(t){t=us(t),Cn(e,t,ta(e[t],e))}),e});function Ic(e){return function(){return e}}var xc=ho(),Tc=ho(!0);function Bc(e){return e}function Pc(e){return ai("function"==typeof e?e:Rn(e,f))}var Cc=Ei(function(e,t){return function(r){return ri(r,e,t)}}),Mc=Ei(function(e,t){return function(r){return ri(e,r,t)}});function Oc(e,t,r){var n=nc(t),i=Yn(t,n);null!=r||Ia(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Yn(t,nc(t)));var o=!(Ia(r)&&"chain"in r&&!r.chain),s=Sa(e);return qt(i,function(r){var n=t[r];e[r]=n,s&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=to(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Qt([this.value()],arguments))})}),e}function Rc(){}var Lc=yo(Zt),jc=yo(Gt),Nc=yo(tr);function Dc(e){return Go(e)?ur(us(e)):function(e){return function(t){return Xn(t,e)}}(e)}var Uc=go(),Hc=go(!0);function Kc(){return[]}function zc(){return!1}var Fc=bo(function(e,t){return e+t},0),Wc=_o("ceil"),qc=bo(function(e,t){return e/t},1),Vc=_o("floor");var Gc,Yc=bo(function(e,t){return e*t},1),Xc=_o("round"),Jc=bo(function(e,t){return e-t},0);return ln.after=function(e,t){if("function"!=typeof t)throw new it(s);return e=Ha(e),function(){if(--e<1)return t.apply(this,arguments)}},ln.ary=$s,ln.assign=qa,ln.assignIn=Va,ln.assignInWith=Ga,ln.assignWith=Ya,ln.at=Xa,ln.before=ea,ln.bind=ta,ln.bindAll=Ac,ln.bindKey=ra,ln.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ya(e)?e:[e]},ln.chain=Ds,ln.chunk=function(e,t,r){t=(r?Vo(e,t,r):t===n)?1:Fr(Ha(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,s=0,a=Je(jr(i/t));oo?0:o+r),(i=i===n||i>o?o:Ha(i))<0&&(i+=o),i=r>i?0:Ka(i);r>>0)?(e=Wa(e))&&("string"==typeof t||null!=t&&!Ca(t))&&!(t=Li(t))&&Er(e)?Gi(Br(e),0,r):e.split(t,r):[]},ln.spread=function(e,t){if("function"!=typeof e)throw new it(s);return t=null==t?0:Fr(Ha(t),0),Ei(function(r){var n=r[t],i=Gi(r,0,t);return n&&Qt(i,n),Ft(e,this,i)})},ln.tail=function(e){var t=null==e?0:e.length;return t?Bi(e,1,t):[]},ln.take=function(e,t,r){return e&&e.length?Bi(e,0,(t=r||t===n?1:Ha(t))<0?0:t):[]},ln.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?Bi(e,(t=i-(t=r||t===n?1:Ha(t)))<0?0:t,i):[]},ln.takeRightWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3),!1,!0):[]},ln.takeWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3)):[]},ln.tap=function(e,t){return t(e),e},ln.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new it(s);return Ia(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),na(e,t,{leading:n,maxWait:t,trailing:i})},ln.thru=Us,ln.toArray=Da,ln.toPairs=fc,ln.toPairsIn=hc,ln.toPath=function(e){return ya(e)?Zt(e,us):Ra(e)?[e]:to(cs(Wa(e)))},ln.toPlainObject=Fa,ln.transform=function(e,t,r){var n=ya(e),i=n||wa(e)||La(e);if(t=Lo(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:Ia(e)&&Sa(o)?dn(Pt(e)):{}}return(i?qt:Vn)(e,function(e,n,i){return t(r,e,n,i)}),r},ln.unary=function(e){return $s(e,1)},ln.union=xs,ln.unionBy=Ts,ln.unionWith=Bs,ln.uniq=function(e){return e&&e.length?ji(e):[]},ln.uniqBy=function(e,t){return e&&e.length?ji(e,Lo(t,2)):[]},ln.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?ji(e,n,t):[]},ln.unset=function(e,t){return null==e||Ni(e,t)},ln.unzip=Ps,ln.unzipWith=Cs,ln.update=function(e,t,r){return null==e?e:Di(e,t,Wi(r))},ln.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:Di(e,t,Wi(r),i)},ln.values=lc,ln.valuesIn=function(e){return null==e?[]:br(e,ic(e))},ln.without=Ms,ln.words=Sc,ln.wrap=function(e,t){return ua(Wi(t),e)},ln.xor=Os,ln.xorBy=Rs,ln.xorWith=Ls,ln.zip=js,ln.zipObject=function(e,t){return zi(e||[],t||[],xn)},ln.zipObjectDeep=function(e,t){return zi(e||[],t||[],Ai)},ln.zipWith=Ns,ln.entries=fc,ln.entriesIn=hc,ln.extend=Va,ln.extendWith=Ga,Oc(ln,ln),ln.add=Fc,ln.attempt=kc,ln.camelCase=dc,ln.capitalize=pc,ln.ceil=Wc,ln.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=za(r))==r?r:0),t!==n&&(t=(t=za(t))==t?t:0),On(za(e),t,r)},ln.clone=function(e){return Rn(e,l)},ln.cloneDeep=function(e){return Rn(e,f|l)},ln.cloneDeepWith=function(e,t){return Rn(e,f|l,t="function"==typeof t?t:n)},ln.cloneWith=function(e,t){return Rn(e,l,t="function"==typeof t?t:n)},ln.conformsTo=function(e,t){return null==t||Ln(e,t,nc(t))},ln.deburr=bc,ln.defaultTo=function(e,t){return null==e||e!=e?t:e},ln.divide=qc,ln.endsWith=function(e,t,r){e=Wa(e),t=Li(t);var i=e.length,o=r=r===n?i:On(Ha(r),0,i);return(r-=t.length)>=0&&e.slice(r,o)==t},ln.eq=la,ln.escape=function(e){return(e=Wa(e))&&Se.test(e)?e.replace(_e,wr):e},ln.escapeRegExp=function(e){return(e=Wa(e))&&Ce.test(e)?e.replace(Pe,"\\$&"):e},ln.every=function(e,t,r){var i=ya(e)?Gt:Hn;return r&&Vo(e,t,r)&&(t=n),i(e,Lo(t,3))},ln.find=zs,ln.findIndex=bs,ln.findKey=function(e,t){return nr(e,Lo(t,3),Vn)},ln.findLast=Fs,ln.findLastIndex=ys,ln.findLastKey=function(e,t){return nr(e,Lo(t,3),Gn)},ln.floor=Vc,ln.forEach=Ws,ln.forEachRight=qs,ln.forIn=function(e,t){return null==e?e:Wn(e,Lo(t,3),ic)},ln.forInRight=function(e,t){return null==e?e:qn(e,Lo(t,3),ic)},ln.forOwn=function(e,t){return e&&Vn(e,Lo(t,3))},ln.forOwnRight=function(e,t){return e&&Gn(e,Lo(t,3))},ln.get=Qa,ln.gt=da,ln.gte=pa,ln.has=function(e,t){return null!=e&&zo(e,t,$n)},ln.hasIn=$a,ln.head=gs,ln.identity=Bc,ln.includes=function(e,t,r,n){e=ga(e)?e:lc(e),r=r&&!n?Ha(r):0;var i=e.length;return r<0&&(r=Fr(i+r,0)),Oa(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&or(e,t,r)>-1},ln.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:Ha(r);return i<0&&(i=Fr(n+i,0)),or(e,t,i)},ln.inRange=function(e,t,r){return t=Ua(t),r===n?(r=t,t=0):r=Ua(r),function(e,t,r){return e>=Wr(t,r)&&e=-M&&e<=M},ln.isSet=Ma,ln.isString=Oa,ln.isSymbol=Ra,ln.isTypedArray=La,ln.isUndefined=function(e){return e===n},ln.isWeakMap=function(e){return xa(e)&&Ko(e)==ie},ln.isWeakSet=function(e){return xa(e)&&Zn(e)==oe},ln.join=function(e,t){return null==e?"":Kr.call(e,t)},ln.kebabCase=yc,ln.last=Es,ln.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Ha(r))<0?Fr(i+o,0):Wr(o,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,o):ir(e,ar,o,!0)},ln.lowerCase=vc,ln.lowerFirst=gc,ln.lt=ja,ln.lte=Na,ln.max=function(e){return e&&e.length?Kn(e,Bc,Qn):n},ln.maxBy=function(e,t){return e&&e.length?Kn(e,Lo(t,2),Qn):n},ln.mean=function(e){return cr(e,Bc)},ln.meanBy=function(e,t){return cr(e,Lo(t,2))},ln.min=function(e){return e&&e.length?Kn(e,Bc,fi):n},ln.minBy=function(e,t){return e&&e.length?Kn(e,Lo(t,2),fi):n},ln.stubArray=Kc,ln.stubFalse=zc,ln.stubObject=function(){return{}},ln.stubString=function(){return""},ln.stubTrue=function(){return!0},ln.multiply=Yc,ln.nth=function(e,t){return e&&e.length?bi(e,Ha(t)):n},ln.noConflict=function(){return Ct._===this&&(Ct._=bt),this},ln.noop=Rc,ln.now=Qs,ln.pad=function(e,t,r){e=Wa(e);var n=(t=Ha(t))?Tr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return vo(Nr(i),r)+e+vo(jr(i),r)},ln.padEnd=function(e,t,r){e=Wa(e);var n=(t=Ha(t))?Tr(e):0;return t&&nt){var i=e;e=t,t=i}if(r||e%1||t%1){var o=Gr();return Wr(e+o*(t-e+xt("1e-"+((o+"").length-1))),t)}return wi(e,t)},ln.reduce=function(e,t,r){var n=ya(e)?$t:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Dn)},ln.reduceRight=function(e,t,r){var n=ya(e)?er:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Un)},ln.repeat=function(e,t,r){return t=(r?Vo(e,t,r):t===n)?1:Ha(t),_i(Wa(e),t)},ln.replace=function(){var e=arguments,t=Wa(e[0]);return e.length<3?t:t.replace(e[1],e[2])},ln.result=function(e,t,r){var i=-1,o=(t=qi(t,e)).length;for(o||(o=1,e=n);++iM)return[];var r=L,n=Wr(e,L);t=Lo(t),e-=L;for(var i=dr(n,t);++r=s)return e;var c=r-Tr(i);if(c<1)return i;var u=a?Gi(a,0,c).join(""):e.slice(0,c);if(o===n)return u+i;if(a&&(c+=u.length-c),Ca(o)){if(e.slice(c).search(o)){var f,h=u;for(o.global||(o=rt(o.source,Wa(Ke.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;u=u.slice(0,l===n?c:l)}}else if(e.indexOf(Li(o),c)!=c){var d=u.lastIndexOf(o);d>-1&&(u=u.slice(0,d))}return u+i},ln.unescape=function(e){return(e=Wa(e))&&Ee.test(e)?e.replace(we,Pr):e},ln.uniqueId=function(e){var t=++ht;return Wa(e)+t},ln.upperCase=_c,ln.upperFirst=Ec,ln.each=Ws,ln.eachRight=qs,ln.first=gs,Oc(ln,(Gc={},Vn(ln,function(e,t){ft.call(ln.prototype,t)||(Gc[t]=e)}),Gc),{chain:!1}),ln.VERSION="4.17.11",qt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){ln[e].placeholder=ln}),qt(["drop","take"],function(e,t){yn.prototype[e]=function(r){r=r===n?1:Fr(Ha(r),0);var i=this.__filtered__&&!t?new yn(this):this.clone();return i.__filtered__?i.__takeCount__=Wr(r,i.__takeCount__):i.__views__.push({size:Wr(r,L),type:e+(i.__dir__<0?"Right":"")}),i},yn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),qt(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r==B||3==r;yn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Lo(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),qt(["head","last"],function(e,t){var r="take"+(t?"Right":"");yn.prototype[e]=function(){return this[r](1).value()[0]}}),qt(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");yn.prototype[e]=function(){return this.__filtered__?new yn(this):this[r](1)}}),yn.prototype.compact=function(){return this.filter(Bc)},yn.prototype.find=function(e){return this.filter(e).head()},yn.prototype.findLast=function(e){return this.reverse().find(e)},yn.prototype.invokeMap=Ei(function(e,t){return"function"==typeof e?new yn(this):this.map(function(r){return ri(r,e,t)})}),yn.prototype.reject=function(e){return this.filter(aa(Lo(e)))},yn.prototype.slice=function(e,t){e=Ha(e);var r=this;return r.__filtered__&&(e>0||t<0)?new yn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=Ha(t))<0?r.dropRight(-t):r.take(t-e)),r)},yn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},yn.prototype.toArray=function(){return this.take(L)},Vn(yn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=ln[i?"take"+("last"==t?"Right":""):t],s=i||/^find/.test(t);o&&(ln.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof yn,u=a[0],f=c||ya(t),h=function(e){var t=o.apply(ln,Qt([e],a));return i&&l?t[0]:t};f&&r&&"function"==typeof u&&1!=u.length&&(c=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=c&&!d;if(!s&&f){t=b?t:new yn(this);var y=e.apply(t,a);return y.__actions__.push({func:Us,args:[h],thisArg:n}),new bn(y,l)}return p&&b?e.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),qt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ot[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);ln.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(ya(i)?i:[],e)}return this[r](function(r){return t.apply(ya(r)?r:[],e)})}}),Vn(yn.prototype,function(e,t){var r=ln[t];if(r){var n=r.name+"";(rn[n]||(rn[n]=[])).push({name:t,func:r})}}),rn[lo(n,y).name]=[{name:"wrapper",func:n}],yn.prototype.clone=function(){var e=new yn(this.__wrapped__);return e.__actions__=to(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=to(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=to(this.__views__),e},yn.prototype.reverse=function(){if(this.__filtered__){var e=new yn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},yn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=ya(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},ln.prototype.plant=function(e){for(var t,r=this;r instanceof pn;){var i=hs(r);i.__index__=0,i.__values__=n,t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},ln.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof yn){var t=e;return this.__actions__.length&&(t=new yn(this)),(t=t.reverse()).__actions__.push({func:Us,args:[Is],thisArg:n}),new bn(t,this.__chain__)}return this.thru(Is)},ln.prototype.toJSON=ln.prototype.valueOf=ln.prototype.value=function(){return Hi(this.__wrapped__,this.__actions__)},ln.prototype.first=ln.prototype.head,rr&&(ln.prototype[rr]=function(){return this}),ln}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Ct._=Cr,define(function(){return Cr})):Ot?((Ot.exports=Cr)._=Cr,Mt._=Cr):Ct._=Cr}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],263:[function(e,t,r){"use strict";var n=e("inherits"),i=e("hash-base"),Buffer=e("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(e,t){return e<>>32-t}function c(e,t,r,n,i,o,s){return a(e+(t&r|~t&n)+i+o|0,s)+t|0}function u(e,t,r,n,i,o,s){return a(e+(t&n|r&~n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return a(e+(t^r^n)+i+o|0,s)+t|0}function h(e,t,r,n,i,o,s){return a(e+(r^(t|~n))+i+o|0,s)+t|0}n(s,i),s.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),s,r,e[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),s,r,e[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),s,r,e[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),s,r,e[15],1236535329,22),i=u(i,s=u(s,r=u(r,n,i,s,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),s,r,e[0],3921069994,20),i=u(i,s=u(s,r=u(r,n,i,s,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),s,r,e[4],3889429448,20),i=u(i,s=u(s,r=u(r,n,i,s,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),s,r,e[8],1163531501,20),i=u(i,s=u(s,r=u(r,n,i,s,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),s,r,e[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),s,r,e[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),s,r,e[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),s,r,e[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),s,r,e[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),s,r,e[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),s,r,e[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),s,r,e[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=s},{"hash-base":243,inherits:259,"safe-buffer":322}],264:[function(e,t,r){(function(Buffer){t.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var r=e.length,n=e.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),s=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var u=e.shrn(c),f=a.toRed(o);t>0;t--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(u);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;t--){var f=this._randrange(new n(2),s),h=e.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(u)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],268:[function(e,t,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(e,t,r){if(!(e0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?c(r=e,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],269:[function(e,t,r){(function(Buffer){var t=e("create-hmac"),n=Math.pow(2,30)-1;function i(e,r,i,o,s){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(i<0)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(o<0||o>n)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(e)||(e=new Buffer(e,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,u,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=t(s,e).update(l).digest();a||(a=p.length,u=new Buffer(a),c=o-((f=Math.ceil(o/a))-1)*a),p.copy(u,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(t).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?u(new s(t),l):a(t,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(e,t){var r=e.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==t[0])throw new Error("decryption error");var a=t.slice(1,s+1),u=t.slice(s+1),f=o(a,i(u,s)),h=o(u,i(f,r-s-1));if(function(e,t){e=Buffer.from(e),t=Buffer.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var s=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,"safe-buffer":322}],295:[function(e,t,r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),s=e("./mgf"),a=e("./xor"),c=e("bn.js"),u=e("./withPublic"),f=e("browserify-rsa"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t,r){var h;h=e.padding?e.padding:r?1:4;var l,d=n(e);if(4===h)l=function(e,t){var r=e.modulus.byteLength(),n=t.length,u=o("sha1").update(Buffer.alloc(0)).digest(),f=u.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([u,l,Buffer.alloc(1,1),t],d),s(p,d)),y=a(p,s(b,f));return new c(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,t);else if(1===h)l=function(e,t,r){var n,o=t.length,s=e.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(e){var t,r=Buffer.allocUnsafe(e),n=0,o=i(2*e),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):u(l,d)}},{"./mgf":273,"./withPublic":296,"./xor":297,"bn.js":90,"browserify-rsa":288,"create-hash":139,"parse-asn1":293,randombytes:306,"safe-buffer":322}],296:[function(e,t,r){var n=e("bn.js"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t){return Buffer.from(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":322}],297:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++ne.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],299:[function(e,t,r){(function(e,n){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof r)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else Q=e()}(function(){"use strict";var t=!1;try{throw new Error}catch(e){t=!!e.stack}var r,i=S(),o=function(){},s=function(){var t={task:void 0,next:null},r=t,i=!1,o=void 0,a=!1;function c(){for(;t.next;){var e=(t=t.next).task;t.task=void 0;var r=t.domain;r&&(t.domain=void 0,r.enter());try{e()}catch(e){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),e;setTimeout(function(){throw e},0)}r&&r.exit()}i=!1}if(s=function(t){r=r.next={task:t,domain:a&&e.domain,next:null},i||(i=!0,o())},void 0!==e&&e.nextTick)a=!0,o=function(){e.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){o=f,u.port1.onmessage=c,c()};var f=function(){u.port2.postMessage(0)};o=function(){setTimeout(c,0),f()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(e){return function(){return a.apply(e,arguments)}}var u,f=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(t)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=_(e[0].indexOf("@")>0?e[1]:e[2]);if(!n)return;return r=n[0],n[1]}}function k(e){return C(e)?e:M(e)?(t=e,r=A(),s(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):K(e);var t,r}function A(){var e,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(t,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){e.promiseDispatch.apply(e,a)})},o.valueOf=function(){if(r)return o;var t=P(e);return C(t)&&(e=t),t},o.inspect=function(){return e?e.inspect():{state:"pending"}},k.longStackSupport&&t)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1)}function a(t){e=t,o.source=t,h(r,function(e,r){s(function(){t.promiseDispatch.apply(t,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(t){e||a(k(t))},i.fulfill=function(t){e||a(K(t))},i.reject=function(t){e||a(H(t))},i.notify=function(t){e||h(n,function(e,r){s(function(){r(t)})},void 0)},i}function I(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=A();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function x(e){return I(function(t,r){for(var n=0,i=e.length;n2?e.resolve(f(arguments,1)):e.resolve(r)}},k.Promise=I,k.promise=I,I.race=x,I.all=W,I.reject=H,I.resolve=k,k.passByCopy=function(e){return e},T.prototype.passByCopy=function(){return this},k.join=function(e,t){return k(e).join(t)},T.prototype.join=function(e){return k([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},k.race=x,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(e,t,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return H(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){w(e,n);try{return t(e)}catch(e){return H(e)}}return H(e)}(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(n=!0,!k.onerror)throw e;k.onerror(e)}n||i.notify(t)}]),i.promise},k.when=B,T.prototype.thenResolve=function(e){return this.then(function(){return e})},k.thenResolve=function(e,t){return k(e).thenResolve(t)},T.prototype.thenReject=function(e){return this.then(function(){throw e})},k.thenReject=function(e,t){return k(e).thenReject(t)},k.nearer=P,k.isPromise=C,k.isPromiseAlike=M,k.isPending=function(e){return C(e)&&"pending"===e.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(e){return!C(e)||"fulfilled"===e.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(e){return C(e)&&"rejected"===e.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var O,R,L,j=[],N=[],D=!0;function U(){j.length=0,N.length=0,D||(D=!0)}function H(e){var t=T({when:function(t){return t&&function(e){if(D){var t=l(N,e);-1!==t&&(N.splice(t,1),j.splice(t,1))}}(this),t?t(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,t){D&&(N.push(e),t&&void 0!==t.stack?j.push(t.stack):j.push("(no stack) "+t))}(t,e),t}function K(e){return T({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return y(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function z(e,t,r){return k(e).spread(t,r)}function F(e,t,r){return k(e).dispatch(t,r)}function W(e){return B(e,function(e){var t=0,r=A();return h(e,function(n,i,o){var s;C(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,B(i,function(n){e[o]=n,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:o,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function q(e){return B(e,function(e){return e=d(e,k),B(W(d(e,function(e){return B(e,o,o)})),function(){return e})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),D=!1},U(),k.reject=H,k.fulfill=K,k.master=function(e){return T({isDef:function(){}},function(t,r){return F(e,t,r)},function(){return k(e).inspect()})},k.spread=z,T.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},k.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=r[e](t)}catch(e){return H(e)}return o.done?o.value:B(o.value,n,i)}try{o=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===v(e)||e instanceof u}(e)?e.value:H(e)}return B(o,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}},k.spawn=function(e){k.done(k.async(e)())},k.return=function(e){throw new u(e)},k.promised=function(e){return function(){return z([this,W(arguments)],function(t,r){return e.apply(t,r)})}},k.dispatch=F,T.prototype.dispatch=function(e,t){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},k.get=function(e,t){return k(e).dispatch("get",[t])},T.prototype.get=function(e){return this.dispatch("get",[e])},k.set=function(e,t,r){return k(e).dispatch("set",[t,r])},T.prototype.set=function(e,t){return this.dispatch("set",[e,t])},k.del=k.delete=function(e,t){return k(e).dispatch("delete",[t])},T.prototype.del=T.prototype.delete=function(e){return this.dispatch("delete",[e])},k.mapply=k.post=function(e,t,r){return k(e).dispatch("post",[t,r])},T.prototype.mapply=T.prototype.post=function(e,t){return this.dispatch("post",[e,t])},k.send=k.mcall=k.invoke=function(e,t){return k(e).dispatch("post",[t,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(e){return this.dispatch("post",[e,f(arguments,1)])},k.fapply=function(e,t){return k(e).dispatch("apply",[void 0,t])},T.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},k.try=k.fcall=function(e){return k(e).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(e){var t=k(e),r=f(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var e=this,t=f(arguments);return function(){return e.dispatch("apply",[this,t.concat(f(arguments))])}},k.keys=function(e){return k(e).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=W,T.prototype.all=function(){return W(this)},k.allResolved=(O=q,R="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(R+" is deprecated, use "+L+" instead.",new Error("").stack),O.apply(O,arguments)}),T.prototype.allResolved=function(){return q(this)},k.allSettled=function(e){return k(e).allSettled()},T.prototype.allSettled=function(){return this.then(function(e){return W(d(e,function(e){function t(){return e.inspect()}return(e=k(e)).then(t,t)}))})},k.fail=k.catch=function(e,t){return k(e).then(void 0,t)},T.prototype.fail=T.prototype.catch=function(e){return this.then(void 0,e)},k.progress=function(e,t){return k(e).then(void 0,void 0,t)},T.prototype.progress=function(e){return this.then(void 0,void 0,e)},k.fin=k.finally=function(e,t){return k(e).finally(t)},T.prototype.fin=T.prototype.finally=function(e){return e=k(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},k.done=function(e,t,r,n){return k(e).done(t,r,n)},T.prototype.done=function(t,r,n){var i=function(e){s(function(){if(w(e,o),!k.onerror)throw e;k.onerror(e)})},o=t||r||n?this.then(t,r,n):this;"object"==typeof e&&e&&e.domain&&(i=e.domain.bind(i)),o.then(void 0,i)},k.timeout=function(e,t,r){return k(e).timeout(t,r)},T.prototype.timeout=function(e,t){var r=A(),n=setTimeout(function(){r.reject(new Error(t||"Timed out after "+e+" ms"))},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},k.delay=function(e,t){return void 0===t&&(t=e,e=void 0),k(e).delay(t)},T.prototype.delay=function(e){return this.then(function(t){var r=A();return setTimeout(function(){r.resolve(t)},e),r.promise})},k.nfapply=function(e,t){return k(e).nfapply(t)},T.prototype.nfapply=function(e){var t=A(),r=f(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},k.nfcall=function(e){var t=f(arguments,1);return k(e).nfapply(t)},T.prototype.nfcall=function(){var e=f(arguments),t=A();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},k.nfbind=k.denodeify=function(e){var t=f(arguments,1);return function(){var r=t.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(e).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var e=f(arguments);return e.unshift(this),k.denodeify.apply(void 0,e)},k.nbind=function(e,t){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return e.apply(t,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var e=f(arguments,0);return e.unshift(this),k.nbind.apply(void 0,e)},k.nmapply=k.npost=function(e,t,r){return k(e).npost(t,r)},T.prototype.nmapply=T.prototype.npost=function(e,t){var r=f(t||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[e,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(e,t){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(e).dispatch("post",[t,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(e){var t=f(arguments,1),r=A();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},k.nodeify=function(e,t){return k(e).nodeify(t)},T.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){s(function(){e(null,t)})},function(t){s(function(){e(t)})})};var V=S();return k})}).call(this,e("_process"),e("timers").setImmediate)},{_process:271,timers:349}],300:[function(e,t,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],301:[function(e,t,r){var n=e("bops"),i=e("./qrcode.js"),o=e("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(e,t,r,n){var o,s,a,c=Array.prototype.slice.call(arguments);if(n=c.pop(),e=c.shift(),t=c.shift(),r=c.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(t,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(e,r,n,i){t=r,o=n,s=e,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var u=new i.QRCode(o,a),f=this.scale||4,h=e.getContext("2d"),l=0;u.addData(t),u.make();var d=this.marginWidth(),p=d;l=this.dataWidth(u)+2*d,this.resetCanvas(e,h,l);for(var b=0,y=u.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(e,n,(o||{}).version,function(t,r,i,o){e=r,level=i,error=t,n=o}),level){try{var s,a=new i.QRCode(level,n),c=(this.scale,0),u=0;a.addData(e),a.make(),c=this.dataWidth(a,1),s=new this.Array(c*c);for(var f=0,h=a.getModuleCount();fe&&e>0&&(e=this.scale*this.marginScaleFactor),e},dataWidth:function(e,t){return e.getModuleCount()*(t||this.scale||4)},resetCanvas:function(e,t,r){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.style.height=e.height=r,e.style.width=e.width=r,this.color.light?(t.fillStyle=this.color.light,t.fillRect(0,0,e.width,e.height)):t.clearRect(0,0,e.width,e.height)}}},{"./qrcapacitytable.js":300,"./qrcode.js":302,bops:91}],302:[function(e,t,r){var n=e("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(e){this.mode=a.MODE_8BIT_BYTE,this.data=e;this.parsedData=n.from(e)}o.prototype={addData:function(e){var t=new s(e);this.dataList.push(t),this.dataCache=null},isDark:function(e,t){if(e<0||this.moduleCount<=e||t<0||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,t){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(e,t){for(var r=-1;r<=7;r++)if(!(e+r<=-1||this.moduleCount<=e+r))for(var n=-1;n<=7;n++)t+n<=-1||this.moduleCount<=t+n||(this.modules[e+r][t+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var e=0,t=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=v.getLostPoint(this);(0==r||e>n)&&(e=n,t=r)}return t},setupTimingPattern:function(){for(var e=8;e>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!e&&1==(t>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(e,t){for(var r=this.errorCorrectLevel<<3|t,n=v.getBCHTypeInfo(r),i=0;i<15;i++){var o=!e&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!e&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var c=!1;o>>i&1)),v.getMask(t,n,s-a)&&(c=!c),this.modules[n][s-a]=c,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(e,t,r){for(var n=_.getRSBlocks(e,t),i=new E,s=0;s8*c)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*c+")");for(i.getLengthInBits()+4<=8*c&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*c||(i.put(o.PAD0,8),i.getLengthInBits()>=8*c));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(e,t){for(var r=0,n=0,o=0,s=new i(t.length),a=new i(t.length),c=0;c=0?d.get(p):0}}var b=0;for(h=0;h=0;)t^=v.G15<=0;)t^=v.G18<>>=1;return t},getPatternPosition:function(e){return v.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,r){switch(e){case u:return(t+r)%2==0;case f:return t%2==0;case h:return r%3==0;case l:return(t+r)%3==0;case d:return(Math.floor(t/2)+Math.floor(r/3))%2==0;case p:return t*r%2+t*r%3==0;case b:return(t*r%2+t*r%3)%2==0;case y:return(t*r%3+(t+r)%2)%2==0;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)e-=255;return g.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)g.EXP_TABLE[m]=1<>>7-e%8&1)},put:function(e,t){for(var r=0;r>>t-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}}},{bops:91}],303:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],304:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var o=new n.Uint8Array(e);e>0&&i.getRandomValues(o);var s=Buffer.from(o.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:271,"safe-buffer":322}],307:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),s=e("randombytes"),Buffer=o.Buffer,a=o.kMaxLength,c=n.crypto||n.msCrypto,u=Math.pow(2,32)-1;function f(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>u||e<0)throw new TypeError("offset must be a uint32");if(e>a||e>t)throw new RangeError("offset out of range")}function h(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>u||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>a)throw new RangeError("buffer too small")}function l(e,r,n,i){if(t.browser){var o=e.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return s(n).copy(e,r),e;s(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(t,e.length),h(r,t,e.length),l(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(t,e.length),void 0===r&&(r=e.length-t);return h(r,t,e.length),l(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:271,randombytes:306,"safe-buffer":322}],308:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":309}],309:[function(e,t,r){"use strict";var n=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),u=0;u0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):A(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=_?e=_:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(l("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(k,e):k(e))}function k(e){l("emit readable"),e.emit("readable"),B(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function C(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function O(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?C(this):S(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&C(this),null;var n,i=t.needReadable;return l("need readable",i),(0===t.length||t.length-e0?P(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&C(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?f:m;function u(t,r){l("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),e.removeListener("close",v),e.removeListener("finish",g),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",u),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function f(){l("onend"),e.end()}o.endEmitted?i.nextTick(c):n.once("end",c),e.on("unpipe",u);var h=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,B(e))}}(n);e.on("drain",h);var d=!1;var p=!1;function b(t){l("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==O(o.pipes,e))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){l("onerror",t),m(),e.removeListener("error",y),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",g),m()}function g(){l("onfinish"),e.removeListener("close",v),m()}function m(){l("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",v),e.once("finish",g),e.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),e},g.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=y;var u=e("core-util-is");u.inherits=e("inherits");var f={deprecate:e("util-deprecate")},h=e("./internal/streams/stream"),Buffer=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,u=t.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?c(m,e,r,s,i):m(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(t){if(a=a||e("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function g(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function m(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,g(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(g(e,t,!1,t.objectMode?1:u.length,u,f,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(v,h),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===v&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(e)&&(e=function(e){return Buffer.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":309,"./internal/streams/destroy":315,"./internal/streams/stream":316,_process:271,"core-util-is":137,inherits:259,"process-nextick-args":270,"safe-buffer":322,timers:349,"util-deprecate":358}],314:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,t.copy(r,n),s+=o.data.length,o=o.next;return i},e}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":322,util:104}],315:[function(e,t,r){"use strict";var n=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":270}],316:[function(e,t,r){t.exports=e("events").EventEmitter},{events:239}],317:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":318}],318:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":309,"./lib/_stream_passthrough.js":310,"./lib/_stream_readable.js":311,"./lib/_stream_transform.js":312,"./lib/_stream_writable.js":313}],319:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":318}],320:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":313}],321:[function(e,t,r){"use strict";var Buffer=e("buffer").Buffer,n=e("inherits"),i=e("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(e,t){return e<>>32-t}function p(e,t,r,n,i,o,s,a){return d(e+(t^r^n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return d(e+(t&r|~t&n)+o+s|0,a)+i|0}function y(e,t,r,n,i,o,s,a){return d(e+((t|~r)^n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return d(e+(t&n|r&~n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return d(e+(t^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var I,x;A<16?(I=p(r,n,i,l,m,e[s[A]],f[0],c[A]),x=g(w,_,E,S,k,e[a[A]],h[0],u[A])):A<32?(I=b(r,n,i,l,m,e[s[A]],f[1],c[A]),x=v(w,_,E,S,k,e[a[A]],h[1],u[A])):A<48?(I=y(r,n,i,l,m,e[s[A]],f[2],c[A]),x=y(w,_,E,S,k,e[a[A]],h[2],u[A])):A<64?(I=v(r,n,i,l,m,e[s[A]],f[3],c[A]),x=b(w,_,E,S,k,e[a[A]],h[3],u[A])):(I=g(r,n,i,l,m,e[s[A]],f[4],c[A]),x=p(w,_,E,S,k,e[a[A]],h[4],u[A])),r=m,m=l,l=d(i,10),i=n,n=I,w=k,k=S,S=d(E,10),E=_,_=x}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=l},{buffer:131,"hash-base":243,inherits:259}],322:[function(e,t,r){var n=e("buffer"),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?t.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:131}],323:[function(e,t,r){"use strict";t.exports=e("./lib")(e("./lib/elliptic"))},{"./lib":327,"./lib/elliptic":326}],324:[function(e,t,r){(function(Buffer){"use strict";var e=Object.prototype.toString;r.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},r.isBoolean=function(t,r){if("[object Boolean]"!==e.call(t))throw TypeError(r)},r.isBuffer=function(e,t){if(!Buffer.isBuffer(e))throw TypeError(t)},r.isFunction=function(t,r){if("[object Function]"!==e.call(t))throw TypeError(r)},r.isNumber=function(t,r){if("[object Number]"!==e.call(t))throw TypeError(r)},r.isObject=function(t,r){if("[object Object]"!==e.call(t))throw TypeError(r)},r.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},r.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},r.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},r.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":260}],325:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var n=Buffer.from(r?i:o);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[i]&&!(128&t[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),e.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(t.slice(i),o.slice(a))},r.signatureImport=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(e);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(e){return}return i.r.copy(t,32-i.r.length),i.s.copy(r,32-i.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var o=e[i++];if(!(128&o&&(i+=o-128)>n)&&2===e[i++]){var s=e[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+e[i]}if(!(s>n-i)){var a=i;if(i+=s,2===e[i++]){var c=e[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+e[i]}if(!(c>n-i)){var u=i;for(i+=c;s>0&&0===e[a];s-=1,a+=1);if(!(s>32)){var f=e.slice(a,a+s);for(f.copy(t,32-f.length);c>0&&0===e[u];c-=1,u+=1);if(!(c>32)){var h=e.slice(u,u+c);return h.copy(r,32-h.length),{r:t,s:r}}}}}}}}}},{bip66:40,"safe-buffer":322}],326:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("create-hash"),i=e("bn.js"),o=e("elliptic").ec,s=e("../messages.json"),a=new o("secp256k1"),c=a.curve;function u(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new i(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new i(t),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new i(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new i(e);return t.isZero()?Buffer.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(e){var t=new i(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=u(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==u(e)},r.publicKeyTweakAdd=function(e,t,r){var n=u(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(c.g.mul(t).add(n.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var n=u(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(e);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new i(t).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new i(e.r);t.cmp(c.n)>=0&&(t=new i(0));var r=new i(e.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([t.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(e,t,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(e,t,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var u=new i(t);if(u.cmp(c.n)>=0||u.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(e,t,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=u(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,n){var o={r:t.slice(0,32),s:t.slice(32,64)},u=new i(o.r),f=new i(o.s);if(u.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(u.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(e,o,r);return Buffer.from(h.encode(!0,n))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var i=r.ecdhUnsafe(e,t,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(e,t,r){var n=u(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(t);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":328,"bn.js":90,"create-hash":139,elliptic:221,"safe-buffer":322}],327:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function s(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=e.privateKeyExport(t,r);return i.privateKeyExport(t,a,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":322}],330:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function u(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+u(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],332:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function u(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=u(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],333:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=a},{"./hash":329,"./sha256":334,inherits:259,"safe-buffer":322}],334:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function u(e,t,r){return e&t|r&(e|t)}function f(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function l(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,v=0;v<16;++v)r[v]=e.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((t=r[v-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var g=0;g<64;++g){var m=y+h(d)+c(d,p,b)+o[g]+r[g]|0,w=f(n)+u(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],335:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=a},{"./hash":329,"./sha512":336,inherits:259,"safe-buffer":322}],336:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function u(e,t,r){return e&t|r&(e|t)}function f(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function l(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function y(e,t){return e>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,I=0|this._gl,x=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var B=t[T-30],P=t[T-30+1],C=l(B,P),M=d(P,B),O=p(B=t[T-4],P=t[T-4+1]),R=b(P,B),L=t[T-14],j=t[T-14+1],N=t[T-32],D=t[T-32+1],U=M+j|0,H=C+L+y(U,M)|0;H=(H=H+O+y(U=U+R|0,R)|0)+N+y(U=U+D|0,D)|0,t[T]=H,t[T+1]=U}for(var K=0;K<160;K+=2){H=t[K],U=t[K+1];var z=u(r,n,i),F=u(w,_,E),W=f(r,w),q=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],J=c(a,v,g),Z=c(k,A,I),Q=x+G|0,$=m+V+y(Q,x)|0;$=($=($=$+J+y(Q=Q+Z|0,Z)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var ee=q+F|0,te=W+z+y(ee,q)|0;m=g,x=I,g=v,I=A,v=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+te+y(w=Q+ee|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+I|0,this._hl=this._hl+x|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+v+y(this._fl,A)|0,this._gh=this._gh+g+y(this._gl,I)|0,this._hh=this._hh+m+y(this._hl,x)|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=a},{"./hash":329,inherits:259,"safe-buffer":322}],337:[function(e,t,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};function i(e,t,r){if(4!==t.length)throw new n.exception.invalid("invalid aes block size");var i=e.c[r],o=t[0]^i[0],s=t[r?3:1]^i[1],a=t[2]^i[2];t=t[r?1:3]^i[3];var c,u,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];e=(c=e.j[r])[0];var b=c[1],y=c[2],v=c[3],g=c[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^v[255&t]^i[d],u=e[s>>>24]^b[a>>16&255]^y[t>>8&255]^v[255&o]^i[d+1],f=e[a>>>24]^b[t>>16&255]^y[o>>8&255]^v[255&s]^i[d+2],t=e[t>>>24]^b[o>>16&255]^y[s>>8&255]^v[255&a]^i[d+3],d+=4,o=c,s=u,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=g[o>>>24]<<24^g[s>>16&255]<<16^g[a>>8&255]<<8^g[255&t]^i[d++],c=o,o=s,s=a,a=t,t=c;return p}n.cipher.aes=function(e){this.j[0][0][0]||this.m();var t,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(t=e.length)&&6!==t&&8!==t)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==e%t&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(e){return i(this,e,0)},decrypt:function(e){return i(this,e,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var e,t,r,n,i,o,s,a=this.j[0],c=this.j[1],u=a[4],f=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!u[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[t]=o,f[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},n.bitArray={bitSlice:function(e,t,r){return e=n.bitArray.v(e.slice(t/32),32-(31&t)).slice(1),void 0===r?e:n.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(n.bitArray.bitLength(e)!==n.bitArray.bitLength(t))return!1;var r,i=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=n.bitArray.getPartial(o),i.push(n.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},n.codec.utf8String={fromBits:function(e){var t,r,i="",o=n.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],i=0;for(t=0;tn;i++){for(r=!0,t=2;t*t<=i;t++)if(0==i%t){r=!1;break}r&&(8>n&&(this.i[n]=e(Math.pow(i,.5))),this.c[n]=e(Math.pow(i,1/3)),n++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?r=e[t]:(r=e[t+1&15],n=e[t+14&15],r=e[15&t]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+e[15&t]+e[t+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=u+r|0,u=c,c=a,s=r+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(e){this.c[0]||this.m(),e?(this.f=e.f.slice(0),this.b=e.b.slice(0),this.a=e.a):this.reset()},n.hash.sha512.hash=function(e){return(new n.hash.sha512).update(e).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(e){"string"==typeof e&&(e=n.codec.utf8String.toBits(e));var t,r=this.b=n.bitArray.concat(this.b,e);if(t=this.a,9007199254740991<(e=this.a=t+n.bitArray.bitLength(e)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(r.splice(0,32));return this},finalize:function(){var e,t=this.b,r=this.f;for(e=(t=n.bitArray.concat(t,[n.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.a/4294967296)),t.push(0|this.a);t.length;)this.g(t.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=e(Math.pow(o,.5)),this.i[2*i+1]=t(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=e(Math.pow(o,1/3)),this.c[2*i+1]=t(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=e[E]}else n=e;E=s;var S=a,k=c,A=u,I=f,x=h,T=l,B=d,P=p,C=b,M=y,O=v,R=g,L=m,j=w,N=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((H=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(e-7)],z=n[2*(e-16)],F=n[2*(e-16)+1];t=t+K+((r=D+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=H)>>>0>>0?1:0),t+=z+((r+=F)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;K=P&M^~P&R;var W=C&O^~C&L,q=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];D=(D=(D=(D=j+((C<<18|P>>>14)^(C<<14|P>>>18)^(P<<23|C>>>9))+((U=N+((P<<18|C>>>14)^(P<<14|C>>>18)^(C<<23|P>>>9)))>>>0>>0?1:0))+(K+((U=U+W)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+H+((r=F+q)>>>0>>0?1:0),j=R,N=L,R=M,L=O,M=P,O=C,P=T+D+((C=B+U|0)>>>0>>0?1:0)|0,T=I,B=x,I=k,x=A,k=E,A=S,E=D+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+B|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+C|0,i[8]=p+P+(b>>>0>>0?1:0)|0,v=i[11]=v+O|0,i[10]=y+M+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+R+(m>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(e,t,r,i,o){var s=t.slice(0);return t=n.bitArray,i=i||[],e=n.mode.gcm.s(!0,e,s,i,r,o||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,o){var s=t.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(t=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(t=s,s=[]),e=n.mode.gcm.s(!1,e,s,i,r,o),!a.equal(e.tag,t))throw new n.exception.corrupt("gcm: tag doesn't match");return e.data},A:function(e,t){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=t.slice(0),r=0;128>r;r++){for((i=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(e,t,r){var i,o=r.length;for(t=t.slice(0),i=0;io&&(e=t.hash(e)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),e=new(o=o||n.misc.hmac)(e);var s,a,c,u,f=[],h=n.bitArray;for(u=1;32*f.length<(i||1);u++){for(o=s=e.encrypt(h.concat(t,[u])),a=1;a>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":322}],340:[function(e,t,r){t.exports=function(t){return t.signer=t.signer||e("./lib/signer-hmac-only"),e("./lib/index")(t)}},{"./lib/index":341,"./lib/signer-hmac-only":342}],341:[function(e,t,r){var n=e("util").format;function i(e,t){return e.get?e.get(t):e.getHeader(t)}function o(e){this.name="MissingHeaderError",this.message=e,this.stack=(new Error).stack}function s(e){this.name="InvalidAlgorithmError",this.message=e,this.stack=(new Error).stack}o.prototype=new Error,s.prototype=new Error;var a={"rsa-sha1":!0,"rsa-sha256":!0,"rsa-sha512":!0,"dsa-sha1":!0,"hmac-sha1":!0,"hmac-sha256":!0,"hmac-sha512":!0},c='Signature keyId="%s",algorithm="%s",headers="%s",signature="%s"';function u(e){var t=e.match(/^(?:(.*?):\/\/?)?\/?(?:[^\/\.]+\.)*?([^\/\.]+)\.?([^\/]*)(?:([^?]*)?(?:\?(‌​[^#]*))?)?(.*)?/);return!!t&&t[4]+(t[6]||"")}function f(e){return parseInt(e,10)<10&&(e="0"+e),e}function h(e,t){var r,h;if(t.headers||(t.headers=["date"]),i(e,"Date")||-1===t.headers.indexOf("date")||e.set("Date",["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][(r=new Date).getUTCDay()]+", "+f(r.getUTCDate())+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.getUTCMonth()]+" "+r.getUTCFullYear()+" "+f(r.getUTCHours())+":"+f(r.getUTCMinutes())+":"+f(r.getUTCSeconds())+" GMT"),t.algorithm||(t.algorithm="rsa-sha256"),t.httpVersion||(t.httpVersion="1.1"),t.algorithm=t.algorithm.toLowerCase(),!a[t.algorithm])throw new s(t.algorithm+" is not supported");var l,d="";for(h=0;h=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&t.setRequestHeader(s,this.header[s]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},f.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(e){c.prototype[e.toLowerCase()]=function(t,r){var n=new f.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,f.get=function(e,t,r){var n=f("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},f.head=function(e,t,r){var n=f("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},f.options=function(e,t,r){var n=f("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},f.del=g,f.delete=g,f.patch=function(e,t,r){var n=f("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},f.post=function(e,t,r){var n=f("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},f.put=function(e,t,r){var n=f("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},{"./agent-base":343,"./is-object":345,"./request-base":346,"./response-base":347,"component-emitter":136}],345:[function(e,t,r){"use strict";t.exports=function(e){return null!==e&&"object"==typeof e}},{}],346:[function(e,t,r){"use strict";var n=e("./is-object");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(e){return this._parser=e,this},i.prototype.responseType=function(e){return this._responseType=e,this},i.prototype.serialize=function(e){return this._serializer=e,this},i.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},i.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~o.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(e,t){r.end(function(r,n){r?t(r):e(n)})})}return this._fullfilledPromise.then(e,t)},i.prototype.catch=function(e){return this.then(void 0,e)},i.prototype.use=function(e){return e(this),this},i.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},i.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},i.prototype.get=function(e){return this._header[e.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(e,t){if(n(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},i.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},i.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var i in t)this.field(e,t[i]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},i.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},i.prototype.redirects=function(e){return this._maxRedirects=e,this},i.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(e){var t=n(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&n(this._data))for(var i in e)this._data[i]=e[i];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},i.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":345}],347:[function(e,t,r){"use strict";var n=e("./utils");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.get=function(e){return this.header[e.toLowerCase()]},i.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=n.type(t);var r=n.params(t);for(var i in r)this[i]=r[i];this.links={};try{e.link&&(this.links=n.parseLinks(e.link))}catch(e){}},i.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},{"./utils":348}],348:[function(e,t,r){"use strict";r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e},{})},r.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},{}],349:[function(e,t,r){(function(t,n){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new u(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new u(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r.setImmediate="function"==typeof t?t:function(e){var t=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(n?e.apply(null,n):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":271,timers:349}],350:[function(e,t,r){t.exports=function(e,t,r){t=void 0===t?0:t,r=void 0===r?e.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-h&&e<=h&&Math.floor(e)===e},Range:function(e,t,n){function i(r,i){return n(r,i)&&r>e&&r>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=h&&Math.floor(e)===e}};for(var d in l)l[d].toJSON=function(e){return e}.bind(null,d);t.exports=l}).call(this,{isBuffer:e("../is-buffer/index.js")})},{"../is-buffer/index.js":260,"./errors":351,"./native":354}],353:[function(e,t,r){var n=e("./errors"),i=e("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==t.minLength&&r.lengtht.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every(function(t,r){try{return l(e,t,n)}catch(e){throw c(e,r)}})))))}return e=h(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=h(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&l(t,o,n)}catch(e){throw c(e,o,"key")}try{var s=r[o];l(e,s,n)}catch(e){throw c(e,o)}}return!0}return e=h(e),t&&(t=h(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=h(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t){l(t[n],e[n],r)}}catch(e){throw c(e,n)}if(r)for(n in e)if(!t[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.some(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.every(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===u(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return!i.Nil(t)&&(!i.Nil(t.length)&&((!r||t.length===e.length)&&e.every(function(e,n){try{return l(e,t[n],r)}catch(e){throw c(e,n)}})))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function h(e){if(i.String(e))return"?"===e[0]?f.maybe(e.slice(1)):i[e]||f.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(e[0])}return f.object(e)}return i.Function(e)?e:f.value(e)}function l(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return l(h(e),t,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=e("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},{"./errors":351,"./extra":352,"./native":354}],354:[function(e,t,r){var n={Array:function(e){return null!==e&&void 0!==e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return void 0===e||null===e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(e){return e}.bind(null,i);t.exports=n},{}],355:[function(e,t,r){!function(e){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,u=21,f=28,h=u*f,l=c*h,d=function(e,t){this.codepoint=e,this.feature=t},p={},b=[],y=0;y<=255;++y)b[y]=0;var v=[function(e,t,n){return t<60||13311>8&255]>n&&(p[t]=i),i},function(e,t,r){return r?e(t,r):new d(t,null)},function(e,t,r){var n;if(t=55296&&e<=56319},d.isLowSurrogate=function(e){return e>=56320&&e<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var e=this.codepoint-65536;return String.fromCharCode(Math.floor(e/1024)+55296,e%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(e){if(this.prepFeature(),!this.feature[2])return null;var t=this.feature[2][e.codepoint];return t?d.fromCharCode(t):null};var g=function(e){this.str=e,this.cursor=0};g.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=e)break}this.resBuf.splice(r,0,t)}while(0!==e);return this.resBuf.shift()};var _=function(e){this.it=e,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var e=this.it.next();if(!e){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=e.getCanonicalClass(),this.procBuf.push(e);else{var t=this.procBuf[0].getComposite(e),r=e.getCanonicalClass();t&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=e("querystring");function m(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?O+="x":O+=M[R];if(!O.match(d)){var j=P.slice(0,x),N=P.slice(x+1),D=M.match(p);D&&(j.push(D[1]),N.unshift(D[2])),N.length&&(m="/"+N.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(x=0,C=f.length;x0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],I=(r.host||e.host||S.length>1)&&("."===A||".."===A)||""===A,x=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),x++):x&&(S.splice(T,1),x--);if(!_&&!E)for(;x--;x)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var B,P=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=P?"":S.length?S.shift():"",(B=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift()));return(_=_||r.host&&S.length)&&!P&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":357,punycode:240,querystring:305}],357:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],358:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],359:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],360:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":359,_process:271,dup:27,inherits:259}],361:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=9007199254740991;function i(e){if(e<0||e>n||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}t.exports={encode:function e(t,r,n){if(i(t),r||(r=Buffer.allocUnsafe(o(t))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),t<253?(r.writeUInt8(t,n),e.bytes=1):t<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(t,n+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(t,n+1),e.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(t>>>0,n+1),r.writeUInt32LE(t/4294967296|0,n+5),e.bytes=9),r},decode:function e(t,r){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=t.readUInt8(r);if(n<253)return e.bytes=1,n;if(253===n)return e.bytes=3,t.readUInt16LE(r+1);if(254===n)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var o=t.readUInt32LE(r+1),s=4294967296*t.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":322}],362:[function(e,t,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;t.exports=function(e,t){for(var r,a=Object.keys(o),c=0,u=a.length;c0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=v.AES.encrypt(t.secret,t.passphrase).toString(v.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=v.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(v.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=v.AES.encrypt(t.secret,t.recoverySecret).toString(v.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,v,g,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=g,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function v(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function g(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(v,"cashaddr"),n||a(g,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,v=[],g=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return g.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?v.splice(r.random(0,v.length),0,n):v.push(n)}t()},function(t){v.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(g.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?g.reject(new u.WalletSendError(e)):g.resolve([d,t])}),g.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=v,l.ok=g,l.equal=function(t,e,r){t!=e&&v(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||v(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||v(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&v(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||v(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!v(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return v(i)||(i=f(t,i,n)),i}var o=function(t,e){if(g(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),I(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function g(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(g(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=v,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=g,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(g),o.rejectSeries=p(g);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),BigInteger.ONE.dlShiftTo(c,g),g.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,v,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,v=t.t-1,g=!0,m=new BigInteger;for(i=l(t[v])-1;v>=0;){for(i>=u?b=t[v]>>i-u&c:(b=(t[v]&(1<0&&(b|=t[v-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),g)s[b].copyTo(o),g=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;v>=0&&0==(t[v]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^v[u>>8&255]^g[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^v[e>>8&255]^g[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^v[o>>8&255]^g[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^v[a>>8&255]^g[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),g=o.low=g+O,o.high=v+R+(g>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+z,h.high=A+K+(x>>>0>>0?1:0),T=l.low=T+F,l.high=I+q+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var v=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(v[1]=e[b].add(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].add(e[y].neg())):(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][x-1>>1]:x<0&&(c=h[u][-x-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),v=new i(1),g=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=v.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++g)break;u=c,d=l,l=c,y=p,p=f,v=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),g^=1),new f({r:y,s:v,recoveryParam:g})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,v="-",g=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function I(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,g,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(g=t.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,g,m,w,_,E,x=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&gS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),g==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,x.push(k(B(p+E%_,0))),u=S(E/_);x.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return I(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return I(t,function(t){return g.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",v),t.removeListener("finish",g),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",g),m()}function g(){l("onfinish"),t.removeListener("close",v),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",v),t.once("finish",g),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},g.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(e){if(a=a||t("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function g(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,g(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(g(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(v,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===v&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,v=2,g=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,I="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",v],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",q="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",Z="[object Number]",J="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",vt="[object Uint32Array]",gt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,It=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Jt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Jt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ve=RegExp("['’]","g"),ge=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Jt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[vt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[q]=Ae[ut]=Ae[F]=Ae[V]=Ae[G]=Ae[X]=Ae[Z]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[H]=xe[K]=xe[at]=xe[ut]=xe[q]=xe[F]=xe[ct]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[X]=xe[Z]=xe[Q]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[vt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Ie={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,qe=De&&De.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Je(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Ie[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Ir(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Jt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,Ie=Buffer?Buffer.allocUnsafe:n,Be=xr(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Jt&&Jt.now!==Ce.Date.now&&Jt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,qr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Jt.now,Yr=e.parseInt,Xr=te.random,Zr=oe.reverse,Jr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Jr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!ga(t)&&!(t instanceof gn)){if(t instanceof vn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new vn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function vn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function gn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=ga(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=qo(t),y=b==G||b==Y;if(Ea(t))return Ji(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case q:case F:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case vt:return $i(t,r);case X:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var v=s.get(t);if(v)return v;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var g=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(g||t,function(n,i){g&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Je,a=!1):e.length>=i&&(s=gr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Zn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Jn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Je:Ze,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function xi(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function Ii(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=gr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Zi=Lr||function(t){return Ce.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=Ie?Ie(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=vn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new vn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof gn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new vn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var qs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var Fs=lo(vs),Ws=lo(gs);function Vs(t,e){return(ga(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(ga(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Rn(t,r,e)});function Js(t,e){return(ga(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),gi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Ir(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|v;if(r.length){var i=Ir(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function v(){var t=ta();if(y(t))return g(t);c=os(v,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function g(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(v,e),l?b(t):u}(f);if(d)return Zi(c),c=os(v,e),b(f)}return c===n&&(c=os(v,e)),u}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Zi(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:g(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,Fa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&ga(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),va=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},ga=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&Ia(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||Fu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==F};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function xa(t){return"number"==typeof t&&t==za(t)}function Ia(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&qo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==Z}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&qo(t)==et};function La(t){return"string"==typeof t||!ga(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=qe?yr(qe):function(t){return Ma(t)&&Ia(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=qo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=Fa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function qa(t){return t?Ln(za(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):qt.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Za=so(function(t,e,r,n){io(e,ou(e),t,n)}),Ja=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:vr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function vu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ge,"")}var gu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var xu=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),Iu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=go(Qe),Nu=go(Ye),Uu=go(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Jn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function qu(){return[]}function Fu(){return!1}var Wu=vo(function(t,e){return t+e},0),Vu=So("ceil"),Gu=vo(function(t,e){return t/e},1),Yu=So("floor");var Xu,Zu=vo(function(t,e){return t*e},1),Ju=So("round"),Qu=vo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Za,pn.at=Ja,pn.before=ra,pn.bind=na,pn.bindAll=Iu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ga(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:qa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return ga(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=ga(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:vr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return Fi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Ii)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=xu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=vu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=ga(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=Fs,pn.findIndex=vs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=gs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&qo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":qr.call(t,e)},pn.kebabCase=gu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?qn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?qn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?qn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?qn(t,Do(e,2),li):n},pn.stubArray=qu,pn.stubFalse=Fu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zu,pn.nth=function(t,e){return t&&t.length?vi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=ga(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=ga(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){gn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new gn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},gn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;gn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");gn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");gn.prototype[t]=function(){return this.__filtered__?new gn(this):this[r](1)}}),gn.prototype.compact=function(){return this.filter(Pu)},gn.prototype.find=function(t){return this.filter(t).head()},gn.prototype.findLast=function(t){return this.reverse().find(t)},gn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new gn(this):this.map(function(r){return ii(r,t,e)})}),gn.prototype.reject=function(t){return this.filter(ca(Do(t)))},gn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new gn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},gn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},gn.prototype.toArray=function(){return this.take(j)},Yn(gn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof gn,c=a[0],f=u||ga(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new gn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new vn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(ga(i)?i:[],t)}return this[r](function(r){return e.apply(ga(r)?r:[],t)})}}),Yn(gn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,v).name]=[{name:"wrapper",func:n}],gn.prototype.clone=function(){var t=new gn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},gn.prototype.reverse=function(){if(this.__filtered__){var t=new gn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},gn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=ga(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof gn){var e=t;return this.__actions__.length&&(e=new gn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new vn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function I(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=I,x.all=F,x.reject=H,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=I,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function q(t,e,r){return k(t).dispatch(e,r)}function F(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(F(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return q(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===v(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=q,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=v.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=v.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),v.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=v.G15<=0;)e^=v.G18<>>=1;return e},getPatternPosition:function(t){return v.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return g.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)g.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new g);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):P(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=p(r,n,i,l,m,t[s[A]],f[0],u[A]),I=g(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(x=b(r,n,i,l,m,t[s[A]],f[1],u[A]),I=v(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(x=y(r,n,i,l,m,t[s[A]],f[2],u[A]),I=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(x=v(r,n,i,l,m,t[s[A]],f[3],u[A]),I=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(x=g(r,n,i,l,m,t[s[A]],f[4],u[A]),I=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=I}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,v=0;v<16;++v)r[v]=t.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((e=r[v-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var g=0;g<64;++g){var m=y+h(d)+u(d,p,b)+o[g]+r[g]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),q=c(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],Z=u(a,v,g),J=u(k,A,x),Q=I+G|0,$=m+V+y(Q,I)|0;$=($=($=$+Z+y(Q=Q+J|0,J)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+q|0,et=F+z+y(tt,W)|0;m=g,I=x,g=v,x=A,v=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+v+y(this._fl,A)|0,this._gh=this._gh+g+y(this._gl,x)|0,this._hh=this._hh+m+y(this._hl,I)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],v=u[3],g=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^v[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^v[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^v[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^v[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=g[o>>>24]<<24^g[s>>16&255]<<16^g[a>>8&255]<<8^g[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=g,f.delete=g,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var v=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var g=function(t){this.str=t,this.cursor=0};g.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,I),D=B.slice(I+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(I=0,P=f.length;I0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),I++):I&&(S.splice(T,1),I--);if(!_&&!E)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u 300) { + // max inputs length + chunk = 300; + } else { + chunk = utxoArray.length; + } + for (i=0,j=utxoArray.length; i= 255) throw new TypeError('Alphabet too long') - - const BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) - - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - - if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') +// @ts-ignore +var _Buffer = require('safe-buffer').Buffer +function base (ALPHABET) { + if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } + var BASE_MAP = new Uint8Array(256) + for (var j = 0; j < BASE_MAP.length; j++) { + BASE_MAP[j] = 255 + } + for (var i = 0; i < ALPHABET.length; i++) { + var x = ALPHABET.charAt(i) + var xc = x.charCodeAt(0) + if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') } BASE_MAP[xc] = i } - - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - + var BASE = ALPHABET.length + var LEADER = ALPHABET.charAt(0) + var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up function encode (source) { - if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') - if (source.length === 0) return '' - - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - + if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) } + if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') } + if (source.length === 0) { return '' } + // Skip & count leading zeroes. + var zeroes = 0 + var length = 0 + var pbegin = 0 + var pend = source.length while (pbegin !== pend && source[pbegin] === 0) { pbegin++ zeroes++ } - - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - - // Process the bytes. + // Allocate enough space in big-endian base58 representation. + var size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + var b58 = new Uint8Array(size) + // Process the bytes. while (pbegin !== pend) { - let carry = source[pbegin] - - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (256 * b58[it]) >>> 0 - b58[it] = (carry % BASE) >>> 0 + var carry = source[pbegin] + // Apply "b58 = b58 * 256 + ch". + var i = 0 + for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) { + carry += (256 * b58[it1]) >>> 0 + b58[it1] = (carry % BASE) >>> 0 carry = (carry / BASE) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i pbegin++ } - - // Skip leading zeroes in base58 result. - let it = size - length - while (it !== size && b58[it] === 0) { - it++ + // Skip leading zeroes in base58 result. + var it2 = size - length + while (it2 !== size && b58[it2] === 0) { + it2++ } - - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - + // Translate the result into a string. + var str = LEADER.repeat(zeroes) + for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) } return str } - function decodeUnsafe (source) { - if (typeof source !== 'string') throw new TypeError('Expected String') - if (source.length === 0) return Buffer.alloc(0) - - let psz = 0 - - // Skip leading spaces. - if (source[psz] === ' ') return - - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 + if (typeof source !== 'string') { throw new TypeError('Expected String') } + if (source.length === 0) { return _Buffer.alloc(0) } + var psz = 0 + // Skip leading spaces. + if (source[psz] === ' ') { return } + // Skip and count leading '1's. + var zeroes = 0 + var length = 0 while (source[psz] === LEADER) { zeroes++ psz++ } - - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - - // Process the characters. + // Allocate enough space in big-endian base256 representation. + var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + var b256 = new Uint8Array(size) + // Process the characters. while (source[psz]) { - // Decode character - let carry = BASE_MAP[source.charCodeAt(psz)] - - // Invalid character - if (carry === 255) return - - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (BASE * b256[it]) >>> 0 - b256[it] = (carry % 256) >>> 0 + // Decode character + var carry = BASE_MAP[source.charCodeAt(psz)] + // Invalid character + if (carry === 255) { return } + var i = 0 + for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) { + carry += (BASE * b256[it3]) >>> 0 + b256[it3] = (carry % 256) >>> 0 carry = (carry / 256) >>> 0 } - - if (carry !== 0) throw new Error('Non-zero carry') + if (carry !== 0) { throw new Error('Non-zero carry') } length = i psz++ } - - // Skip trailing spaces. - if (source[psz] === ' ') return - - // Skip leading zeroes in b256. - let it = size - length - while (it !== size && b256[it] === 0) { - it++ + // Skip trailing spaces. + if (source[psz] === ' ') { return } + // Skip leading zeroes in b256. + var it4 = size - length + while (it4 !== size && b256[it4] === 0) { + it4++ } - - const vch = Buffer.allocUnsafe(zeroes + (size - it)) + var vch = _Buffer.allocUnsafe(zeroes + (size - it4)) vch.fill(0x00, 0, zeroes) - - let j = zeroes - while (it !== size) { - vch[j++] = b256[it++] + var j = zeroes + while (it4 !== size) { + vch[j++] = b256[it4++] } - return vch } - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) return buffer - + var buffer = decodeUnsafe(string) + if (buffer) { return buffer } throw new Error('Non-base' + BASE + ' character') } - return { encode: encode, decodeUnsafe: decodeUnsafe, decode: decode } } +module.exports = base -},{"safe-buffer":298}],29:[function(require,module,exports){ +},{"safe-buffer":321}],29:[function(require,module,exports){ 'use strict'; var ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'; @@ -11684,7 +11817,7 @@ BigInteger.valueOf = nbv module.exports = BigInteger },{"../package.json":33}],31:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ // FIXME: Kind of a weird way to throw exceptions, consider removing var assert = require('assert') var BigInteger = require('./bigi') @@ -11777,8 +11910,8 @@ BigInteger.prototype.toHex = function(size) { return this.toBuffer(size).toString('hex') } -}).call(this,require("buffer").Buffer) -},{"./bigi":30,"assert":23,"buffer":111}],32:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./bigi":30,"assert":23,"buffer":110}],32:[function(require,module,exports){ var BigInteger = require('./bigi') //addons @@ -11787,21 +11920,27 @@ require('./convert') module.exports = BigInteger },{"./bigi":30,"./convert":31}],33:[function(require,module,exports){ module.exports={ - "_from": "bigi@^1.4.0", + "_args": [ + [ + "bigi@1.4.2", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] + ], + "_from": "bigi@1.4.2", "_id": "bigi@1.4.2", "_inBundle": false, "_integrity": "sha1-nGZalfiLiwj8Bc/XMfVhhZ1yWCU=", "_location": "/bigi", "_phantomChildren": {}, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "bigi@^1.4.0", + "raw": "bigi@1.4.2", "name": "bigi", "escapedName": "bigi", - "rawSpec": "^1.4.0", + "rawSpec": "1.4.2", "saveSpec": null, - "fetchSpec": "^1.4.0" + "fetchSpec": "1.4.2" }, "_requiredBy": [ "/bitcoinjs-lib", @@ -11809,15 +11948,12 @@ module.exports={ "/ecurve" ], "_resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", - "_shasum": "9c665a95f88b8b08fc05cfd731f561859d725825", - "_spec": "bigi@^1.4.0", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/bitcoinjs-lib", + "_spec": "1.4.2", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", "bugs": { "url": "https://github.com/cryptocoinjs/bigi/issues" }, - "bundleDependencies": false, "dependencies": {}, - "deprecated": false, "description": "Big integers.", "devDependencies": { "coveralls": "^2.11.2", @@ -11874,7 +12010,7 @@ module.exports={ } },{}],34:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ var bip39 = require('./lib/index') var sjcl = require('./sjcl') var assert = require('assert') @@ -11914,9 +12050,9 @@ module.exports = { validateMnemonic: bip39.validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"./lib/index":35,"./sjcl":36,"assert":23,"buffer":111}],35:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/index":35,"./sjcl":36,"assert":23,"buffer":110}],35:[function(require,module,exports){ +(function (Buffer){(function (){ var assert = require('assert') var createHash = require('create-hash') var randomBytes = require('randombytes') @@ -12047,8 +12183,8 @@ module.exports = { validateMnemonic: validateMnemonic } -}).call(this,require("buffer").Buffer) -},{"../wordlists/en.json":37,"assert":23,"buffer":111,"create-hash":119,"randombytes":282,"unorm":330}],36:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"../wordlists/en.json":37,"assert":23,"buffer":110,"create-hash":118,"randombytes":303,"unorm":353}],36:[function(require,module,exports){ "use strict";function q(a){throw a;}var u=void 0,v=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl}); sjcl.cipher.aes=function(a){this.o[0][0][0]||this.t();var b,c,d,e,f=this.o[0][4],g=this.o[1];b=a.length;var h=1;4!==b&&(6!==b&&8!==b)&&q(new sjcl.exception.invalid("invalid aes key size"));this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c& @@ -12111,7 +12247,7 @@ b.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&b.ct instanceof ArrayBuffer?sjcl q(new sjcl.exception.invalid("json decode: this isn't json!")),null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(d[4]):unescape(d[4]):null!=d[5]&&(b[d[2]]="true"===d[5]);return b},h:function(a,b,c){a===u&&(a={});if(b===u)return a;for(var d in b)b.hasOwnProperty(d)&&(c&&(a[d]!==u&&a[d]!==b[d])&&q(new sjcl.exception.invalid("required parameter overridden")),a[d]=b[d]);return a},la:function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&& a[d]!==b[d]&&(c[d]=a[d]);return c},ka:function(a,b){var c={},d;for(d=0;d {serialized scriptPubKey script} @@ -16452,7 +16588,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":51,"safe-buffer":298,"typeforce":328}],66:[function(require,module,exports){ +},{"../../script":51,"safe-buffer":321,"typeforce":351}],66:[function(require,module,exports){ // OP_HASH160 {scriptHash} OP_EQUAL var bscript = require('../../script') @@ -16488,7 +16624,7 @@ module.exports = { encode: encode } -},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":328}],67:[function(require,module,exports){ +},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":351}],67:[function(require,module,exports){ module.exports = { output: require('./output') } @@ -16537,7 +16673,7 @@ module.exports = { encode: encode } -},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":298,"typeforce":328}],69:[function(require,module,exports){ +},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":321,"typeforce":351}],69:[function(require,module,exports){ arguments[4][54][0].apply(exports,arguments) },{"./input":70,"./output":71,"dup":54}],70:[function(require,module,exports){ // {signature} {pubKey} @@ -16585,7 +16721,7 @@ module.exports = { encodeStack: encodeStack } -},{"../../script":51,"typeforce":328}],71:[function(require,module,exports){ +},{"../../script":51,"typeforce":351}],71:[function(require,module,exports){ // OP_0 {pubKeyHash} var bscript = require('../../script') @@ -16620,7 +16756,7 @@ module.exports = { encode: encode } -},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":328}],72:[function(require,module,exports){ +},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":351}],72:[function(require,module,exports){ arguments[4][54][0].apply(exports,arguments) },{"./input":73,"./output":74,"dup":54}],73:[function(require,module,exports){ // {signature} {pubKey} @@ -16668,7 +16804,7 @@ module.exports = { encode: encode } -},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":328}],75:[function(require,module,exports){ +},{"../../script":51,"../../types":77,"bitcoin-ops":39,"typeforce":351}],75:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var bcrypto = require('./crypto') @@ -17218,7 +17354,7 @@ Transaction.prototype.setWitness = function (index, witness) { module.exports = Transaction -},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":109,"safe-buffer":298,"typeforce":328,"varuint-bitcoin":336}],76:[function(require,module,exports){ +},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,"typeforce":351,"varuint-bitcoin":357}],76:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var bufferReverse = require('buffer-reverse') var baddress = require('./address') @@ -18037,7 +18173,7 @@ TransactionBuilder.prototype.__overMaximumFees = function (bytes) { module.exports = TransactionBuilder -},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":109,"safe-buffer":298,"typeforce":328}],77:[function(require,module,exports){ +},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,"typeforce":351}],77:[function(require,module,exports){ var typeforce = require('typeforce') var UINT31_MAX = Math.pow(2, 31) - 1 @@ -18092,8 +18228,8 @@ for (var typeName in typeforce) { module.exports = types -},{"typeforce":328}],78:[function(require,module,exports){ -(function (Buffer){ +},{"typeforce":351}],78:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') var bufferEquals = require('buffer-equals') var createHash = require('create-hash') @@ -18164,8 +18300,8 @@ module.exports = { verify: verify } -}).call(this,require("buffer").Buffer) -},{"bs58check":81,"buffer":111,"buffer-equals":108,"create-hash":119,"secp256k1":299,"varuint-bitcoin":336}],79:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":81,"buffer":110,"buffer-equals":107,"create-hash":118,"secp256k1":323,"varuint-bitcoin":357}],79:[function(require,module,exports){ // base-x encoding // Forked from https://github.com/cryptocoinjs/bs58 // Originally written by Mike Hearn for BitcoinJ @@ -18260,7 +18396,7 @@ var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' module.exports = basex(ALPHABET) },{"base-x":79}],81:[function(require,module,exports){ -(function (Buffer){ +(function (Buffer){(function (){ 'use strict' var base58 = require('bs58') @@ -18321,8 +18457,8 @@ module.exports = { decodeRaw: decodeUnsafe } -}).call(this,require("buffer").Buffer) -},{"bs58":80,"buffer":111,"create-hash":119}],82:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58":80,"buffer":110,"create-hash":118}],82:[function(require,module,exports){ (function (module, exports) { 'use strict'; @@ -18375,7 +18511,11 @@ module.exports = { var Buffer; try { - Buffer = require('buffer').Buffer; + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } } catch (e) { } @@ -18416,23 +18556,19 @@ module.exports = { var start = 0; if (number[0] === '-') { start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { this.negative = 1; } - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } }; BN.prototype._initNumber = function _initNumber (number, base, endian) { @@ -18508,31 +18644,29 @@ module.exports = { return this.strip(); }; - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // 'A' - 'F' + if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + // '0' - '9' + } else { + return (c - 48) & 0xf; + } + } - // '0' - '9' - } else { - r |= c & 0xf; - } + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } return r; } - BN.prototype._parseHex = function _parseHex (number, start) { + BN.prototype._parseHex = function _parseHex (number, start, endian) { // Create possibly bigger array to ensure that it fits the number this.length = Math.ceil((number.length - start) / 6); this.words = new Array(this.length); @@ -18540,25 +18674,38 @@ module.exports = { this.words[i] = 0; } - var j, w; - // Scan 24-bit chunks and add them to the number + // 24-bits chunks var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } } + this.strip(); }; @@ -18629,6 +18776,8 @@ module.exports = { this._iaddn(word); } } + + this.strip(); }; BN.prototype.copy = function copy (dest) { @@ -21297,7 +21446,13 @@ module.exports = { } else if (cmp > 0) { r.isub(this.p); } else { - r.strip(); + if (r.strip !== undefined) { + // r is BN v4 instance + r.strip(); + } else { + // r is BN v5 instance + r._strip(); + } } return r; @@ -21751,7 +21906,7 @@ module.exports = { }; })(typeof module === 'undefined' || module, this); -},{"buffer":84}],83:[function(require,module,exports){ +},{"buffer":219}],83:[function(require,module,exports){ var r; module.exports = function rand(len) { @@ -21818,9 +21973,7 @@ if (typeof self === 'object') { } } -},{"crypto":84}],84:[function(require,module,exports){ - -},{}],85:[function(require,module,exports){ +},{"crypto":219}],84:[function(require,module,exports){ // based on the aes implimentation in triple sec // https://github.com/keybase/triplesec // which is in turn based on the one from crypto-js @@ -22050,7 +22203,7 @@ AES.prototype.scrub = function () { module.exports.AES = AES -},{"safe-buffer":298}],86:[function(require,module,exports){ +},{"safe-buffer":321}],85:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -22169,7 +22322,7 @@ StreamCipher.prototype.setAAD = function setAAD (buf) { module.exports = StreamCipher -},{"./aes":85,"./ghash":90,"./incr32":91,"buffer-xor":110,"cipher-base":115,"inherits":238,"safe-buffer":298}],87:[function(require,module,exports){ +},{"./aes":84,"./ghash":89,"./incr32":90,"buffer-xor":109,"cipher-base":114,"inherits":258,"safe-buffer":321}],86:[function(require,module,exports){ var ciphers = require('./encrypter') var deciphers = require('./decrypter') var modes = require('./modes/list.json') @@ -22184,7 +22337,7 @@ exports.createDecipher = exports.Decipher = deciphers.createDecipher exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"./decrypter":88,"./encrypter":89,"./modes/list.json":99}],88:[function(require,module,exports){ +},{"./decrypter":87,"./encrypter":88,"./modes/list.json":98}],87:[function(require,module,exports){ var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer var MODES = require('./modes') @@ -22310,7 +22463,7 @@ function createDecipher (suite, password) { exports.createDecipher = createDecipher exports.createDecipheriv = createDecipheriv -},{"./aes":85,"./authCipher":86,"./modes":98,"./streamCipher":101,"cipher-base":115,"evp_bytestokey":217,"inherits":238,"safe-buffer":298}],89:[function(require,module,exports){ +},{"./aes":84,"./authCipher":85,"./modes":97,"./streamCipher":100,"cipher-base":114,"evp_bytestokey":218,"inherits":258,"safe-buffer":321}],88:[function(require,module,exports){ var MODES = require('./modes') var AuthCipher = require('./authCipher') var Buffer = require('safe-buffer').Buffer @@ -22426,7 +22579,7 @@ function createCipher (suite, password) { exports.createCipheriv = createCipheriv exports.createCipher = createCipher -},{"./aes":85,"./authCipher":86,"./modes":98,"./streamCipher":101,"cipher-base":115,"evp_bytestokey":217,"inherits":238,"safe-buffer":298}],90:[function(require,module,exports){ +},{"./aes":84,"./authCipher":85,"./modes":97,"./streamCipher":100,"cipher-base":114,"evp_bytestokey":218,"inherits":258,"safe-buffer":321}],89:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var ZEROES = Buffer.alloc(16, 0) @@ -22517,7 +22670,7 @@ GHASH.prototype.final = function (abl, bl) { module.exports = GHASH -},{"safe-buffer":298}],91:[function(require,module,exports){ +},{"safe-buffer":321}],90:[function(require,module,exports){ function incr32 (iv) { var len = iv.length var item @@ -22534,7 +22687,7 @@ function incr32 (iv) { } module.exports = incr32 -},{}],92:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ var xor = require('buffer-xor') exports.encrypt = function (self, block) { @@ -22553,7 +22706,7 @@ exports.decrypt = function (self, block) { return xor(out, pad) } -},{"buffer-xor":110}],93:[function(require,module,exports){ +},{"buffer-xor":109}],92:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var xor = require('buffer-xor') @@ -22588,7 +22741,7 @@ exports.encrypt = function (self, data, decrypt) { return out } -},{"buffer-xor":110,"safe-buffer":298}],94:[function(require,module,exports){ +},{"buffer-xor":109,"safe-buffer":321}],93:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -22632,7 +22785,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":298}],95:[function(require,module,exports){ +},{"safe-buffer":321}],94:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer function encryptByte (self, byteParam, decrypt) { @@ -22659,7 +22812,7 @@ exports.encrypt = function (self, chunk, decrypt) { return out } -},{"safe-buffer":298}],96:[function(require,module,exports){ +},{"safe-buffer":321}],95:[function(require,module,exports){ var xor = require('buffer-xor') var Buffer = require('safe-buffer').Buffer var incr32 = require('../incr32') @@ -22691,7 +22844,7 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -},{"../incr32":91,"buffer-xor":110,"safe-buffer":298}],97:[function(require,module,exports){ +},{"../incr32":90,"buffer-xor":109,"safe-buffer":321}],96:[function(require,module,exports){ exports.encrypt = function (self, block) { return self._cipher.encryptBlock(block) } @@ -22700,7 +22853,7 @@ exports.decrypt = function (self, block) { return self._cipher.decryptBlock(block) } -},{}],98:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ var modeModules = { ECB: require('./ecb'), CBC: require('./cbc'), @@ -22720,7 +22873,7 @@ for (var key in modes) { module.exports = modes -},{"./cbc":92,"./cfb":93,"./cfb1":94,"./cfb8":95,"./ctr":96,"./ecb":97,"./list.json":99,"./ofb":100}],99:[function(require,module,exports){ +},{"./cbc":91,"./cfb":92,"./cfb1":93,"./cfb8":94,"./ctr":95,"./ecb":96,"./list.json":98,"./ofb":99}],98:[function(require,module,exports){ module.exports={ "aes-128-ecb": { "cipher": "AES", @@ -22913,8 +23066,8 @@ module.exports={ } } -},{}],100:[function(require,module,exports){ -(function (Buffer){ +},{}],99:[function(require,module,exports){ +(function (Buffer){(function (){ var xor = require('buffer-xor') function getBlock (self) { @@ -22932,8 +23085,8 @@ exports.encrypt = function (self, chunk) { return xor(chunk, pad) } -}).call(this,require("buffer").Buffer) -},{"buffer":111,"buffer-xor":110}],101:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":110,"buffer-xor":109}],100:[function(require,module,exports){ var aes = require('./aes') var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') @@ -22962,7 +23115,7 @@ StreamCipher.prototype._final = function () { module.exports = StreamCipher -},{"./aes":85,"cipher-base":115,"inherits":238,"safe-buffer":298}],102:[function(require,module,exports){ +},{"./aes":84,"cipher-base":114,"inherits":258,"safe-buffer":321}],101:[function(require,module,exports){ var DES = require('browserify-des') var aes = require('browserify-aes/browser') var aesModes = require('browserify-aes/modes') @@ -23031,7 +23184,7 @@ exports.createDecipher = exports.Decipher = createDecipher exports.createDecipheriv = exports.Decipheriv = createDecipheriv exports.listCiphers = exports.getCiphers = getCiphers -},{"browserify-aes/browser":87,"browserify-aes/modes":98,"browserify-des":103,"browserify-des/modes":104,"evp_bytestokey":217}],103:[function(require,module,exports){ +},{"browserify-aes/browser":86,"browserify-aes/modes":97,"browserify-des":102,"browserify-des/modes":103,"evp_bytestokey":218}],102:[function(require,module,exports){ var CipherBase = require('cipher-base') var des = require('des.js') var inherits = require('inherits') @@ -23083,7 +23236,7 @@ DES.prototype._final = function () { return Buffer.from(this._des.final()) } -},{"cipher-base":115,"des.js":186,"inherits":238,"safe-buffer":298}],104:[function(require,module,exports){ +},{"cipher-base":114,"des.js":187,"inherits":258,"safe-buffer":321}],103:[function(require,module,exports){ exports['des-ecb'] = { key: 8, iv: 0 @@ -23109,9 +23262,9 @@ exports['des-ede'] = { iv: 0 } -},{}],105:[function(require,module,exports){ +},{}],104:[function(require,module,exports){ arguments[4][80][0].apply(exports,arguments) -},{"base-x":28,"dup":80}],106:[function(require,module,exports){ +},{"base-x":28,"dup":80}],105:[function(require,module,exports){ 'use strict' var base58 = require('bs58') @@ -23163,7 +23316,7 @@ module.exports = function (checksumFn) { } } -},{"bs58":105,"safe-buffer":298}],107:[function(require,module,exports){ +},{"bs58":104,"safe-buffer":321}],106:[function(require,module,exports){ 'use strict' var createHash = require('create-hash') @@ -23177,8 +23330,8 @@ function sha256x2 (buffer) { module.exports = bs58checkBase(sha256x2) -},{"./base":106,"create-hash":119}],108:[function(require,module,exports){ -(function (Buffer){ +},{"./base":105,"create-hash":118}],107:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; module.exports = function (a, b) { if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { @@ -23206,9 +23359,9 @@ module.exports = function (a, b) { return true; }; -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":239}],109:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":259}],108:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function reverse (src) { var buffer = new Buffer(src.length) @@ -23220,9 +23373,9 @@ module.exports = function reverse (src) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":111}],110:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":110}],109:[function(require,module,exports){ +(function (Buffer){(function (){ module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) var buffer = new Buffer(length) @@ -23234,8 +23387,9 @@ module.exports = function xor (a, b) { return buffer } -}).call(this,require("buffer").Buffer) -},{"buffer":111}],111:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":110}],110:[function(require,module,exports){ +(function (Buffer){(function (){ /*! * The buffer module from node.js, for the browser. * @@ -25014,7 +25168,8 @@ function numberIsNaN (obj) { return obj !== obj // eslint-disable-line no-self-compare } -},{"base64-js":112,"ieee754":236}],112:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"base64-js":111,"buffer":110,"ieee754":257}],111:[function(require,module,exports){ 'use strict' exports.byteLength = byteLength @@ -25082,7 +25237,8 @@ function toByteArray (b64) { ? validLen - 4 : validLen - for (var i = 0; i < len; i += 4) { + var i + for (i = 0; i < len; i += 4) { tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | @@ -25141,9 +25297,7 @@ function fromByteArray (uint8) { // go through the array every three bytes, we'll deal with trailing stuff later for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) } // pad the end with zeros, but make sure to not forget the extra bytes @@ -25167,7 +25321,7 @@ function fromByteArray (uint8) { return parts.join('') } -},{}],113:[function(require,module,exports){ +},{}],112:[function(require,module,exports){ 'use strict'; var BigInteger = require('bigi'); @@ -25354,8 +25508,8 @@ function fromWords(words) { } module.exports = { decode: decode, encode: encode, toWords: toWords, fromWords: fromWords }; -},{"bigi":32}],114:[function(require,module,exports){ -(function (Buffer){ +},{"bigi":32}],113:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict'; /** global: Buffer */ @@ -25457,8 +25611,8 @@ function decode(address) { } module.exports = { decode: decode, encode: encode }; -}).call(this,require("buffer").Buffer) -},{"./base32":113,"buffer":111}],115:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"./base32":112,"buffer":110}],114:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer var Transform = require('stream').Transform var StringDecoder = require('string_decoder').StringDecoder @@ -25559,7 +25713,7 @@ CipherBase.prototype._toString = function (value, enc, fin) { module.exports = CipherBase -},{"inherits":238,"safe-buffer":298,"stream":314,"string_decoder":220}],116:[function(require,module,exports){ +},{"inherits":258,"safe-buffer":321,"stream":238,"string_decoder":239}],115:[function(require,module,exports){ /** * Expose `Emitter`. @@ -25673,6 +25827,13 @@ Emitter.prototype.removeEventListener = function(event, fn){ break; } } + + // Remove event specific arrays for event types that no + // one is subscribed for to avoid memory leak. + if (callbacks.length === 0) { + delete this._callbacks['$' + event]; + } + return this; }; @@ -25686,9 +25847,14 @@ Emitter.prototype.removeEventListener = function(event, fn){ Emitter.prototype.emit = function(event){ this._callbacks = this._callbacks || {}; - var args = [].slice.call(arguments, 1) + + var args = new Array(arguments.length - 1) , callbacks = this._callbacks['$' + event]; + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) { @@ -25724,8 +25890,8 @@ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; -},{}],117:[function(require,module,exports){ -(function (Buffer){ +},{}],116:[function(require,module,exports){ +(function (Buffer){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25834,9 +26000,9 @@ function objectToString(o) { return Object.prototype.toString.call(o); } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":239}],118:[function(require,module,exports){ -(function (Buffer){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":259}],117:[function(require,module,exports){ +(function (Buffer){(function (){ var elliptic = require('elliptic') var BN = require('bn.js') @@ -25962,8 +26128,8 @@ function formatReturnValue (bn, enc, len) { } } -}).call(this,require("buffer").Buffer) -},{"bn.js":82,"buffer":111,"elliptic":201}],119:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":82,"buffer":110,"elliptic":202}],118:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var MD5 = require('md5.js') @@ -25995,14 +26161,14 @@ module.exports = function createHash (alg) { return new Hash(sha(alg)) } -},{"cipher-base":115,"inherits":238,"md5.js":242,"ripemd160":297,"sha.js":306}],120:[function(require,module,exports){ +},{"cipher-base":114,"inherits":258,"md5.js":262,"ripemd160":320,"sha.js":330}],119:[function(require,module,exports){ var MD5 = require('md5.js') module.exports = function (buffer) { return new MD5().update(buffer).digest() } -},{"md5.js":242}],121:[function(require,module,exports){ +},{"md5.js":262}],120:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Legacy = require('./legacy') @@ -26066,7 +26232,7 @@ module.exports = function createHmac (alg, key) { return new Hmac(alg, key) } -},{"./legacy":122,"cipher-base":115,"create-hash/md5":120,"inherits":238,"ripemd160":297,"safe-buffer":298,"sha.js":306}],122:[function(require,module,exports){ +},{"./legacy":121,"cipher-base":114,"create-hash/md5":119,"inherits":258,"ripemd160":320,"safe-buffer":321,"sha.js":330}],121:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var Buffer = require('safe-buffer').Buffer @@ -26114,7 +26280,7 @@ Hmac.prototype._final = function () { } module.exports = Hmac -},{"cipher-base":115,"inherits":238,"safe-buffer":298}],123:[function(require,module,exports){ +},{"cipher-base":114,"inherits":258,"safe-buffer":321}],122:[function(require,module,exports){ 'use strict' exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes') @@ -26213,8 +26379,10 @@ exports.constants = { 'POINT_CONVERSION_HYBRID': 6 } -},{"browserify-cipher":102,"browserify-sign":142,"browserify-sign/algos":139,"create-ecdh":118,"create-hash":119,"create-hmac":121,"diffie-hellman":192,"pbkdf2":248,"public-encrypt":251,"randombytes":282,"randomfill":283}],124:[function(require,module,exports){ -var asn1 = exports; +},{"browserify-cipher":101,"browserify-sign":143,"browserify-sign/algos":140,"create-ecdh":117,"create-hash":118,"create-hmac":120,"diffie-hellman":193,"pbkdf2":269,"public-encrypt":271,"randombytes":303,"randomfill":304}],123:[function(require,module,exports){ +'use strict'; + +const asn1 = exports; asn1.bignum = require('bn.js'); @@ -26224,11 +26392,14 @@ asn1.constants = require('./asn1/constants'); asn1.decoders = require('./asn1/decoders'); asn1.encoders = require('./asn1/encoders'); -},{"./asn1/api":125,"./asn1/base":127,"./asn1/constants":131,"./asn1/decoders":133,"./asn1/encoders":136,"bn.js":82}],125:[function(require,module,exports){ -var asn1 = require('../asn1'); -var inherits = require('inherits'); +},{"./asn1/api":124,"./asn1/base":126,"./asn1/constants":130,"./asn1/decoders":132,"./asn1/encoders":135,"bn.js":137}],124:[function(require,module,exports){ +'use strict'; + +const encoders = require('./encoders'); +const decoders = require('./decoders'); +const inherits = require('inherits'); -var api = exports; +const api = exports; api.define = function define(name, body) { return new Entity(name, body); @@ -26240,34 +26411,27 @@ function Entity(name, body) { this.decoders = {}; this.encoders = {}; -}; +} -Entity.prototype._createNamed = function createNamed(base) { - var named; - try { - named = require('vm').runInThisContext( - '(function ' + this.name + '(entity) {\n' + - ' this._initNamed(entity);\n' + - '})' - ); - } catch (e) { - named = function (entity) { - this._initNamed(entity); - }; +Entity.prototype._createNamed = function createNamed(Base) { + const name = this.name; + + function Generated(entity) { + this._initNamed(entity, name); } - inherits(named, base); - named.prototype._initNamed = function initnamed(entity) { - base.call(this, entity); + inherits(Generated, Base); + Generated.prototype._initNamed = function _initNamed(entity, name) { + Base.call(this, entity, name); }; - return new named(this); + return new Generated(this); }; Entity.prototype._getDecoder = function _getDecoder(enc) { enc = enc || 'der'; // Lazily create decoder if (!this.decoders.hasOwnProperty(enc)) - this.decoders[enc] = this._createNamed(asn1.decoders[enc]); + this.decoders[enc] = this._createNamed(decoders[enc]); return this.decoders[enc]; }; @@ -26279,7 +26443,7 @@ Entity.prototype._getEncoder = function _getEncoder(enc) { enc = enc || 'der'; // Lazily create encoder if (!this.encoders.hasOwnProperty(enc)) - this.encoders[enc] = this._createNamed(asn1.encoders[enc]); + this.encoders[enc] = this._createNamed(encoders[enc]); return this.encoders[enc]; }; @@ -26287,10 +26451,12 @@ Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) { return this._getEncoder(enc).encode(data, reporter); }; -},{"../asn1":124,"inherits":238,"vm":221}],126:[function(require,module,exports){ -var inherits = require('inherits'); -var Reporter = require('../base').Reporter; -var Buffer = require('buffer').Buffer; +},{"./decoders":132,"./encoders":135,"inherits":258}],125:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Reporter = require('../base/reporter').Reporter; +const Buffer = require('safer-buffer').Buffer; function DecoderBuffer(base, options) { Reporter.call(this, options); @@ -26306,13 +26472,34 @@ function DecoderBuffer(base, options) { inherits(DecoderBuffer, Reporter); exports.DecoderBuffer = DecoderBuffer; +DecoderBuffer.isDecoderBuffer = function isDecoderBuffer(data) { + if (data instanceof DecoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + Buffer.isBuffer(data.base) && + data.constructor.name === 'DecoderBuffer' && + typeof data.offset === 'number' && + typeof data.length === 'number' && + typeof data.save === 'function' && + typeof data.restore === 'function' && + typeof data.isEmpty === 'function' && + typeof data.readUInt8 === 'function' && + typeof data.skip === 'function' && + typeof data.raw === 'function'; + + return isCompatible; +}; + DecoderBuffer.prototype.save = function save() { return { offset: this.offset, reporter: Reporter.prototype.save.call(this) }; }; DecoderBuffer.prototype.restore = function restore(save) { // Return skipped data - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); res.offset = save.offset; res.length = this.offset; @@ -26331,13 +26518,13 @@ DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) { return this.base.readUInt8(this.offset++, true); else return this.error(fail || 'DecoderBuffer overrun'); -} +}; DecoderBuffer.prototype.skip = function skip(bytes, fail) { if (!(this.offset + bytes <= this.length)) return this.error(fail || 'DecoderBuffer overrun'); - var res = new DecoderBuffer(this.base); + const res = new DecoderBuffer(this.base); // Share reporter state res._reporterState = this._reporterState; @@ -26346,17 +26533,17 @@ DecoderBuffer.prototype.skip = function skip(bytes, fail) { res.length = this.offset + bytes; this.offset += bytes; return res; -} +}; DecoderBuffer.prototype.raw = function raw(save) { return this.base.slice(save ? save.offset : this.offset, this.length); -} +}; function EncoderBuffer(value, reporter) { if (Array.isArray(value)) { this.length = 0; this.value = value.map(function(item) { - if (!(item instanceof EncoderBuffer)) + if (!EncoderBuffer.isEncoderBuffer(item)) item = new EncoderBuffer(item, reporter); this.length += item.length; return item; @@ -26378,9 +26565,23 @@ function EncoderBuffer(value, reporter) { } exports.EncoderBuffer = EncoderBuffer; +EncoderBuffer.isEncoderBuffer = function isEncoderBuffer(data) { + if (data instanceof EncoderBuffer) { + return true; + } + + // Or accept compatible API + const isCompatible = typeof data === 'object' && + data.constructor.name === 'EncoderBuffer' && + typeof data.length === 'number' && + typeof data.join === 'function'; + + return isCompatible; +}; + EncoderBuffer.prototype.join = function join(out, offset) { if (!out) - out = new Buffer(this.length); + out = Buffer.alloc(this.length); if (!offset) offset = 0; @@ -26405,22 +26606,26 @@ EncoderBuffer.prototype.join = function join(out, offset) { return out; }; -},{"../base":127,"buffer":111,"inherits":238}],127:[function(require,module,exports){ -var base = exports; +},{"../base/reporter":128,"inherits":258,"safer-buffer":322}],126:[function(require,module,exports){ +'use strict'; + +const base = exports; base.Reporter = require('./reporter').Reporter; base.DecoderBuffer = require('./buffer').DecoderBuffer; base.EncoderBuffer = require('./buffer').EncoderBuffer; base.Node = require('./node'); -},{"./buffer":126,"./node":128,"./reporter":129}],128:[function(require,module,exports){ -var Reporter = require('../base').Reporter; -var EncoderBuffer = require('../base').EncoderBuffer; -var DecoderBuffer = require('../base').DecoderBuffer; -var assert = require('minimalistic-assert'); +},{"./buffer":125,"./node":127,"./reporter":128}],127:[function(require,module,exports){ +'use strict'; + +const Reporter = require('../base/reporter').Reporter; +const EncoderBuffer = require('../base/buffer').EncoderBuffer; +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const assert = require('minimalistic-assert'); // Supported tags -var tags = [ +const tags = [ 'seq', 'seqof', 'set', 'setof', 'objid', 'bool', 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc', 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str', @@ -26428,13 +26633,13 @@ var tags = [ ]; // Public methods list -var methods = [ +const methods = [ 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice', 'any', 'contains' ].concat(tags); // Overrided methods list -var overrided = [ +const overrided = [ '_peekTag', '_decodeTag', '_use', '_decodeStr', '_decodeObjid', '_decodeTime', '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList', @@ -26443,10 +26648,11 @@ var overrided = [ '_encodeNull', '_encodeInt', '_encodeBool' ]; -function Node(enc, parent) { - var state = {}; +function Node(enc, parent, name) { + const state = {}; this._baseState = state; + state.name = name; state.enc = enc; state.parent = parent || null; @@ -26476,28 +26682,28 @@ function Node(enc, parent) { } module.exports = Node; -var stateProps = [ +const stateProps = [ 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice', 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit', 'implicit', 'contains' ]; Node.prototype.clone = function clone() { - var state = this._baseState; - var cstate = {}; + const state = this._baseState; + const cstate = {}; stateProps.forEach(function(prop) { cstate[prop] = state[prop]; }); - var res = new this.constructor(cstate.parent); + const res = new this.constructor(cstate.parent); res._baseState = cstate; return res; }; Node.prototype._wrap = function wrap() { - var state = this._baseState; + const state = this._baseState; methods.forEach(function(method) { this[method] = function _wrappedMethod() { - var clone = new this.constructor(this); + const clone = new this.constructor(this); state.children.push(clone); return clone[method].apply(clone, arguments); }; @@ -26505,7 +26711,7 @@ Node.prototype._wrap = function wrap() { }; Node.prototype._init = function init(body) { - var state = this._baseState; + const state = this._baseState; assert(state.parent === null); body.call(this); @@ -26518,10 +26724,10 @@ Node.prototype._init = function init(body) { }; Node.prototype._useArgs = function useArgs(args) { - var state = this._baseState; + const state = this._baseState; // Filter children and args - var children = args.filter(function(arg) { + const children = args.filter(function(arg) { return arg instanceof this.constructor; }, this); args = args.filter(function(arg) { @@ -26544,11 +26750,11 @@ Node.prototype._useArgs = function useArgs(args) { if (typeof arg !== 'object' || arg.constructor !== Object) return arg; - var res = {}; + const res = {}; Object.keys(arg).forEach(function(key) { if (key == (key | 0)) key |= 0; - var value = arg[key]; + const value = arg[key]; res[value] = key; }); return res; @@ -26562,7 +26768,7 @@ Node.prototype._useArgs = function useArgs(args) { overrided.forEach(function(method) { Node.prototype[method] = function _overrided() { - var state = this._baseState; + const state = this._baseState; throw new Error(method + ' not implemented for encoding: ' + state.enc); }; }); @@ -26573,8 +26779,8 @@ overrided.forEach(function(method) { tags.forEach(function(tag) { Node.prototype[tag] = function _tagMethod() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); assert(state.tag === null); state.tag = tag; @@ -26587,7 +26793,7 @@ tags.forEach(function(tag) { Node.prototype.use = function use(item) { assert(item); - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.use = item; @@ -26596,7 +26802,7 @@ Node.prototype.use = function use(item) { }; Node.prototype.optional = function optional() { - var state = this._baseState; + const state = this._baseState; state.optional = true; @@ -26604,7 +26810,7 @@ Node.prototype.optional = function optional() { }; Node.prototype.def = function def(val) { - var state = this._baseState; + const state = this._baseState; assert(state['default'] === null); state['default'] = val; @@ -26614,7 +26820,7 @@ Node.prototype.def = function def(val) { }; Node.prototype.explicit = function explicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.explicit = num; @@ -26623,7 +26829,7 @@ Node.prototype.explicit = function explicit(num) { }; Node.prototype.implicit = function implicit(num) { - var state = this._baseState; + const state = this._baseState; assert(state.explicit === null && state.implicit === null); state.implicit = num; @@ -26632,8 +26838,8 @@ Node.prototype.implicit = function implicit(num) { }; Node.prototype.obj = function obj() { - var state = this._baseState; - var args = Array.prototype.slice.call(arguments); + const state = this._baseState; + const args = Array.prototype.slice.call(arguments); state.obj = true; @@ -26644,7 +26850,7 @@ Node.prototype.obj = function obj() { }; Node.prototype.key = function key(newKey) { - var state = this._baseState; + const state = this._baseState; assert(state.key === null); state.key = newKey; @@ -26653,7 +26859,7 @@ Node.prototype.key = function key(newKey) { }; Node.prototype.any = function any() { - var state = this._baseState; + const state = this._baseState; state.any = true; @@ -26661,7 +26867,7 @@ Node.prototype.any = function any() { }; Node.prototype.choice = function choice(obj) { - var state = this._baseState; + const state = this._baseState; assert(state.choice === null); state.choice = obj; @@ -26673,7 +26879,7 @@ Node.prototype.choice = function choice(obj) { }; Node.prototype.contains = function contains(item) { - var state = this._baseState; + const state = this._baseState; assert(state.use === null); state.contains = item; @@ -26686,22 +26892,22 @@ Node.prototype.contains = function contains(item) { // Node.prototype._decode = function decode(input, options) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return input.wrapResult(state.children[0]._decode(input, options)); - var result = state['default']; - var present = true; + let result = state['default']; + let present = true; - var prevKey = null; + let prevKey = null; if (state.key !== null) prevKey = input.enterKey(state.key); // Check if tag is there if (state.optional) { - var tag = null; + let tag = null; if (state.explicit !== null) tag = state.explicit; else if (state.implicit !== null) @@ -26711,7 +26917,7 @@ Node.prototype._decode = function decode(input, options) { if (tag === null && !state.any) { // Trial and Error - var save = input.save(); + const save = input.save(); try { if (state.choice === null) this._decodeGeneric(state.tag, input, options); @@ -26731,26 +26937,27 @@ Node.prototype._decode = function decode(input, options) { } // Push object on stack - var prevObj; + let prevObj; if (state.obj && present) prevObj = input.enterObject(); if (present) { // Unwrap explicit values if (state.explicit !== null) { - var explicit = this._decodeTag(input, state.explicit); + const explicit = this._decodeTag(input, state.explicit); if (input.isError(explicit)) return explicit; input = explicit; } - var start = input.offset; + const start = input.offset; // Unwrap implicit and normal values if (state.use === null && state.choice === null) { + let save; if (state.any) - var save = input.save(); - var body = this._decodeTag( + save = input.save(); + const body = this._decodeTag( input, state.implicit !== null ? state.implicit : state.tag, state.any @@ -26771,12 +26978,13 @@ Node.prototype._decode = function decode(input, options) { options.track(input.path(), input.offset, input.length, 'content'); // Select proper method for tag - if (state.any) - result = result; - else if (state.choice === null) + if (state.any) { + // no-op + } else if (state.choice === null) { result = this._decodeGeneric(state.tag, input, options); - else + } else { result = this._decodeChoice(input, options); + } if (input.isError(result)) return result; @@ -26792,9 +27000,9 @@ Node.prototype._decode = function decode(input, options) { // Decode contained/encoded by schema, only in bit or octet strings if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) { - var data = new DecoderBuffer(result); + const data = new DecoderBuffer(result); result = this._getUse(state.contains, input._reporterState.obj) - ._decode(data, options); + ._decode(data, options); } } @@ -26812,7 +27020,7 @@ Node.prototype._decode = function decode(input, options) { }; Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { - var state = this._baseState; + const state = this._baseState; if (tag === 'seq' || tag === 'set') return null; @@ -26837,7 +27045,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { if (state.use !== null) { return this._getUse(state.use, input._reporterState.obj) - ._decode(input, options); + ._decode(input, options); } else { return input.error('unknown tag: ' + tag); } @@ -26845,7 +27053,7 @@ Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) { Node.prototype._getUse = function _getUse(entity, obj) { - var state = this._baseState; + const state = this._baseState; // Create altered use decoder if implicit is set state.useDecoder = this._use(entity, obj); assert(state.useDecoder._baseState.parent === null); @@ -26858,15 +27066,15 @@ Node.prototype._getUse = function _getUse(entity, obj) { }; Node.prototype._decodeChoice = function decodeChoice(input, options) { - var state = this._baseState; - var result = null; - var match = false; + const state = this._baseState; + let result = null; + let match = false; Object.keys(state.choice).some(function(key) { - var save = input.save(); - var node = state.choice[key]; + const save = input.save(); + const node = state.choice[key]; try { - var value = node._decode(input, options); + const value = node._decode(input, options); if (input.isError(value)) return false; @@ -26894,11 +27102,11 @@ Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) { }; Node.prototype._encode = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; if (state['default'] !== null && state['default'] === data) return; - var result = this._encodeValue(data, reporter, parent); + const result = this._encodeValue(data, reporter, parent); if (result === undefined) return; @@ -26909,13 +27117,13 @@ Node.prototype._encode = function encode(data, reporter, parent) { }; Node.prototype._encodeValue = function encode(data, reporter, parent) { - var state = this._baseState; + const state = this._baseState; // Decode root node if (state.parent === null) return state.children[0]._encode(data, reporter || new Reporter()); - var result = null; + let result = null; // Set reporter to share it with a child class this.reporter = reporter; @@ -26923,14 +27131,14 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { // Check if data is there if (state.optional && data === undefined) { if (state['default'] !== null) - data = state['default'] + data = state['default']; else return; } // Encode children first - var content = null; - var primitive = false; + let content = null; + let primitive = false; if (state.any) { // Anything that was given is translated to buffer result = this._createEncoderBuffer(data); @@ -26946,12 +27154,12 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (child._baseState.key === null) return reporter.error('Child should have a key'); - var prevKey = reporter.enterKey(child._baseState.key); + const prevKey = reporter.enterKey(child._baseState.key); if (typeof data !== 'object') return reporter.error('Child expected, but input is not object'); - var res = child._encode(data[child._baseState.key], reporter, data); + const res = child._encode(data[child._baseState.key], reporter, data); reporter.leaveKey(prevKey); return res; @@ -26968,10 +27176,10 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { if (!Array.isArray(data)) return reporter.error('seqof/setof, but data is not Array'); - var child = this.clone(); + const child = this.clone(); child._baseState.implicit = null; content = this._createEncoderBuffer(data.map(function(item) { - var state = this._baseState; + const state = this._baseState; return this._getUse(state.args[0], data)._encode(item, reporter); }, child)); @@ -26984,10 +27192,9 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { } // Encode data itself - var result; if (!state.any && state.choice === null) { - var tag = state.implicit !== null ? state.implicit : state.tag; - var cls = state.implicit === null ? 'universal' : 'context'; + const tag = state.implicit !== null ? state.implicit : state.tag; + const cls = state.implicit === null ? 'universal' : 'context'; if (tag === null) { if (state.use === null) @@ -27006,20 +27213,20 @@ Node.prototype._encodeValue = function encode(data, reporter, parent) { }; Node.prototype._encodeChoice = function encodeChoice(data, reporter) { - var state = this._baseState; + const state = this._baseState; - var node = state.choice[data.type]; + const node = state.choice[data.type]; if (!node) { assert( - false, - data.type + ' not found in ' + + false, + data.type + ' not found in ' + JSON.stringify(Object.keys(state.choice))); } return node._encode(data.value, reporter); }; Node.prototype._encodePrimitive = function encodePrimitive(tag, data) { - var state = this._baseState; + const state = this._baseState; if (/str$/.test(tag)) return this._encodeStr(data, tag); @@ -27046,11 +27253,13 @@ Node.prototype._isNumstr = function isNumstr(str) { }; Node.prototype._isPrintstr = function isPrintstr(str) { - return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str); + return /^[A-Za-z0-9 '()+,-./:=?]*$/.test(str); }; -},{"../base":127,"minimalistic-assert":245}],129:[function(require,module,exports){ -var inherits = require('inherits'); +},{"../base/buffer":125,"../base/reporter":128,"minimalistic-assert":265}],128:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); function Reporter(options) { this._reporterState = { @@ -27067,13 +27276,13 @@ Reporter.prototype.isError = function isError(obj) { }; Reporter.prototype.save = function save() { - var state = this._reporterState; + const state = this._reporterState; return { obj: state.obj, pathLen: state.path.length }; }; Reporter.prototype.restore = function restore(data) { - var state = this._reporterState; + const state = this._reporterState; state.obj = data.obj; state.path = state.path.slice(0, data.pathLen); @@ -27084,13 +27293,13 @@ Reporter.prototype.enterKey = function enterKey(key) { }; Reporter.prototype.exitKey = function exitKey(index) { - var state = this._reporterState; + const state = this._reporterState; state.path = state.path.slice(0, index - 1); }; Reporter.prototype.leaveKey = function leaveKey(index, key, value) { - var state = this._reporterState; + const state = this._reporterState; this.exitKey(index); if (state.obj !== null) @@ -27102,26 +27311,26 @@ Reporter.prototype.path = function path() { }; Reporter.prototype.enterObject = function enterObject() { - var state = this._reporterState; + const state = this._reporterState; - var prev = state.obj; + const prev = state.obj; state.obj = {}; return prev; }; Reporter.prototype.leaveObject = function leaveObject(prev) { - var state = this._reporterState; + const state = this._reporterState; - var now = state.obj; + const now = state.obj; state.obj = prev; return now; }; Reporter.prototype.error = function error(msg) { - var err; - var state = this._reporterState; + let err; + const state = this._reporterState; - var inherited = msg instanceof ReporterError; + const inherited = msg instanceof ReporterError; if (inherited) { err = msg; } else { @@ -27140,7 +27349,7 @@ Reporter.prototype.error = function error(msg) { }; Reporter.prototype.wrapResult = function wrapResult(result) { - var state = this._reporterState; + const state = this._reporterState; if (!state.options.partial) return result; @@ -27153,7 +27362,7 @@ Reporter.prototype.wrapResult = function wrapResult(result) { function ReporterError(path, msg) { this.path = path; this.rethrow(msg); -}; +} inherits(ReporterError, Error); ReporterError.prototype.rethrow = function rethrow(msg) { @@ -27172,8 +27381,24 @@ ReporterError.prototype.rethrow = function rethrow(msg) { return this; }; -},{"inherits":238}],130:[function(require,module,exports){ -var constants = require('../constants'); +},{"inherits":258}],129:[function(require,module,exports){ +'use strict'; + +// Helper +function reverse(map) { + const res = {}; + + Object.keys(map).forEach(function(key) { + // Convert key to integer if it is stringified + if ((key | 0) == key) + key = key | 0; + + const value = map[key]; + res[value] = key; + }); + + return res; +} exports.tagClass = { 0: 'universal', @@ -27181,7 +27406,7 @@ exports.tagClass = { 2: 'context', 3: 'private' }; -exports.tagClassByName = constants._reverse(exports.tagClass); +exports.tagClassByName = reverse(exports.tagClass); exports.tag = { 0x00: 'end', @@ -27214,21 +27439,23 @@ exports.tag = { 0x1d: 'charstr', 0x1e: 'bmpstr' }; -exports.tagByName = constants._reverse(exports.tag); +exports.tagByName = reverse(exports.tag); + +},{}],130:[function(require,module,exports){ +'use strict'; -},{"../constants":131}],131:[function(require,module,exports){ -var constants = exports; +const constants = exports; // Helper constants._reverse = function reverse(map) { - var res = {}; + const res = {}; Object.keys(map).forEach(function(key) { // Convert key to integer if it is stringified if ((key | 0) == key) key = key | 0; - var value = map[key]; + const value = map[key]; res[value] = key; }); @@ -27237,15 +27464,17 @@ constants._reverse = function reverse(map) { constants.der = require('./der'); -},{"./der":130}],132:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":129}],131:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; -var bignum = asn1.bignum; +const inherits = require('inherits'); + +const bignum = require('bn.js'); +const DecoderBuffer = require('../base/buffer').DecoderBuffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DERDecoder(entity) { this.enc = 'der'; @@ -27255,12 +27484,13 @@ function DERDecoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DERDecoder; DERDecoder.prototype.decode = function decode(data, options) { - if (!(data instanceof base.DecoderBuffer)) - data = new base.DecoderBuffer(data, options); + if (!DecoderBuffer.isDecoderBuffer(data)) { + data = new DecoderBuffer(data, options); + } return this.tree._decode(data, options); }; @@ -27268,16 +27498,16 @@ DERDecoder.prototype.decode = function decode(data, options) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { if (buffer.isEmpty()) return false; - var state = buffer.save(); - var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); + const state = buffer.save(); + const decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; @@ -27288,14 +27518,14 @@ DERNode.prototype._peekTag = function peekTag(buffer, tag, any) { }; DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { - var decodedTag = derDecodeTag(buffer, - 'Failed to decode tag of "' + tag + '"'); + const decodedTag = derDecodeTag(buffer, + 'Failed to decode tag of "' + tag + '"'); if (buffer.isError(decodedTag)) return decodedTag; - var len = derDecodeLen(buffer, - decodedTag.primitive, - 'Failed to get length of "' + tag + '"'); + let len = derDecodeLen(buffer, + decodedTag.primitive, + 'Failed to get length of "' + tag + '"'); // Failure if (buffer.isError(len)) @@ -27312,10 +27542,10 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { return buffer.skip(len, 'Failed to match body of: "' + tag + '"'); // Indefinite length... find END tag - var state = buffer.save(); - var res = this._skipUntilEnd( - buffer, - 'Failed to skip indefinite length body: "' + this.tag + '"'); + const state = buffer.save(); + const res = this._skipUntilEnd( + buffer, + 'Failed to skip indefinite length body: "' + this.tag + '"'); if (buffer.isError(res)) return res; @@ -27325,17 +27555,17 @@ DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) { }; DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { - while (true) { - var tag = derDecodeTag(buffer, fail); + for (;;) { + const tag = derDecodeTag(buffer, fail); if (buffer.isError(tag)) return tag; - var len = derDecodeLen(buffer, tag.primitive, fail); + const len = derDecodeLen(buffer, tag.primitive, fail); if (buffer.isError(len)) return len; - var res; + let res; if (tag.primitive || len !== null) - res = buffer.skip(len) + res = buffer.skip(len); else res = this._skipUntilEnd(buffer, fail); @@ -27349,14 +27579,14 @@ DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) { }; DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, - options) { - var result = []; + options) { + const result = []; while (!buffer.isEmpty()) { - var possibleEnd = this._peekTag(buffer, 'end'); + const possibleEnd = this._peekTag(buffer, 'end'); if (buffer.isError(possibleEnd)) return possibleEnd; - var res = decoder.decode(buffer, 'der', options); + const res = decoder.decode(buffer, 'der', options); if (buffer.isError(res) && possibleEnd) break; result.push(res); @@ -27366,22 +27596,22 @@ DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder, DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { if (tag === 'bitstr') { - var unused = buffer.readUInt8(); + const unused = buffer.readUInt8(); if (buffer.isError(unused)) return unused; return { unused: unused, data: buffer.raw() }; } else if (tag === 'bmpstr') { - var raw = buffer.raw(); + const raw = buffer.raw(); if (raw.length % 2 === 1) return buffer.error('Decoding of string type: bmpstr length mismatch'); - var str = ''; - for (var i = 0; i < raw.length / 2; i++) { + let str = ''; + for (let i = 0; i < raw.length / 2; i++) { str += String.fromCharCode(raw.readUInt16BE(i * 2)); } return str; } else if (tag === 'numstr') { - var numstr = buffer.raw().toString('ascii'); + const numstr = buffer.raw().toString('ascii'); if (!this._isNumstr(numstr)) { return buffer.error('Decoding of string type: ' + 'numstr unsupported characters'); @@ -27392,7 +27622,7 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { } else if (tag === 'objDesc') { return buffer.raw(); } else if (tag === 'printstr') { - var printstr = buffer.raw().toString('ascii'); + const printstr = buffer.raw().toString('ascii'); if (!this._isPrintstr(printstr)) { return buffer.error('Decoding of string type: ' + 'printstr unsupported characters'); @@ -27406,11 +27636,12 @@ DERNode.prototype._decodeStr = function decodeStr(buffer, tag) { }; DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) { - var result; - var identifiers = []; - var ident = 0; + let result; + const identifiers = []; + let ident = 0; + let subident = 0; while (!buffer.isEmpty()) { - var subident = buffer.readUInt8(); + subident = buffer.readUInt8(); ident <<= 7; ident |= subident & 0x7f; if ((subident & 0x80) === 0) { @@ -27421,8 +27652,8 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) if (subident & 0x80) identifiers.push(ident); - var first = (identifiers[0] / 40) | 0; - var second = identifiers[0] % 40; + const first = (identifiers[0] / 40) | 0; + const second = identifiers[0] % 40; if (relative) result = identifiers; @@ -27430,7 +27661,7 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) result = [first, second].concat(identifiers.slice(1)); if (values) { - var tmp = values[result.join(' ')]; + let tmp = values[result.join(' ')]; if (tmp === undefined) tmp = values[result.join('.')]; if (tmp !== undefined) @@ -27441,21 +27672,28 @@ DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) }; DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { - var str = buffer.raw().toString(); + const str = buffer.raw().toString(); + + let year; + let mon; + let day; + let hour; + let min; + let sec; if (tag === 'gentime') { - var year = str.slice(0, 4) | 0; - var mon = str.slice(4, 6) | 0; - var day = str.slice(6, 8) | 0; - var hour = str.slice(8, 10) | 0; - var min = str.slice(10, 12) | 0; - var sec = str.slice(12, 14) | 0; + year = str.slice(0, 4) | 0; + mon = str.slice(4, 6) | 0; + day = str.slice(6, 8) | 0; + hour = str.slice(8, 10) | 0; + min = str.slice(10, 12) | 0; + sec = str.slice(12, 14) | 0; } else if (tag === 'utctime') { - var year = str.slice(0, 2) | 0; - var mon = str.slice(2, 4) | 0; - var day = str.slice(4, 6) | 0; - var hour = str.slice(6, 8) | 0; - var min = str.slice(8, 10) | 0; - var sec = str.slice(10, 12) | 0; + year = str.slice(0, 2) | 0; + mon = str.slice(2, 4) | 0; + day = str.slice(4, 6) | 0; + hour = str.slice(6, 8) | 0; + min = str.slice(8, 10) | 0; + sec = str.slice(10, 12) | 0; if (year < 70) year = 2000 + year; else @@ -27467,12 +27705,12 @@ DERNode.prototype._decodeTime = function decodeTime(buffer, tag) { return Date.UTC(year, mon - 1, day, hour, min, sec, 0); }; -DERNode.prototype._decodeNull = function decodeNull(buffer) { +DERNode.prototype._decodeNull = function decodeNull() { return null; }; DERNode.prototype._decodeBool = function decodeBool(buffer) { - var res = buffer.readUInt8(); + const res = buffer.readUInt8(); if (buffer.isError(res)) return res; else @@ -27481,8 +27719,8 @@ DERNode.prototype._decodeBool = function decodeBool(buffer) { DERNode.prototype._decodeInt = function decodeInt(buffer, values) { // Bigint, return as it is (assume big endian) - var raw = buffer.raw(); - var res = new bignum(raw); + const raw = buffer.raw(); + let res = new bignum(raw); if (values) res = values[res.toString(10)] || res; @@ -27499,16 +27737,16 @@ DERNode.prototype._use = function use(entity, obj) { // Utility methods function derDecodeTag(buf, fail) { - var tag = buf.readUInt8(fail); + let tag = buf.readUInt8(fail); if (buf.isError(tag)) return tag; - var cls = der.tagClass[tag >> 6]; - var primitive = (tag & 0x20) === 0; + const cls = der.tagClass[tag >> 6]; + const primitive = (tag & 0x20) === 0; // Multi-octet tag - load if ((tag & 0x1f) === 0x1f) { - var oct = tag; + let oct = tag; tag = 0; while ((oct & 0x80) === 0x80) { oct = buf.readUInt8(fail); @@ -27521,7 +27759,7 @@ function derDecodeTag(buf, fail) { } else { tag &= 0x1f; } - var tagStr = der.tag[tag]; + const tagStr = der.tag[tag]; return { cls: cls, @@ -27532,7 +27770,7 @@ function derDecodeTag(buf, fail) { } function derDecodeLen(buf, primitive, fail) { - var len = buf.readUInt8(fail); + let len = buf.readUInt8(fail); if (buf.isError(len)) return len; @@ -27547,14 +27785,14 @@ function derDecodeLen(buf, primitive, fail) { } // Long form - var num = len & 0x7f; + const num = len & 0x7f; if (num > 4) return buf.error('length octect is too long'); len = 0; - for (var i = 0; i < num; i++) { + for (let i = 0; i < num; i++) { len <<= 8; - var j = buf.readUInt8(fail); + const j = buf.readUInt8(fail); if (buf.isError(j)) return j; len |= j; @@ -27563,35 +27801,39 @@ function derDecodeLen(buf, primitive, fail) { return len; } -},{"../../asn1":124,"inherits":238}],133:[function(require,module,exports){ -var decoders = exports; +},{"../base/buffer":125,"../base/node":127,"../constants/der":129,"bn.js":137,"inherits":258}],132:[function(require,module,exports){ +'use strict'; + +const decoders = exports; decoders.der = require('./der'); decoders.pem = require('./pem'); -},{"./der":132,"./pem":134}],134:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":131,"./pem":133}],133:[function(require,module,exports){ +'use strict'; + +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; -var DERDecoder = require('./der'); +const DERDecoder = require('./der'); function PEMDecoder(entity) { DERDecoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMDecoder, DERDecoder); module.exports = PEMDecoder; PEMDecoder.prototype.decode = function decode(data, options) { - var lines = data.toString().split(/[\r\n]+/g); + const lines = data.toString().split(/[\r\n]+/g); - var label = options.label.toUpperCase(); + const label = options.label.toUpperCase(); - var re = /^-----(BEGIN|END) ([^-]+)-----$/; - var start = -1; - var end = -1; - for (var i = 0; i < lines.length; i++) { - var match = lines[i].match(re); + const re = /^-----(BEGIN|END) ([^-]+)-----$/; + let start = -1; + let end = -1; + for (let i = 0; i < lines.length; i++) { + const match = lines[i].match(re); if (match === null) continue; @@ -27612,23 +27854,23 @@ PEMDecoder.prototype.decode = function decode(data, options) { if (start === -1 || end === -1) throw new Error('PEM section not found for: ' + label); - var base64 = lines.slice(start + 1, end).join(''); + const base64 = lines.slice(start + 1, end).join(''); // Remove excessive symbols - base64.replace(/[^a-z0-9\+\/=]+/gi, ''); + base64.replace(/[^a-z0-9+/=]+/gi, ''); - var input = new Buffer(base64, 'base64'); + const input = Buffer.from(base64, 'base64'); return DERDecoder.prototype.decode.call(this, input, options); }; -},{"./der":132,"buffer":111,"inherits":238}],135:[function(require,module,exports){ -var inherits = require('inherits'); -var Buffer = require('buffer').Buffer; +},{"./der":131,"inherits":258,"safer-buffer":322}],134:[function(require,module,exports){ +'use strict'; -var asn1 = require('../../asn1'); -var base = asn1.base; +const inherits = require('inherits'); +const Buffer = require('safer-buffer').Buffer; +const Node = require('../base/node'); // Import DER constants -var der = asn1.constants.der; +const der = require('../constants/der'); function DEREncoder(entity) { this.enc = 'der'; @@ -27638,7 +27880,7 @@ function DEREncoder(entity) { // Construct base tree this.tree = new DERNode(); this.tree._init(entity.body); -}; +} module.exports = DEREncoder; DEREncoder.prototype.encode = function encode(data, reporter) { @@ -27648,19 +27890,19 @@ DEREncoder.prototype.encode = function encode(data, reporter) { // Tree methods function DERNode(parent) { - base.Node.call(this, 'der', parent); + Node.call(this, 'der', parent); } -inherits(DERNode, base.Node); +inherits(DERNode, Node); DERNode.prototype._encodeComposite = function encodeComposite(tag, - primitive, - cls, - content) { - var encodedTag = encodeTag(tag, primitive, cls, this.reporter); + primitive, + cls, + content) { + const encodedTag = encodeTag(tag, primitive, cls, this.reporter); // Short form if (content.length < 0x80) { - var header = new Buffer(2); + const header = Buffer.alloc(2); header[0] = encodedTag; header[1] = content.length; return this._createEncoderBuffer([ header, content ]); @@ -27668,15 +27910,15 @@ DERNode.prototype._encodeComposite = function encodeComposite(tag, // Long form // Count octets required to store length - var lenOctets = 1; - for (var i = content.length; i >= 0x100; i >>= 8) + let lenOctets = 1; + for (let i = content.length; i >= 0x100; i >>= 8) lenOctets++; - var header = new Buffer(1 + 1 + lenOctets); + const header = Buffer.alloc(1 + 1 + lenOctets); header[0] = encodedTag; header[1] = 0x80 | lenOctets; - for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) + for (let i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8) header[i] = j & 0xff; return this._createEncoderBuffer([ header, content ]); @@ -27686,8 +27928,8 @@ DERNode.prototype._encodeStr = function encodeStr(str, tag) { if (tag === 'bitstr') { return this._createEncoderBuffer([ str.unused | 0, str.data ]); } else if (tag === 'bmpstr') { - var buf = new Buffer(str.length * 2); - for (var i = 0; i < str.length; i++) { + const buf = Buffer.alloc(str.length * 2); + for (let i = 0; i < str.length; i++) { buf.writeUInt16BE(str.charCodeAt(i), i * 2); } return this._createEncoderBuffer(buf); @@ -27723,12 +27965,12 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { return this.reporter.error('string objid given, but no values map found'); if (!values.hasOwnProperty(id)) return this.reporter.error('objid not found in values map'); - id = values[id].split(/[\s\.]+/g); - for (var i = 0; i < id.length; i++) + id = values[id].split(/[\s.]+/g); + for (let i = 0; i < id.length; i++) id[i] |= 0; } else if (Array.isArray(id)) { id = id.slice(); - for (var i = 0; i < id.length; i++) + for (let i = 0; i < id.length; i++) id[i] |= 0; } @@ -27744,17 +27986,17 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) { } // Count number of octets - var size = 0; - for (var i = 0; i < id.length; i++) { - var ident = id[i]; + let size = 0; + for (let i = 0; i < id.length; i++) { + let ident = id[i]; for (size++; ident >= 0x80; ident >>= 7) size++; } - var objid = new Buffer(size); - var offset = objid.length - 1; - for (var i = id.length - 1; i >= 0; i--) { - var ident = id[i]; + const objid = Buffer.alloc(size); + let offset = objid.length - 1; + for (let i = id.length - 1; i >= 0; i--) { + let ident = id[i]; objid[offset--] = ident & 0x7f; while ((ident >>= 7) > 0) objid[offset--] = 0x80 | (ident & 0x7f); @@ -27771,12 +28013,12 @@ function two(num) { } DERNode.prototype._encodeTime = function encodeTime(time, tag) { - var str; - var date = new Date(time); + let str; + const date = new Date(time); if (tag === 'gentime') { str = [ - two(date.getFullYear()), + two(date.getUTCFullYear()), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -27786,7 +28028,7 @@ DERNode.prototype._encodeTime = function encodeTime(time, tag) { ].join(''); } else if (tag === 'utctime') { str = [ - two(date.getFullYear() % 100), + two(date.getUTCFullYear() % 100), two(date.getUTCMonth() + 1), two(date.getUTCDate()), two(date.getUTCHours()), @@ -27818,22 +28060,22 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { // Bignum, assume big endian if (typeof num !== 'number' && !Buffer.isBuffer(num)) { - var numArray = num.toArray(); + const numArray = num.toArray(); if (!num.sign && numArray[0] & 0x80) { numArray.unshift(0); } - num = new Buffer(numArray); + num = Buffer.from(numArray); } if (Buffer.isBuffer(num)) { - var size = num.length; + let size = num.length; if (num.length === 0) size++; - var out = new Buffer(size); + const out = Buffer.alloc(size); num.copy(out); if (num.length === 0) - out[0] = 0 + out[0] = 0; return this._createEncoderBuffer(out); } @@ -27843,12 +28085,12 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { if (num < 0x100) return this._createEncoderBuffer([0, num]); - var size = 1; - for (var i = num; i >= 0x100; i >>= 8) + let size = 1; + for (let i = num; i >= 0x100; i >>= 8) size++; - var out = new Array(size); - for (var i = out.length - 1; i >= 0; i--) { + const out = new Array(size); + for (let i = out.length - 1; i >= 0; i--) { out[i] = num & 0xff; num >>= 8; } @@ -27856,7 +28098,7 @@ DERNode.prototype._encodeInt = function encodeInt(num, values) { out.unshift(0); } - return this._createEncoderBuffer(new Buffer(out)); + return this._createEncoderBuffer(Buffer.from(out)); }; DERNode.prototype._encodeBool = function encodeBool(value) { @@ -27870,12 +28112,12 @@ DERNode.prototype._use = function use(entity, obj) { }; DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) { - var state = this._baseState; - var i; + const state = this._baseState; + let i; if (state['default'] === null) return false; - var data = dataBuffer.join(); + const data = dataBuffer.join(); if (state.defaultBuffer === undefined) state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join(); @@ -27892,7 +28134,7 @@ DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, pare // Utility methods function encodeTag(tag, primitive, cls, reporter) { - var res; + let res; if (tag === 'seqof') tag = 'seq'; @@ -27917,5057 +28159,4501 @@ function encodeTag(tag, primitive, cls, reporter) { return res; } -},{"../../asn1":124,"buffer":111,"inherits":238}],136:[function(require,module,exports){ -var encoders = exports; +},{"../base/node":127,"../constants/der":129,"inherits":258,"safer-buffer":322}],135:[function(require,module,exports){ +'use strict'; + +const encoders = exports; encoders.der = require('./der'); encoders.pem = require('./pem'); -},{"./der":135,"./pem":137}],137:[function(require,module,exports){ -var inherits = require('inherits'); +},{"./der":134,"./pem":136}],136:[function(require,module,exports){ +'use strict'; -var DEREncoder = require('./der'); +const inherits = require('inherits'); + +const DEREncoder = require('./der'); function PEMEncoder(entity) { DEREncoder.call(this, entity); this.enc = 'pem'; -}; +} inherits(PEMEncoder, DEREncoder); module.exports = PEMEncoder; PEMEncoder.prototype.encode = function encode(data, options) { - var buf = DEREncoder.prototype.encode.call(this, data); + const buf = DEREncoder.prototype.encode.call(this, data); - var p = buf.toString('base64'); - var out = [ '-----BEGIN ' + options.label + '-----' ]; - for (var i = 0; i < p.length; i += 64) + const p = buf.toString('base64'); + const out = [ '-----BEGIN ' + options.label + '-----' ]; + for (let i = 0; i < p.length; i += 64) out.push(p.slice(i, i + 64)); out.push('-----END ' + options.label + '-----'); return out.join('\n'); }; -},{"./der":135,"inherits":238}],138:[function(require,module,exports){ -(function (Buffer){ -var bn = require('bn.js'); -var randomBytes = require('randombytes'); -module.exports = crt; -function blind(priv) { - var r = getr(priv); - var blinder = r.toRed(bn.mont(priv.modulus)) - .redPow(new bn(priv.publicExponent)).fromRed(); - return { - blinder: blinder, - unblinder:r.invm(priv.modulus) - }; -} -function crt(msg, priv) { - var blinds = blind(priv); - var len = priv.modulus.byteLength(); - var mod = bn.mont(priv.modulus); - var blinded = new bn(msg).mul(blinds.blinder).umod(priv.modulus); - var c1 = blinded.toRed(bn.mont(priv.prime1)); - var c2 = blinded.toRed(bn.mont(priv.prime2)); - var qinv = priv.coefficient; - var p = priv.prime1; - var q = priv.prime2; - var m1 = c1.redPow(priv.exponent1); - var m2 = c2.redPow(priv.exponent2); - m1 = m1.fromRed(); - m2 = m2.fromRed(); - var h = m1.isub(m2).imul(qinv).umod(p); - h.imul(q); - m2.iadd(h); - return new Buffer(m2.imul(blinds.unblinder).umod(priv.modulus).toArray(false, len)); -} -crt.getr = getr; -function getr(priv) { - var len = priv.modulus.byteLength(); - var r = new bn(randomBytes(len)); - while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) { - r = new bn(randomBytes(len)); - } - return r; -} +},{"./der":134,"inherits":258}],137:[function(require,module,exports){ +arguments[4][82][0].apply(exports,arguments) +},{"buffer":219,"dup":82}],138:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; -}).call(this,require("buffer").Buffer) -},{"bn.js":82,"buffer":111,"randombytes":282}],139:[function(require,module,exports){ -module.exports = require('./browser/algorithms.json') + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } -},{"./browser/algorithms.json":140}],140:[function(require,module,exports){ -module.exports={ - "sha224WithRSAEncryption": { - "sign": "rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "RSA-SHA224": { - "sign": "ecdsa/rsa", - "hash": "sha224", - "id": "302d300d06096086480165030402040500041c" - }, - "sha256WithRSAEncryption": { - "sign": "rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "RSA-SHA256": { - "sign": "ecdsa/rsa", - "hash": "sha256", - "id": "3031300d060960864801650304020105000420" - }, - "sha384WithRSAEncryption": { - "sign": "rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "RSA-SHA384": { - "sign": "ecdsa/rsa", - "hash": "sha384", - "id": "3041300d060960864801650304020205000430" - }, - "sha512WithRSAEncryption": { - "sign": "rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA512": { - "sign": "ecdsa/rsa", - "hash": "sha512", - "id": "3051300d060960864801650304020305000440" - }, - "RSA-SHA1": { - "sign": "rsa", - "hash": "sha1", - "id": "3021300906052b0e03021a05000414" - }, - "ecdsa-with-SHA1": { - "sign": "ecdsa", - "hash": "sha1", - "id": "" - }, - "sha256": { - "sign": "ecdsa", - "hash": "sha256", - "id": "" - }, - "sha224": { - "sign": "ecdsa", - "hash": "sha224", - "id": "" - }, - "sha384": { - "sign": "ecdsa", - "hash": "sha384", - "id": "" - }, - "sha512": { - "sign": "ecdsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-SHA1": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA": { - "sign": "dsa", - "hash": "sha1", - "id": "" - }, - "DSA-WITH-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-SHA224": { - "sign": "dsa", - "hash": "sha224", - "id": "" - }, - "DSA-WITH-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-SHA256": { - "sign": "dsa", - "hash": "sha256", - "id": "" - }, - "DSA-WITH-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-SHA384": { - "sign": "dsa", - "hash": "sha384", - "id": "" - }, - "DSA-WITH-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-SHA512": { - "sign": "dsa", - "hash": "sha512", - "id": "" - }, - "DSA-RIPEMD160": { - "sign": "dsa", - "hash": "rmd160", - "id": "" - }, - "ripemd160WithRSA": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "RSA-RIPEMD160": { - "sign": "rsa", - "hash": "rmd160", - "id": "3021300906052b2403020105000414" - }, - "md5WithRSAEncryption": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" - }, - "RSA-MD5": { - "sign": "rsa", - "hash": "md5", - "id": "3020300c06082a864886f70d020505000410" + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; } -} -},{}],141:[function(require,module,exports){ -module.exports={ - "1.3.132.0.10": "secp256k1", - "1.3.132.0.33": "p224", - "1.2.840.10045.3.1.1": "p192", - "1.2.840.10045.3.1.7": "p256", - "1.3.132.0.34": "p384", - "1.3.132.0.35": "p521" -} + // BN -},{}],142:[function(require,module,exports){ -(function (Buffer){ -var createHash = require('create-hash') -var stream = require('stream') -var inherits = require('inherits') -var sign = require('./sign') -var verify = require('./verify') + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } -var algorithms = require('./algorithms.json') -Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = new Buffer(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] -}) + this.negative = 0; + this.words = null; + this.length = 0; -function Sign (algorithm) { - stream.Writable.call(this) + // Reduction context + this.red = null; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Sign, stream.Writable) + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + BN.BN = BN; + BN.wordSize = 26; -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } - this._hash.update(data) - return this -} + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; - return enc ? sig.toString(enc) : sig -} + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; -function Verify (algorithm) { - stream.Writable.call(this) + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign -} -inherits(Verify, stream.Writable) + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = new Buffer(data, enc) + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } - this._hash.update(data) - return this -} + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = new Buffer(sig, enc) + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) -} + if (endian !== 'le') return; -function createSign (algorithm) { - return new Sign(algorithm) -} + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; -function createVerify (algorithm) { - return new Verify(algorithm) -} + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } -module.exports = { - Sign: createSign, - Verify: createVerify, - createSign: createSign, - createVerify: createVerify -} + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } -}).call(this,require("buffer").Buffer) -},{"./algorithms.json":140,"./sign":143,"./verify":144,"buffer":111,"create-hash":119,"inherits":238,"stream":314}],143:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var createHmac = require('create-hmac') -var crt = require('browserify-rsa') -var EC = require('elliptic').ec -var BN = require('bn.js') -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; -function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) - if (priv.curve) { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) - } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [ 0, 1 ] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) - - var out = crt(pad, priv) - return out -} - -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) - - return new Buffer(out.toDER()) -} -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) - while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) - if (s.cmpn(0) === 0) { - s = false - r = new BN(0) + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; } + return r; } - return toDER(r, s) -} -function toDER (r, s) { - r = r.toArray() - s = s.toArray() - - // Pad values - if (r[0] & 0x80) r = [ 0 ].concat(r) - if (s[0] & 0x80) s = [ 0 ].concat(s) + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } - var total = r.length + s.length + 4 - var res = [ 0x30, total, 0x02, r.length ] - res = res.concat(r, [ 0x02, s.length ], s) - return new Buffer(res) -} + // 24-bits chunks + var off = 0; + var j = 0; -function getKey (x, q, hash, algo) { - x = new Buffer(x.toArray()) - if (x.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - x.length) - zeros.fill(0) - x = Buffer.concat([ zeros, x ]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = new Buffer(hlen) - v.fill(1) - var k = new Buffer(hlen) - k.fill(0) - k = createHmac(algo, k).update(v).update(new Buffer([ 0 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(new Buffer([ 1 ])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } -} + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits -} + this._strip(); + }; -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = new Buffer(bits.toArray()) - if (out.length < q.byteLength()) { - var zeros = new Buffer(q.byteLength() - out.length) - zeros.fill(0) - out = Buffer.concat([ zeros, out ]) - } - return out -} + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; -function makeKey (q, kv, algo) { - var t - var k + r *= mul; - do { - t = new Buffer(0) + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; - while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([ t, kv.v ]) + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; + + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; } + return r; + } - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(new Buffer([ 0 ])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; - return k -} + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) -} + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); -}).call(this,require("buffer").Buffer) -},{"./curves.json":141,"bn.js":82,"browserify-rsa":138,"buffer":111,"create-hmac":121,"elliptic":201,"parse-asn1":149}],144:[function(require,module,exports){ -(function (Buffer){ -// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var BN = require('bn.js') -var EC = require('elliptic').ec -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) - if (pub.type === 'ec') { - // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) - } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [ 1 ] - var padNum = 0 - while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ - } - pad.push(0x00) - var i = -1 - while (++i < hash.length) { - pad.push(hash[i]) - } - pad = new Buffer(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - sig = sig.redPow(new BN(pub.publicExponent)) - sig = new Buffer(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 + for (i = 0; i < mod; i++) { + pow *= base; + } - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 -} + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) + this._strip(); + }; - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; - return curve.verify(hash, sig, pubkey) -} + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) - var v = g.toRed(montp) - .redPow(new BN(hash).mul(w).mod(q)) - .fromRed() - .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) - .mod(p) - .mod(q) - return v.cmp(r) === 0 -} + BN.prototype._move = function _move (dest) { + move(dest, this); + }; -function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') -} + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; -module.exports = verify + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; -}).call(this,require("buffer").Buffer) -},{"./curves.json":141,"bn.js":82,"buffer":111,"elliptic":201,"parse-asn1":149}],145:[function(require,module,exports){ -module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", -"2.16.840.1.101.3.4.1.2": "aes-128-cbc", -"2.16.840.1.101.3.4.1.3": "aes-128-ofb", -"2.16.840.1.101.3.4.1.4": "aes-128-cfb", -"2.16.840.1.101.3.4.1.21": "aes-192-ecb", -"2.16.840.1.101.3.4.1.22": "aes-192-cbc", -"2.16.840.1.101.3.4.1.23": "aes-192-ofb", -"2.16.840.1.101.3.4.1.24": "aes-192-cfb", -"2.16.840.1.101.3.4.1.41": "aes-256-ecb", -"2.16.840.1.101.3.4.1.42": "aes-256-cbc", -"2.16.840.1.101.3.4.1.43": "aes-256-ofb", -"2.16.840.1.101.3.4.1.44": "aes-256-cfb" -} -},{}],146:[function(require,module,exports){ -// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js -// Fedor, you are amazing. -'use strict' + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; -var asn1 = require('asn1.js') + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; -exports.certificate = require('./certificate') + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } -var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('modulus').int(), - this.key('publicExponent').int(), - this.key('privateExponent').int(), - this.key('prime1').int(), - this.key('prime2').int(), - this.key('exponent1').int(), - this.key('exponent2').int(), - this.key('coefficient').int() - ) -}) -exports.RSAPrivateKey = RSAPrivateKey + function inspect () { + return (this.red ? ''; + } -var RSAPublicKey = asn1.define('RSAPublicKey', function () { - this.seq().obj( - this.key('modulus').int(), - this.key('publicExponent').int() - ) -}) -exports.RSAPublicKey = RSAPublicKey + /* -var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) -exports.PublicKey = PublicKey + var zeros = []; + var groupSizes = []; + var groupBases = []; -var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('none').null_().optional(), - this.key('curve').objid().optional(), - this.key('params').seq().obj( - this.key('p').int(), - this.key('q').int(), - this.key('g').int() - ).optional() - ) -}) + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } -var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { - this.seq().obj( - this.key('version').int(), - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPrivateKey').octstr() - ) -}) -exports.PrivateKey = PrivateKeyInfo -var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { - this.seq().obj( - this.key('algorithm').seq().obj( - this.key('id').objid(), - this.key('decrypt').seq().obj( - this.key('kde').seq().obj( - this.key('id').objid(), - this.key('kdeparams').seq().obj( - this.key('salt').octstr(), - this.key('iters').int() - ) - ), - this.key('cipher').seq().obj( - this.key('algo').objid(), - this.key('iv').octstr() - ) - ) - ), - this.key('subjectPrivateKey').octstr() - ) -}) + */ -exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo + var zeros = [ + '', + '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' + ]; -var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('p').int(), - this.key('q').int(), - this.key('g').int(), - this.key('pub_key').int(), - this.key('priv_key').int() - ) -}) -exports.DSAPrivateKey = DSAPrivateKey + var groupSizes = [ + 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 + ]; -exports.DSAparam = asn1.define('DSAparam', function () { - this.int() -}) + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; -var ECPrivateKey = asn1.define('ECPrivateKey', function () { - this.seq().obj( - this.key('version').int(), - this.key('privateKey').octstr(), - this.key('parameters').optional().explicit(0).use(ECParameters), - this.key('publicKey').optional().explicit(1).bitstr() - ) -}) -exports.ECPrivateKey = ECPrivateKey + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; -var ECParameters = asn1.define('ECParameters', function () { - this.choice({ - namedCurve: this.objid() - }) -}) + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -exports.signature = asn1.define('signature', function () { - this.seq().obj( - this.key('r').int(), - this.key('s').int() - ) -}) + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); -},{"./certificate":147,"asn1.js":124}],147:[function(require,module,exports){ -// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js -// thanks to @Rantanen + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } -'use strict' + assert(false, 'Base should be between 2 and 36'); + }; -var asn = require('asn1.js') + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; -var Time = asn.define('Time', function () { - this.choice({ - utcTime: this.utctime(), - generalTime: this.gentime() - }) -}) + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; -var AttributeTypeValue = asn.define('AttributeTypeValue', function () { - this.seq().obj( - this.key('type').objid(), - this.key('value').any() - ) -}) + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } -var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { - this.seq().obj( - this.key('algorithm').objid(), - this.key('parameters').optional() - ) -}) + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; -var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { - this.seq().obj( - this.key('algorithm').use(AlgorithmIdentifier), - this.key('subjectPublicKey').bitstr() - ) -}) + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; -var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { - this.setof(AttributeTypeValue) -}) + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); -var RDNSequence = asn.define('RDNSequence', function () { - this.seqof(RelativeDistinguishedName) -}) + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); -var Name = asn.define('Name', function () { - this.choice({ - rdnSequence: this.use(RDNSequence) - }) -}) + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; -var Validity = asn.define('Validity', function () { - this.seq().obj( - this.key('notBefore').use(Time), - this.key('notAfter').use(Time) - ) -}) + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; -var Extension = asn.define('Extension', function () { - this.seq().obj( - this.key('extnID').objid(), - this.key('critical').bool().def(false), - this.key('extnValue').octstr() - ) -}) + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; -var TBSCertificate = asn.define('TBSCertificate', function () { - this.seq().obj( - this.key('version').explicit(0).int(), - this.key('serialNumber').int(), - this.key('signature').use(AlgorithmIdentifier), - this.key('issuer').use(Name), - this.key('validity').use(Validity), - this.key('subject').use(Name), - this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), - this.key('issuerUniqueID').implicit(1).bitstr().optional(), - this.key('subjectUniqueID').implicit(2).bitstr().optional(), - this.key('extensions').explicit(3).seqof(Extension).optional() - ) -}) + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } -var X509Certificate = asn.define('X509Certificate', function () { - this.seq().obj( - this.key('tbsCertificate').use(TBSCertificate), - this.key('signatureAlgorithm').use(AlgorithmIdentifier), - this.key('signatureValue').bitstr() - ) -}) + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } -module.exports = X509Certificate + if (position < res.length) { + res[position++] = carry; -},{"asn1.js":124}],148:[function(require,module,exports){ -(function (Buffer){ -// adapted from https://github.com/apatil/pemstrip -var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r\+\/\=]+)[\n\r]+/m -var startRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----/m -var fullRegex = /^-----BEGIN ((?:.* KEY)|CERTIFICATE)-----([0-9A-z\n\r\+\/\=]+)-----END \1-----$/m -var evp = require('evp_bytestokey') -var ciphers = require('browserify-aes') -module.exports = function (okey, password) { - var key = okey.toString() - var match = key.match(findProc) - var decrypted - if (!match) { - var match2 = key.match(fullRegex) - decrypted = new Buffer(match2[2].replace(/[\r\n]/g, ''), 'base64') - } else { - var suite = 'aes' + match[1] - var iv = new Buffer(match[2], 'hex') - var cipherText = new Buffer(match[3].replace(/[\r\n]/g, ''), 'base64') - var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key - var out = [] - var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - decrypted = Buffer.concat(out) - } - var tag = key.match(startRegex)[1] - return { - tag: tag, - data: decrypted - } -} + while (position < res.length) { + res[position++] = 0; + } + } + }; -}).call(this,require("buffer").Buffer) -},{"browserify-aes":87,"buffer":111,"evp_bytestokey":217}],149:[function(require,module,exports){ -(function (Buffer){ -var asn1 = require('./asn1') -var aesid = require('./aesid.json') -var fixProc = require('./fixProc') -var ciphers = require('browserify-aes') -var compat = require('pbkdf2') -module.exports = parseKeys + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; -function parseKeys (buffer) { - var password - if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { - password = buffer.passphrase - buffer = buffer.key - } - if (typeof buffer === 'string') { - buffer = new Buffer(buffer) - } + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; - var stripped = fixProc(buffer, password) + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } - var type = stripped.tag - var data = stripped.data - var subtype, ndata - switch (type) { - case 'CERTIFICATE': - ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo - // falls through - case 'PUBLIC KEY': - if (!ndata) { - ndata = asn1.PublicKey.decode(data, 'der') + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; } - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') - case '1.2.840.10045.2.1': - ndata.subjectPrivateKey = ndata.subjectPublicKey - return { - type: 'ec', - data: ndata - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') - return { - type: 'dsa', - data: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; } - throw new Error('unknown key type ' + type) - case 'ENCRYPTED PRIVATE KEY': - data = asn1.EncryptedPrivateKey.decode(data, 'der') - data = decrypt(data, password) - // falls through - case 'PRIVATE KEY': - ndata = asn1.PrivateKey.decode(data, 'der') - subtype = ndata.algorithm.algorithm.join('.') - switch (subtype) { - case '1.2.840.113549.1.1.1': - return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') - case '1.2.840.10045.2.1': - return { - curve: ndata.algorithm.curve, - privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey - } - case '1.2.840.10040.4.1': - ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') - return { - type: 'dsa', - params: ndata.algorithm.params - } - default: throw new Error('unknown key id ' + subtype) + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; } - throw new Error('unknown key type ' + type) - case 'RSA PUBLIC KEY': - return asn1.RSAPublicKey.decode(data, 'der') - case 'RSA PRIVATE KEY': - return asn1.RSAPrivateKey.decode(data, 'der') - case 'DSA PRIVATE KEY': - return { - type: 'dsa', - params: asn1.DSAPrivateKey.decode(data, 'der') + if (t >= 0x40) { + r += 7; + t >>>= 7; } - case 'EC PRIVATE KEY': - data = asn1.ECPrivateKey.decode(data, 'der') - return { - curve: data.parameters.value, - privateKey: data.privateKey + if (t >= 0x8) { + r += 4; + t >>>= 4; } - default: throw new Error('unknown key type ' + type) + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; } -} -parseKeys.signature = asn1.signature -function decrypt (data, password) { - var salt = data.algorithm.decrypt.kde.kdeparams.salt - var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) - var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] - var iv = data.algorithm.decrypt.cipher.iv - var cipherText = data.subjectPrivateKey - var keylen = parseInt(algo.split('-')[1], 10) / 8 - var key = compat.pbkdf2Sync(password, salt, iters, keylen) - var cipher = ciphers.createDecipheriv(algo, key, iv) - var out = [] - out.push(cipher.update(cipherText)) - out.push(cipher.final()) - return Buffer.concat(out) -} -}).call(this,require("buffer").Buffer) -},{"./aesid.json":145,"./asn1":146,"./fixProc":148,"browserify-aes":87,"buffer":111,"pbkdf2":248}],150:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; - // Lookup tables - var SBOX = []; - var INV_SBOX = []; - var SUB_MIX_0 = []; - var SUB_MIX_1 = []; - var SUB_MIX_2 = []; - var SUB_MIX_3 = []; - var INV_SUB_MIX_0 = []; - var INV_SUB_MIX_1 = []; - var INV_SUB_MIX_2 = []; - var INV_SUB_MIX_3 = []; + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; - // Compute lookup tables - (function () { - // Compute double table - var d = []; - for (var i = 0; i < 256; i++) { - if (i < 128) { - d[i] = i << 1; - } else { - d[i] = (i << 1) ^ 0x11b; - } - } + function toBitArray (num) { + var w = new Array(num.bitLength()); - // Walk GF(2^8) - var x = 0; - var xi = 0; - for (var i = 0; i < 256; i++) { - // Compute sbox - var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); - sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; - SBOX[x] = sx; - INV_SBOX[sx] = x; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - // Compute multiplication - var x2 = d[x]; - var x4 = d[x2]; - var x8 = d[x4]; + w[bit] = (num.words[off] >>> wbit) & 0x01; + } - // Compute sub bytes, mix columns tables - var t = (d[sx] * 0x101) ^ (sx * 0x1010100); - SUB_MIX_0[x] = (t << 24) | (t >>> 8); - SUB_MIX_1[x] = (t << 16) | (t >>> 16); - SUB_MIX_2[x] = (t << 8) | (t >>> 24); - SUB_MIX_3[x] = t; + return w; + } - // Compute inv sub bytes, inv mix columns tables - var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); - INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); - INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); - INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); - INV_SUB_MIX_3[sx] = t; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - // Compute next counter - if (!x) { - x = xi = 1; - } else { - x = x2 ^ d[d[d[x8 ^ x2]]]; - xi ^= d[d[xi]]; - } - } - }()); + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; - // Precomputed Rcon lookup - var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; - /** - * AES block cipher algorithm. - */ - var AES = C_algo.AES = BlockCipher.extend({ - _doReset: function () { - // Skip reset of nRounds has been set before and key did not change - if (this._nRounds && this._keyPriorReset === this._key) { - return; - } + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; - // Shortcuts - var key = this._keyPriorReset = this._key; - var keyWords = key.words; - var keySize = key.sigBytes / 4; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; - // Compute number of rounds - var nRounds = this._nRounds = keySize + 6; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; - // Compute number of key schedule rows - var ksRows = (nRounds + 1) * 4; + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; - // Compute key schedule - var keySchedule = this._keySchedule = []; - for (var ksRow = 0; ksRow < ksRows; ksRow++) { - if (ksRow < keySize) { - keySchedule[ksRow] = keyWords[ksRow]; - } else { - var t = keySchedule[ksRow - 1]; + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } - if (!(ksRow % keySize)) { - // Rot word - t = (t << 8) | (t >>> 24); + return this; + }; - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } - // Mix Rcon - t ^= RCON[(ksRow / keySize) | 0] << 24; - } else if (keySize > 6 && ksRow % keySize == 4) { - // Sub word - t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - } + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } - keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; - } - } + return this._strip(); + }; - // Compute inv key schedule - var invKeySchedule = this._invKeySchedule = []; - for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { - var ksRow = ksRows - invKsRow; + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; - if (invKsRow % 4) { - var t = keySchedule[ksRow]; - } else { - var t = keySchedule[ksRow - 4]; - } + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; - if (invKsRow < 4 || ksRow <= 4) { - invKeySchedule[invKsRow] = t; - } else { - invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ - INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; - } - } - }, + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); - }, + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } - decryptBlock: function (M, offset) { - // Swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } - this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + this.length = b.length; - // Inv swap 2nd and 4th rows - var t = M[offset + 1]; - M[offset + 1] = M[offset + 3]; - M[offset + 3] = t; - }, + return this._strip(); + }; - _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { - // Shortcut - var nRounds = this._nRounds; + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; - // Get input, add round key - var s0 = M[offset] ^ keySchedule[0]; - var s1 = M[offset + 1] ^ keySchedule[1]; - var s2 = M[offset + 2] ^ keySchedule[2]; - var s3 = M[offset + 3] ^ keySchedule[3]; + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; - // Key schedule row counter - var ksRow = 4; + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - // Rounds - for (var round = 1; round < nRounds; round++) { - // Shift rows, sub bytes, mix columns, add round key - var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; - var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; - var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; - var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - // Update state - s0 = t0; - s1 = t1; - s2 = t2; - s3 = t3; - } + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } - // Shift rows, sub bytes, add round key - var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; - var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; - var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; - var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - // Set output - M[offset] = t0; - M[offset + 1] = t1; - M[offset + 2] = t2; - M[offset + 3] = t3; - }, + this.length = a.length; - keySize: 256/32 - }); + return this._strip(); + }; - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); - */ - C.AES = BlockCipher._createHelper(AES); - }()); + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; - return CryptoJS.AES; + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; -})); -},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],151:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - /** - * Cipher core components. - */ - CryptoJS.lib.Cipher || (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var Base64 = C_enc.Base64; - var C_algo = C.algo; - var EvpKDF = C_algo.EvpKDF; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - /** - * Abstract base cipher template. - * - * @property {number} keySize This cipher's key size. Default: 4 (128 bits) - * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) - * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. - * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. - */ - var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - * - * @property {WordArray} iv The IV to use for this operation. - */ - cfg: Base.extend(), + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - /** - * Creates this cipher in encryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); - */ - createEncryptor: function (key, cfg) { - return this.create(this._ENC_XFORM_MODE, key, cfg); - }, + if (bitsLeft > 0) { + bytesNeeded--; + } - /** - * Creates this cipher in decryption mode. - * - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {Cipher} A cipher instance. - * - * @static - * - * @example - * - * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); - */ - createDecryptor: function (key, cfg) { - return this.create(this._DEC_XFORM_MODE, key, cfg); - }, + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - /** - * Initializes a newly created cipher. - * - * @param {number} xformMode Either the encryption or decryption transormation mode constant. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @example - * - * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); - */ - init: function (xformMode, key, cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - // Store transform mode and key - this._xformMode = xformMode; - this._key = key; + // And remove leading zeroes + return this._strip(); + }; - // Set initial values - this.reset(); - }, + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; - /** - * Resets this cipher to its initial state. - * - * @example - * - * cipher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - // Perform concrete-cipher logic - this._doReset(); - }, + var off = (bit / 26) | 0; + var wbit = bit % 26; - /** - * Adds data to be encrypted or decrypted. - * - * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. - * - * @return {WordArray} The data after processing. - * - * @example - * - * var encrypted = cipher.process('data'); - * var encrypted = cipher.process(wordArray); - */ - process: function (dataUpdate) { - // Append - this._append(dataUpdate); + this._expand(off + 1); - // Process available blocks - return this._process(); - }, + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } - /** - * Finalizes the encryption or decryption process. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. - * - * @return {WordArray} The data after final processing. - * - * @example - * - * var encrypted = cipher.finalize(); - * var encrypted = cipher.finalize('data'); - * var encrypted = cipher.finalize(wordArray); - */ - finalize: function (dataUpdate) { - // Final data update - if (dataUpdate) { - this._append(dataUpdate); - } + return this._strip(); + }; - // Perform concrete-cipher logic - var finalProcessedData = this._doFinalize(); + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; - return finalProcessedData; - }, + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); - keySize: 128/32, + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } - ivSize: 128/32, + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - _ENC_XFORM_MODE: 1, + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } - _DEC_XFORM_MODE: 2, + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * Creates shortcut functions to a cipher's object interface. - * - * @param {Cipher} cipher The cipher to create a helper for. - * - * @return {Object} An object with encrypt and decrypt shortcut functions. - * - * @static - * - * @example - * - * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); - */ - _createHelper: (function () { - function selectCipherStrategy(key) { - if (typeof key == 'string') { - return PasswordBasedCipher; - } else { - return SerializableCipher; - } - } + return this; + }; - return function (cipher) { - return { - encrypt: function (message, key, cfg) { - return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); - }, + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } - decrypt: function (ciphertext, key, cfg) { - return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); - } - }; - }; - }()) - }); + if (this.length > num.length) return this.clone().iadd(num); - /** - * Abstract base stream cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) - */ - var StreamCipher = C_lib.StreamCipher = Cipher.extend({ - _doFinalize: function () { - // Process partial blocks - var finalProcessedBlocks = this._process(!!'flush'); + return num.clone().iadd(this); + }; - return finalProcessedBlocks; - }, + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); - blockSize: 1 - }); + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } - /** - * Mode namespace. - */ - var C_mode = C.mode = {}; + // At this point both numbers are positive + var cmp = this.cmp(num); - /** - * Abstract base block cipher mode template. - */ - var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ - /** - * Creates this mode for encryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); - */ - createEncryptor: function (cipher, iv) { - return this.Encryptor.create(cipher, iv); - }, + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } - /** - * Creates this mode for decryption. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @static - * - * @example - * - * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); - */ - createDecryptor: function (cipher, iv) { - return this.Decryptor.create(cipher, iv); - }, + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * Initializes a newly created mode. - * - * @param {Cipher} cipher A block cipher instance. - * @param {Array} iv The IV words. - * - * @example - * - * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); - */ - init: function (cipher, iv) { - this._cipher = cipher; - this._iv = iv; - } - }); + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } - /** - * Cipher Block Chaining mode. - */ - var CBC = C_mode.CBC = (function () { - /** - * Abstract base CBC mode. - */ - var CBC = BlockCipherMode.extend(); + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * CBC encryptor. - */ - CBC.Encryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; + this.length = Math.max(this.length, i); - // XOR and encrypt - xorBlock.call(this, words, offset, blockSize); - cipher.encryptBlock(words, offset); + if (a !== this) { + this.negative = 1; + } - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); + return this._strip(); + }; - /** - * CBC decryptor. - */ - CBC.Decryptor = CBC.extend({ - /** - * Processes the data block at offset. - * - * @param {Array} words The data words to operate on. - * @param {number} offset The offset where the block starts. - * - * @example - * - * mode.processBlock(data.words, offset); - */ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; - - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); - - // Decrypt and XOR - cipher.decryptBlock(words, offset); - xorBlock.call(this, words, offset, blockSize); - - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); - - function xorBlock(words, offset, blockSize) { - // Shortcut - var iv = this._iv; - - // Choose mixing block - if (iv) { - var block = iv; - - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - var block = this._prevBlock; - } - - // XOR blocks - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= block[i]; - } - } - - return CBC; - }()); - - /** - * Padding namespace. - */ - var C_pad = C.pad = {}; - - /** - * PKCS #5/7 padding strategy. - */ - var Pkcs7 = C_pad.Pkcs7 = { - /** - * Pads data using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to pad. - * @param {number} blockSize The multiple that the data should be padded to. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.pad(wordArray, 4); - */ - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; - - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - - // Create padding word - var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; - - // Create padding - var paddingWords = []; - for (var i = 0; i < nPaddingBytes; i += 4) { - paddingWords.push(paddingWord); - } - var padding = WordArray.create(paddingWords, nPaddingBytes); - - // Add padding - data.concat(padding); - }, - - /** - * Unpads data that had been padded using the algorithm defined in PKCS #5/7. - * - * @param {WordArray} data The data to unpad. - * - * @static - * - * @example - * - * CryptoJS.pad.Pkcs7.unpad(wordArray); - */ - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; - - /** - * Abstract base block cipher template. - * - * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) - */ - var BlockCipher = C_lib.BlockCipher = Cipher.extend({ - /** - * Configuration options. - * - * @property {Mode} mode The block mode to use. Default: CBC - * @property {Padding} padding The padding strategy to use. Default: Pkcs7 - */ - cfg: Cipher.cfg.extend({ - mode: CBC, - padding: Pkcs7 - }), - - reset: function () { - // Reset cipher - Cipher.reset.call(this); - - // Shortcuts - var cfg = this.cfg; - var iv = cfg.iv; - var mode = cfg.mode; - - // Reset block mode - if (this._xformMode == this._ENC_XFORM_MODE) { - var modeCreator = mode.createEncryptor; - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - var modeCreator = mode.createDecryptor; - - // Keep at least one block in the buffer for unpadding - this._minBufferSize = 1; - } - this._mode = modeCreator.call(mode, this, iv && iv.words); - }, - - _doProcessBlock: function (words, offset) { - this._mode.processBlock(words, offset); - }, - - _doFinalize: function () { - // Shortcut - var padding = this.cfg.padding; - - // Finalize - if (this._xformMode == this._ENC_XFORM_MODE) { - // Pad data - padding.pad(this._data, this.blockSize); - - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { - // Process final blocks - var finalProcessedBlocks = this._process(!!'flush'); - - // Unpad data - padding.unpad(finalProcessedBlocks); - } - - return finalProcessedBlocks; - }, - - blockSize: 128/32 - }); - - /** - * A collection of cipher parameters. - * - * @property {WordArray} ciphertext The raw ciphertext. - * @property {WordArray} key The key to this ciphertext. - * @property {WordArray} iv The IV used in the ciphering operation. - * @property {WordArray} salt The salt used with a key derivation function. - * @property {Cipher} algorithm The cipher algorithm. - * @property {Mode} mode The block mode used in the ciphering operation. - * @property {Padding} padding The padding scheme used in the ciphering operation. - * @property {number} blockSize The block size of the cipher. - * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. - */ - var CipherParams = C_lib.CipherParams = Base.extend({ - /** - * Initializes a newly created cipher params object. - * - * @param {Object} cipherParams An object with any of the possible cipher parameters. - * - * @example - * - * var cipherParams = CryptoJS.lib.CipherParams.create({ - * ciphertext: ciphertextWordArray, - * key: keyWordArray, - * iv: ivWordArray, - * salt: saltWordArray, - * algorithm: CryptoJS.algo.AES, - * mode: CryptoJS.mode.CBC, - * padding: CryptoJS.pad.PKCS7, - * blockSize: 4, - * formatter: CryptoJS.format.OpenSSL - * }); - */ - init: function (cipherParams) { - this.mixIn(cipherParams); - }, - - /** - * Converts this cipher params object to a string. - * - * @param {Format} formatter (Optional) The formatting strategy to use. - * - * @return {string} The stringified cipher params. - * - * @throws Error If neither the formatter nor the default formatter is set. - * - * @example - * - * var string = cipherParams + ''; - * var string = cipherParams.toString(); - * var string = cipherParams.toString(CryptoJS.format.OpenSSL); - */ - toString: function (formatter) { - return (formatter || this.formatter).stringify(this); - } - }); - - /** - * Format namespace. - */ - var C_format = C.format = {}; - - /** - * OpenSSL formatting strategy. - */ - var OpenSSLFormatter = C_format.OpenSSL = { - /** - * Converts a cipher params object to an OpenSSL-compatible string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The OpenSSL-compatible string. - * - * @static - * - * @example - * - * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); - */ - stringify: function (cipherParams) { - // Shortcuts - var ciphertext = cipherParams.ciphertext; - var salt = cipherParams.salt; - - // Format - if (salt) { - var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); - } else { - var wordArray = ciphertext; - } - - return wordArray.toString(Base64); - }, - - /** - * Converts an OpenSSL-compatible string to a cipher params object. - * - * @param {string} openSSLStr The OpenSSL-compatible string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); - */ - parse: function (openSSLStr) { - // Parse base64 - var ciphertext = Base64.parse(openSSLStr); - - // Shortcut - var ciphertextWords = ciphertext.words; - - // Test for salt - if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { - // Extract salt - var salt = WordArray.create(ciphertextWords.slice(2, 4)); - - // Remove salt from ciphertext - ciphertextWords.splice(0, 4); - ciphertext.sigBytes -= 16; - } - - return CipherParams.create({ ciphertext: ciphertext, salt: salt }); - } - }; - - /** - * A cipher wrapper that returns ciphertext as a serializable cipher params object. - */ - var SerializableCipher = C_lib.SerializableCipher = Base.extend({ - /** - * Configuration options. - * - * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL - */ - cfg: Base.extend({ - format: OpenSSLFormatter - }), - - /** - * Encrypts a message. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); - * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); - - // Encrypt - var encryptor = cipher.createEncryptor(key, cfg); - var ciphertext = encryptor.finalize(message); + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; - // Shortcut - var cipherCfg = encryptor.cfg; + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; - // Create and return serializable cipher params - return CipherParams.create({ - ciphertext: ciphertext, - key: key, - iv: cipherCfg.iv, - algorithm: cipher, - mode: cipherCfg.mode, - padding: cipherCfg.padding, - blockSize: cipher.blockSize, - formatter: cfg.format - }); - }, + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; - /** - * Decrypts serialized ciphertext. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {WordArray} key The key. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, key, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } - // Decrypt - var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return out._strip(); + } - return plaintext; - }, + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; - /** - * Converts serialized ciphertext to CipherParams, - * else assumed CipherParams already and returns ciphertext unchanged. - * - * @param {CipherParams|string} ciphertext The ciphertext. - * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. - * - * @return {CipherParams} The unserialized ciphertext. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); - */ - _parse: function (ciphertext, format) { - if (typeof ciphertext == 'string') { - return format.parse(ciphertext, this); - } else { - return ciphertext; - } - } - }); + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; - /** - * Key derivation function namespace. - */ - var C_kdf = C.kdf = {}; + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } - /** - * OpenSSL key derivation function. - */ - var OpenSSLKdf = C_kdf.OpenSSL = { - /** - * Derives a key and IV from a password. - * - * @param {string} password The password to derive from. - * @param {number} keySize The size in words of the key to generate. - * @param {number} ivSize The size in words of the IV to generate. - * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. - * - * @return {CipherParams} A cipher params object with the key, IV, and salt. - * - * @static - * - * @example - * - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); - * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); - */ - execute: function (password, keySize, ivSize, salt) { - // Generate random salt - if (!salt) { - salt = WordArray.random(64/8); - } + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; - // Derive key and IV - var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; - // Separate key and IV - var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); - key.sigBytes = keySize * 4; + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; - // Return params - return CipherParams.create({ key: key, iv: iv, salt: salt }); - } - }; + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } - /** - * A serializable cipher wrapper that derives the key from a password, - * and returns ciphertext as a serializable cipher params object. - */ - var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ - /** - * Configuration options. - * - * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL - */ - cfg: SerializableCipher.cfg.extend({ - kdf: OpenSSLKdf - }), + return out._strip(); + } - /** - * Encrypts a message using a password. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {WordArray|string} message The message to encrypt. - * @param {string} password The password. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {CipherParams} A cipher params object. - * - * @static - * - * @example - * - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); - * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); - */ - encrypt: function (cipher, message, password, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } - // Derive key and other params - var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize); + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } - // Add IV to config - cfg.iv = derivedParams.iv; + return res; + }; - // Encrypt - var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion - // Mix in derived params - ciphertext.mixIn(derivedParams); + function FFTM (x, y) { + this.x = x; + this.y = y; + } - return ciphertext; - }, + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } - /** - * Decrypts serialized ciphertext using a password. - * - * @param {Cipher} cipher The cipher algorithm to use. - * @param {CipherParams|string} ciphertext The ciphertext to decrypt. - * @param {string} password The password. - * @param {Object} cfg (Optional) The configuration options to use for this operation. - * - * @return {WordArray} The plaintext. - * - * @static - * - * @example - * - * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); - * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); - */ - decrypt: function (cipher, ciphertext, password, cfg) { - // Apply config defaults - cfg = this.cfg.extend(cfg); + return t; + }; - // Convert string to CipherParams - ciphertext = this._parse(ciphertext, cfg.format); + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; - // Derive key and other params - var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt); + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } - // Add IV to config - cfg.iv = derivedParams.iv; + return rb; + }; - // Decrypt - var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; - return plaintext; - } - }); - }()); + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; -})); -},{"./core":152}],152:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(); - } - else if (typeof define === "function" && define.amd) { - // AMD - define([], factory); - } - else { - // Global (browser) - root.CryptoJS = factory(); - } -}(this, function () { + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); - /** - * CryptoJS core components. - */ - var CryptoJS = CryptoJS || (function (Math, undefined) { - /* - * Local polyfil of Object.create - */ - var create = Object.create || (function () { - function F() {}; + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; - return function (obj) { - var subtype; + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; - F.prototype = obj; + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; - subtype = new F(); + var rx = rtwdf_ * ro - itwdf_ * io; - F.prototype = null; + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; - return subtype; - }; - }()) + rtws[p + j] = re + ro; + itws[p + j] = ie + io; - /** - * CryptoJS namespace. - */ - var C = {}; + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; - /** - * Library namespace. - */ - var C_lib = C.lib = {}; + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; - /** - * Base object for prototypal inheritance. - */ - var Base = C_lib.Base = (function () { + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } - return { - /** - * Creates a new object that inherits from this object. - * - * @param {Object} overrides Properties to copy into the new object. - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var MyType = CryptoJS.lib.Base.extend({ - * field: 'value', - * - * method: function () { - * } - * }); - */ - extend: function (overrides) { - // Spawn - var subtype = create(this); + return 1 << i + 1 + odd; + }; - // Augment - if (overrides) { - subtype.mixIn(overrides); - } + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; - // Create default initializer - if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { - subtype.init = function () { - subtype.$super.init.apply(this, arguments); - }; - } + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; - // Initializer's prototype is the subtype object - subtype.init.prototype = subtype; + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; - // Reference supertype - subtype.$super = this; + t = iws[i]; - return subtype; - }, + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; - /** - * Extends this object and runs the init method. - * Arguments to create() will be passed to init(). - * - * @return {Object} The new object. - * - * @static - * - * @example - * - * var instance = MyType.create(); - */ - create: function () { - var instance = this.extend(); - instance.init.apply(instance, arguments); + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; - return instance; - }, + ws[i] = w & 0x3ffffff; - /** - * Initializes a newly created object. - * Override this method to add some logic when your objects are created. - * - * @example - * - * var MyType = CryptoJS.lib.Base.extend({ - * init: function () { - * // ... - * } - * }); - */ - init: function () { - }, + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } - /** - * Copies properties into this object. - * - * @param {Object} properties The properties to mix in. - * - * @example - * - * MyType.mixIn({ - * field: 'value' - * }); - */ - mixIn: function (properties) { - for (var propertyName in properties) { - if (properties.hasOwnProperty(propertyName)) { - this[propertyName] = properties[propertyName]; - } - } + return ws; + }; - // IE won't copy toString using the loop above - if (properties.hasOwnProperty('toString')) { - this.toString = properties.toString; - } - }, + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * var clone = instance.clone(); - */ - clone: function () { - return this.init.prototype.extend(this); - } - }; - }()); + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } - /** - * An array of 32-bit words. - * - * @property {Array} words The array of 32-bit words. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var WordArray = C_lib.WordArray = Base.extend({ - /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of 32-bit words. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. - * - * @example - * - * var wordArray = CryptoJS.lib.WordArray.create(); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); - * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); - */ - init: function (words, sigBytes) { - words = this.words = words || []; + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 4; - } - }, + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; - /** - * Converts this word array to a string. - * - * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex - * - * @return {string} The stringified word array. - * - * @example - * - * var string = wordArray + ''; - * var string = wordArray.toString(); - * var string = wordArray.toString(CryptoJS.enc.Utf8); - */ - toString: function (encoder) { - return (encoder || Hex).stringify(this); - }, + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } - /** - * Concatenates a word array to this word array. - * - * @param {WordArray} wordArray The word array to append. - * - * @return {WordArray} This word array. - * - * @example - * - * wordArray1.concat(wordArray2); - */ - concat: function (wordArray) { - // Shortcuts - var thisWords = this.words; - var thatWords = wordArray.words; - var thisSigBytes = this.sigBytes; - var thatSigBytes = wordArray.sigBytes; + return ph; + }; - // Clamp excess bits - this.clamp(); + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); - // Concat - if (thisSigBytes % 4) { - // Copy one byte at a time - for (var i = 0; i < thatSigBytes; i++) { - var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); - } - } else { - // Copy one word at a time - for (var i = 0; i < thatSigBytes; i += 4) { - thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; - } - } - this.sigBytes += thatSigBytes; + var rbt = this.makeRBT(N); - // Chainable - return this; - }, + var _ = this.stub(N); - /** - * Removes insignificant bits. - * - * @example - * - * wordArray.clamp(); - */ - clamp: function () { - // Shortcuts - var words = this.words; - var sigBytes = this.sigBytes; + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); - // Clamp - words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); - words.length = Math.ceil(sigBytes / 4); - }, + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); - /** - * Creates a copy of this word array. - * - * @return {WordArray} The clone. - * - * @example - * - * var clone = wordArray.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); - clone.words = this.words.slice(0); + var rmws = out.words; + rmws.length = N; - return clone; - }, + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); - /** - * Creates a word array filled with random bytes. - * - * @param {number} nBytes The number of random bytes to generate. - * - * @return {WordArray} The random word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.lib.WordArray.random(16); - */ - random: function (nBytes) { - var words = []; + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); - var r = (function (m_w) { - var m_w = m_w; - var m_z = 0x3ade68b1; - var mask = 0xffffffff; + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } - return function () { - m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; - m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; - var result = ((m_z << 0x10) + m_w) & mask; - result /= 0x100000000; - result += 0.5; - return result * (Math.random() > .5 ? 1 : -1); - } - }); + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); - for (var i = 0, rcache; i < nBytes; i += 4) { - var _r = r((rcache || Math.random()) * 0x100000000); + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out._strip(); + }; - rcache = _r() * 0x3ade67b7; - words.push((_r() * 0x100000000) | 0); - } + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; - return new WordArray.init(words, nBytes); - } - }); + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; - /** - * Encoder namespace. - */ - var C_enc = C.enc = {}; + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; - /** - * Hex encoding strategy. - */ - var Hex = C_enc.Hex = { - /** - * Converts a word array to a hex string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The hex string. - * - * @static - * - * @example - * - * var hexString = CryptoJS.enc.Hex.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; - // Convert - var hexChars = []; - for (var i = 0; i < sigBytes; i++) { - var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - hexChars.push((bite >>> 4).toString(16)); - hexChars.push((bite & 0x0f).toString(16)); - } + assert(typeof num === 'number'); + assert(num < 0x4000000); - return hexChars.join(''); - }, + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } - /** - * Converts a hex string to a word array. - * - * @param {string} hexStr The hex string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Hex.parse(hexString); - */ - parse: function (hexStr) { - // Shortcut - var hexStrLength = hexStr.length; + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } - // Convert - var words = []; - for (var i = 0; i < hexStrLength; i += 2) { - words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); - } + return isNegNum ? this.ineg() : this; + }; - return new WordArray.init(words, hexStrLength / 2); - } - }; + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; - /** - * Latin1 encoding strategy. - */ - var Latin1 = C_enc.Latin1 = { - /** - * Converts a word array to a Latin1 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Latin1 string. - * - * @static - * - * @example - * - * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; - // Convert - var latin1Chars = []; - for (var i = 0; i < sigBytes; i++) { - var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - latin1Chars.push(String.fromCharCode(bite)); - } + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; - return latin1Chars.join(''); - }, + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); - /** - * Converts a Latin1 string to a word array. - * - * @param {string} latin1Str The Latin1 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); - */ - parse: function (latin1Str) { - // Shortcut - var latin1StrLength = latin1Str.length; + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } - // Convert - var words = []; - for (var i = 0; i < latin1StrLength; i++) { - words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); - } + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; - return new WordArray.init(words, latin1StrLength); - } - }; + res = res.mul(q); + } + } - /** - * UTF-8 encoding strategy. - */ - var Utf8 = C_enc.Utf8 = { - /** - * Converts a word array to a UTF-8 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-8 string. - * - * @static - * - * @example - * - * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); - */ - stringify: function (wordArray) { - try { - return decodeURIComponent(escape(Latin1.stringify(wordArray))); - } catch (e) { - throw new Error('Malformed UTF-8 data'); - } - }, + return res; + }; - /** - * Converts a UTF-8 string to a word array. - * - * @param {string} utf8Str The UTF-8 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); - */ - parse: function (utf8Str) { - return Latin1.parse(unescape(encodeURIComponent(utf8Str))); - } - }; + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; - /** - * Abstract buffered block algorithm template. - * - * The property blockSize must be implemented in a concrete subtype. - * - * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 - */ - var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ - /** - * Resets this block algorithm's data buffer to its initial state. - * - * @example - * - * bufferedBlockAlgorithm.reset(); - */ - reset: function () { - // Initial values - this._data = new WordArray.init(); - this._nDataBytes = 0; - }, + if (r !== 0) { + var carry = 0; - /** - * Adds new data to this block algorithm's buffer. - * - * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. - * - * @example - * - * bufferedBlockAlgorithm._append('data'); - * bufferedBlockAlgorithm._append(wordArray); - */ - _append: function (data) { - // Convert string to WordArray, else assume WordArray already - if (typeof data == 'string') { - data = Utf8.parse(data); - } + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } - // Append - this._data.concat(data); - this._nDataBytes += data.sigBytes; - }, + if (carry) { + this.words[i] = carry; + this.length++; + } + } - /** - * Processes available data blocks. - * - * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. - * - * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. - * - * @return {WordArray} The processed data. - * - * @example - * - * var processedData = bufferedBlockAlgorithm._process(); - * var processedData = bufferedBlockAlgorithm._process(!!'flush'); - */ - _process: function (doFlush) { - // Shortcuts - var data = this._data; - var dataWords = data.words; - var dataSigBytes = data.sigBytes; - var blockSize = this.blockSize; - var blockSizeBytes = blockSize * 4; + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } - // Count blocks ready - var nBlocksReady = dataSigBytes / blockSizeBytes; - if (doFlush) { - // Round up to include partial blocks - nBlocksReady = Math.ceil(nBlocksReady); - } else { - // Round down to include only full blocks, - // less the number of blocks that must remain in the buffer - nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); - } + for (i = 0; i < s; i++) { + this.words[i] = 0; + } - // Count words ready - var nWordsReady = nBlocksReady * blockSize; + this.length += s; + } - // Count bytes ready - var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + return this._strip(); + }; - // Process blocks - if (nWordsReady) { - for (var offset = 0; offset < nWordsReady; offset += blockSize) { - // Perform concrete-algorithm logic - this._doProcessBlock(dataWords, offset); - } + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; - // Remove processed words - var processedWords = dataWords.splice(0, nWordsReady); - data.sigBytes -= nBytesReady; - } + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } - // Return processed words - return new WordArray.init(processedWords, nBytesReady); - }, + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; - /** - * Creates a copy of this object. - * - * @return {Object} The clone. - * - * @example - * - * var clone = bufferedBlockAlgorithm.clone(); - */ - clone: function () { - var clone = Base.clone.call(this); - clone._data = this._data.clone(); + h -= s; + h = Math.max(0, h); - return clone; - }, + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } - _minBufferSize: 0 - }); + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } - /** - * Abstract hasher template. - * - * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) - */ - var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ - /** - * Configuration options. - */ - cfg: Base.extend(), + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } - /** - * Initializes a newly created hasher. - * - * @param {Object} cfg (Optional) The configuration options to use for this hash computation. - * - * @example - * - * var hasher = CryptoJS.algo.SHA256.create(); - */ - init: function (cfg) { - // Apply config defaults - this.cfg = this.cfg.extend(cfg); + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } - // Set initial values - this.reset(); - }, + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } - /** - * Resets this hasher to its initial state. - * - * @example - * - * hasher.reset(); - */ - reset: function () { - // Reset data buffer - BufferedBlockAlgorithm.reset.call(this); + return this._strip(); + }; - // Perform concrete-hasher logic - this._doReset(); - }, + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; - /** - * Updates this hasher with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {Hasher} This hasher. - * - * @example - * - * hasher.update('message'); - * hasher.update(wordArray); - */ - update: function (messageUpdate) { - // Append - this._append(messageUpdate); + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; - // Update the hash - this._process(); + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; - // Chainable - return this; - }, + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; - /** - * Finalizes the hash computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The hash. - * - * @example - * - * var hash = hasher.finalize(); - * var hash = hasher.finalize('message'); - * var hash = hasher.finalize(wordArray); - */ - finalize: function (messageUpdate) { - // Final message update - if (messageUpdate) { - this._append(messageUpdate); - } + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; - // Perform concrete-hasher logic - var hash = this._doFinalize(); + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; - return hash; - }, + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; - blockSize: 512/32, + // Check bit and return + var w = this.words[s]; - /** - * Creates a shortcut function to a hasher's object interface. - * - * @param {Hasher} hasher The hasher to create a helper for. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); - */ - _createHelper: function (hasher) { - return function (message, cfg) { - return new hasher.init(cfg).finalize(message); - }; - }, + return !!(w & q); + }; - /** - * Creates a shortcut function to the HMAC's object interface. - * - * @param {Hasher} hasher The hasher to use in this HMAC helper. - * - * @return {Function} The shortcut function. - * - * @static - * - * @example - * - * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); - */ - _createHmacHelper: function (hasher) { - return function (message, key) { - return new C_algo.HMAC.init(hasher, key).finalize(message); - }; - } - }); + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; - /** - * Algorithm namespace. - */ - var C_algo = C.algo = {}; + assert(this.negative === 0, 'imaskn works only with positive numbers'); - return C; - }(Math)); + if (this.length <= s) { + return this; + } + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); - return CryptoJS; + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } -})); -},{}],153:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + return this._strip(); + }; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; - /** - * Base64 encoding strategy. - */ - var Base64 = C_enc.Base64 = { - /** - * Converts a word array to a Base64 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Base64 string. - * - * @static - * - * @example - * - * var base64String = CryptoJS.enc.Base64.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - var map = this._map; + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); - // Clamp excess bits - wordArray.clamp(); + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } - // Convert - var base64Chars = []; - for (var i = 0; i < sigBytes; i += 3) { - var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; - var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } - var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + // Add without checks + return this._iaddn(num); + }; - for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { - base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); - } - } + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; - // Add padding - var paddingChar = map.charAt(64); - if (paddingChar) { - while (base64Chars.length % 4) { - base64Chars.push(paddingChar); - } - } + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); - return base64Chars.join(''); - }, + return this; + }; - /** - * Converts a Base64 string to a word array. - * - * @param {string} base64Str The Base64 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Base64.parse(base64String); - */ - parse: function (base64Str) { - // Shortcuts - var base64StrLength = base64Str.length; - var map = this._map; - var reverseMap = this._reverseMap; + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); - if (!reverseMap) { - reverseMap = this._reverseMap = []; - for (var j = 0; j < map.length; j++) { - reverseMap[map.charCodeAt(j)] = j; - } - } + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } - // Ignore padding - var paddingChar = map.charAt(64); - if (paddingChar) { - var paddingIndex = base64Str.indexOf(paddingChar); - if (paddingIndex !== -1) { - base64StrLength = paddingIndex; - } - } + this.words[0] -= num; - // Convert - return parseLoop(base64Str, base64StrLength, reverseMap); + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } - }, + return this._strip(); + }; - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - }; + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; - function parseLoop(base64Str, base64StrLength, reverseMap) { - var words = []; - var nBytes = 0; - for (var i = 0; i < base64StrLength; i++) { - if (i % 4) { - var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); - var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); - words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); - nBytes++; - } - } - return WordArray.create(words, nBytes); - } - }()); + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + BN.prototype.iabs = function iabs () { + this.negative = 0; - return CryptoJS.enc.Base64; + return this; + }; -})); -},{"./core":152}],154:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; - /** - * UTF-16 BE encoding strategy. - */ - var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = { - /** - * Converts a word array to a UTF-16 BE string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-16 BE string. - * - * @static - * - * @example - * - * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; + this._expand(len); - // Convert - var utf16Chars = []; - for (var i = 0; i < sigBytes; i += 2) { - var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; - utf16Chars.push(String.fromCharCode(codePoint)); - } + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } - return utf16Chars.join(''); - }, + if (carry === 0) return this._strip(); - /** - * Converts a UTF-16 BE string to a word array. - * - * @param {string} utf16Str The UTF-16 BE string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); - */ - parse: function (utf16Str) { - // Shortcut - var utf16StrLength = utf16Str.length; + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; - // Convert - var words = []; - for (var i = 0; i < utf16StrLength; i++) { - words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); - } + return this._strip(); + }; - return WordArray.create(words, utf16StrLength * 2); - } - }; + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; - /** - * UTF-16 LE encoding strategy. - */ - C_enc.Utf16LE = { - /** - * Converts a word array to a UTF-16 LE string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The UTF-16 LE string. - * - * @static - * - * @example - * - * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; + var a = this.clone(); + var b = num; - // Convert - var utf16Chars = []; - for (var i = 0; i < sigBytes; i += 2) { - var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); - utf16Chars.push(String.fromCharCode(codePoint)); - } + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } - return utf16Chars.join(''); - }, + // Initialize quotient + var m = a.length - b.length; + var q; - /** - * Converts a UTF-16 LE string to a word array. - * - * @param {string} utf16Str The UTF-16 LE string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); - */ - parse: function (utf16Str) { - // Shortcut - var utf16StrLength = utf16Str.length; - - // Convert - var words = []; - for (var i = 0; i < utf16StrLength; i++) { - words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); - } - - return WordArray.create(words, utf16StrLength * 2); - } - }; + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } - function swapEndian(word) { - return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); - } - }()); + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); - return CryptoJS.enc.Utf16; + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); -})); -},{"./core":152}],155:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./sha1", "./hmac"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var MD5 = C_algo.MD5; + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } - /** - * This key derivation function is meant to conform with EVP_BytesToKey. - * www.openssl.org/docs/crypto/EVP_BytesToKey.html - */ - var EvpKDF = C_algo.EvpKDF = Base.extend({ - /** - * Configuration options. - * - * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) - * @property {Hasher} hasher The hash algorithm to use. Default: MD5 - * @property {number} iterations The number of iterations to perform. Default: 1 - */ - cfg: Base.extend({ - keySize: 128/32, - hasher: MD5, - iterations: 1 - }), + return { + div: q || null, + mod: a + }; + }; - /** - * Initializes a newly created key derivation function. - * - * @param {Object} cfg (Optional) The configuration options to use for the derivation. - * - * @example - * - * var kdf = CryptoJS.algo.EvpKDF.create(); - * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); - * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); - */ - init: function (cfg) { - this.cfg = this.cfg.extend(cfg); - }, + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); - /** - * Derives a key from a password. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * - * @return {WordArray} The derived key. - * - * @example - * - * var key = kdf.compute(password, salt); - */ - compute: function (password, salt) { - // Shortcut - var cfg = this.cfg; + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } - // Init hasher - var hasher = cfg.hasher.create(); + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); - // Initial values - var derivedKey = WordArray.create(); + if (mode !== 'mod') { + div = res.div.neg(); + } - // Shortcuts - var derivedKeyWords = derivedKey.words; - var keySize = cfg.keySize; - var iterations = cfg.iterations; + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } - // Generate key - while (derivedKeyWords.length < keySize) { - if (block) { - hasher.update(block); - } - var block = hasher.update(password).finalize(salt); - hasher.reset(); + return { + div: div, + mod: mod + }; + } - // Iterations - for (var i = 1; i < iterations; i++) { - block = hasher.finalize(block); - hasher.reset(); - } + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); - derivedKey.concat(block); - } - derivedKey.sigBytes = keySize * 4; + if (mode !== 'mod') { + div = res.div.neg(); + } - return derivedKey; - } - }); + return { + div: div, + mod: res.mod + }; + } - /** - * Derives a key from a password. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * @param {Object} cfg (Optional) The configuration options to use for this computation. - * - * @return {WordArray} The derived key. - * - * @static - * - * @example - * - * var key = CryptoJS.EvpKDF(password, salt); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); - * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); - */ - C.EvpKDF = function (password, salt, cfg) { - return EvpKDF.create(cfg).compute(password, salt); - }; - }()); + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } - return CryptoJS.EvpKDF; + return { + div: res.div, + mod: mod + }; + } -})); -},{"./core":152,"./hmac":157,"./sha1":176}],156:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Both numbers are positive at this point - (function (undefined) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var CipherParams = C_lib.CipherParams; - var C_enc = C.enc; - var Hex = C_enc.Hex; - var C_format = C.format; + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } - var HexFormatter = C_format.Hex = { - /** - * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. - * - * @param {CipherParams} cipherParams The cipher params object. - * - * @return {string} The hexadecimally encoded string. - * - * @static - * - * @example - * - * var hexString = CryptoJS.format.Hex.stringify(cipherParams); - */ - stringify: function (cipherParams) { - return cipherParams.ciphertext.toString(Hex); - }, + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } - /** - * Converts a hexadecimally encoded ciphertext string to a cipher params object. - * - * @param {string} input The hexadecimally encoded string. - * - * @return {CipherParams} The cipher params object. - * - * @static - * - * @example - * - * var cipherParams = CryptoJS.format.Hex.parse(hexString); - */ - parse: function (input) { - var ciphertext = Hex.parse(input); - return CipherParams.create({ ciphertext: ciphertext }); - } - }; - }()); + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } - return CryptoJS.format.Hex; + return this._wordDiv(num, mode); + }; -})); -},{"./cipher-core":151,"./core":152}],157:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var C_enc = C.enc; - var Utf8 = C_enc.Utf8; - var C_algo = C.algo; + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; - /** - * HMAC algorithm. - */ - var HMAC = C_algo.HMAC = Base.extend({ - /** - * Initializes a newly created HMAC. - * - * @param {Hasher} hasher The hash algorithm to use. - * @param {WordArray|string} key The secret key. - * - * @example - * - * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); - */ - init: function (hasher, key) { - // Init hasher - hasher = this._hasher = new hasher.init(); + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; - // Convert string to WordArray, else assume WordArray already - if (typeof key == 'string') { - key = Utf8.parse(key); - } + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); - // Shortcuts - var hasherBlockSize = hasher.blockSize; - var hasherBlockSizeBytes = hasherBlockSize * 4; + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; - // Allow arbitrary length keys - if (key.sigBytes > hasherBlockSizeBytes) { - key = hasher.finalize(key); - } + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - // Clamp excess bits - key.clamp(); + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); - // Clone key for inner and outer pads - var oKey = this._oKey = key.clone(); - var iKey = this._iKey = key.clone(); + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; - // Shortcuts - var oKeyWords = oKey.words; - var iKeyWords = iKey.words; + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; - // XOR keys with pad constants - for (var i = 0; i < hasherBlockSize; i++) { - oKeyWords[i] ^= 0x5c5c5c5c; - iKeyWords[i] ^= 0x36363636; - } - oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; - // Set initial values - this.reset(); - }, + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; - /** - * Resets this HMAC to its initial state. - * - * @example - * - * hmacHasher.reset(); - */ - reset: function () { - // Shortcut - var hasher = this._hasher; + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } - // Reset - hasher.reset(); - hasher.update(this._iKey); - }, + return isNegNum ? -acc : acc; + }; - /** - * Updates this HMAC with a message. - * - * @param {WordArray|string} messageUpdate The message to append. - * - * @return {HMAC} This HMAC instance. - * - * @example - * - * hmacHasher.update('message'); - * hmacHasher.update(wordArray); - */ - update: function (messageUpdate) { - this._hasher.update(messageUpdate); + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; - // Chainable - return this; - }, + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; - /** - * Finalizes the HMAC computation. - * Note that the finalize operation is effectively a destructive, read-once operation. - * - * @param {WordArray|string} messageUpdate (Optional) A final message update. - * - * @return {WordArray} The HMAC. - * - * @example - * - * var hmac = hmacHasher.finalize(); - * var hmac = hmacHasher.finalize('message'); - * var hmac = hmacHasher.finalize(wordArray); - */ - finalize: function (messageUpdate) { - // Shortcut - var hasher = this._hasher; + assert(num <= 0x3ffffff); - // Compute HMAC - var innerHash = hasher.finalize(messageUpdate); - hasher.reset(); - var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } - return hmac; - } - }); - }()); + this._strip(); + return isNegNum ? this.ineg() : this; + }; + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; -})); -},{"./core":152}],158:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory); - } - else { - // Global (browser) - root.CryptoJS = factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); - return CryptoJS; + var x = this; + var y = p.clone(); -})); -},{"./aes":150,"./cipher-core":151,"./core":152,"./enc-base64":153,"./enc-utf16":154,"./evpkdf":155,"./format-hex":156,"./hmac":157,"./lib-typedarrays":159,"./md5":160,"./mode-cfb":161,"./mode-ctr":163,"./mode-ctr-gladman":162,"./mode-ecb":164,"./mode-ofb":165,"./pad-ansix923":166,"./pad-iso10126":167,"./pad-iso97971":168,"./pad-nopadding":169,"./pad-zeropadding":170,"./pbkdf2":171,"./rabbit":173,"./rabbit-legacy":172,"./rc4":174,"./ripemd160":175,"./sha1":176,"./sha224":177,"./sha256":178,"./sha3":179,"./sha384":180,"./sha512":181,"./tripledes":182,"./x64-core":183}],159:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { - - (function () { - // Check if typed arrays are supported - if (typeof ArrayBuffer != 'function') { - return; - } + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); - // Reference original init - var superInit = WordArray.init; + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); - // Augment WordArray.init to handle typed arrays - var subInit = WordArray.init = function (typedArray) { - // Convert buffers to uint8 - if (typedArray instanceof ArrayBuffer) { - typedArray = new Uint8Array(typedArray); - } + var g = 0; - // Convert other array views to uint8 - if ( - typedArray instanceof Int8Array || - (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) || - typedArray instanceof Int16Array || - typedArray instanceof Uint16Array || - typedArray instanceof Int32Array || - typedArray instanceof Uint32Array || - typedArray instanceof Float32Array || - typedArray instanceof Float64Array - ) { - typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); - } + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } - // Handle Uint8Array - if (typedArray instanceof Uint8Array) { - // Shortcut - var typedArrayByteLength = typedArray.byteLength; + var yp = y.clone(); + var xp = x.clone(); - // Extract bytes - var words = []; - for (var i = 0; i < typedArrayByteLength; i++) { - words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); - } + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } - // Initialize this word array - superInit.call(this, words, typedArrayByteLength); - } else { - // Else call normal init - superInit.apply(this, arguments); - } - }; + A.iushrn(1); + B.iushrn(1); + } + } - subInit.prototype = WordArray; - }()); + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + C.iushrn(1); + D.iushrn(1); + } + } - return CryptoJS.lib.WordArray; + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } -})); -},{"./core":152}],160:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; - (function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); - // Constants table - var T = []; + var a = this; + var b = p.clone(); - // Compute constants - (function () { - for (var i = 0; i < 64; i++) { - T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; - } - }()); + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } - /** - * MD5 hash algorithm. - */ - var MD5 = C_algo.MD5 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0x67452301, 0xefcdab89, - 0x98badcfe, 0x10325476 - ]); - }, + var x1 = new BN(1); + var x2 = new BN(0); - _doProcessBlock: function (M, offset) { - // Swap endian - for (var i = 0; i < 16; i++) { - // Shortcuts - var offset_i = offset + i; - var M_offset_i = M[offset_i]; + var delta = b.clone(); - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ); - } + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } - // Shortcuts - var H = this._hash.words; + x1.iushrn(1); + } + } - var M_offset_0 = M[offset + 0]; - var M_offset_1 = M[offset + 1]; - var M_offset_2 = M[offset + 2]; - var M_offset_3 = M[offset + 3]; - var M_offset_4 = M[offset + 4]; - var M_offset_5 = M[offset + 5]; - var M_offset_6 = M[offset + 6]; - var M_offset_7 = M[offset + 7]; - var M_offset_8 = M[offset + 8]; - var M_offset_9 = M[offset + 9]; - var M_offset_10 = M[offset + 10]; - var M_offset_11 = M[offset + 11]; - var M_offset_12 = M[offset + 12]; - var M_offset_13 = M[offset + 13]; - var M_offset_14 = M[offset + 14]; - var M_offset_15 = M[offset + 15]; + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } - // Working varialbes - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; + x2.iushrn(1); + } + } - // Computation - a = FF(a, b, c, d, M_offset_0, 7, T[0]); - d = FF(d, a, b, c, M_offset_1, 12, T[1]); - c = FF(c, d, a, b, M_offset_2, 17, T[2]); - b = FF(b, c, d, a, M_offset_3, 22, T[3]); - a = FF(a, b, c, d, M_offset_4, 7, T[4]); - d = FF(d, a, b, c, M_offset_5, 12, T[5]); - c = FF(c, d, a, b, M_offset_6, 17, T[6]); - b = FF(b, c, d, a, M_offset_7, 22, T[7]); - a = FF(a, b, c, d, M_offset_8, 7, T[8]); - d = FF(d, a, b, c, M_offset_9, 12, T[9]); - c = FF(c, d, a, b, M_offset_10, 17, T[10]); - b = FF(b, c, d, a, M_offset_11, 22, T[11]); - a = FF(a, b, c, d, M_offset_12, 7, T[12]); - d = FF(d, a, b, c, M_offset_13, 12, T[13]); - c = FF(c, d, a, b, M_offset_14, 17, T[14]); - b = FF(b, c, d, a, M_offset_15, 22, T[15]); + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } - a = GG(a, b, c, d, M_offset_1, 5, T[16]); - d = GG(d, a, b, c, M_offset_6, 9, T[17]); - c = GG(c, d, a, b, M_offset_11, 14, T[18]); - b = GG(b, c, d, a, M_offset_0, 20, T[19]); - a = GG(a, b, c, d, M_offset_5, 5, T[20]); - d = GG(d, a, b, c, M_offset_10, 9, T[21]); - c = GG(c, d, a, b, M_offset_15, 14, T[22]); - b = GG(b, c, d, a, M_offset_4, 20, T[23]); - a = GG(a, b, c, d, M_offset_9, 5, T[24]); - d = GG(d, a, b, c, M_offset_14, 9, T[25]); - c = GG(c, d, a, b, M_offset_3, 14, T[26]); - b = GG(b, c, d, a, M_offset_8, 20, T[27]); - a = GG(a, b, c, d, M_offset_13, 5, T[28]); - d = GG(d, a, b, c, M_offset_2, 9, T[29]); - c = GG(c, d, a, b, M_offset_7, 14, T[30]); - b = GG(b, c, d, a, M_offset_12, 20, T[31]); + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } - a = HH(a, b, c, d, M_offset_5, 4, T[32]); - d = HH(d, a, b, c, M_offset_8, 11, T[33]); - c = HH(c, d, a, b, M_offset_11, 16, T[34]); - b = HH(b, c, d, a, M_offset_14, 23, T[35]); - a = HH(a, b, c, d, M_offset_1, 4, T[36]); - d = HH(d, a, b, c, M_offset_4, 11, T[37]); - c = HH(c, d, a, b, M_offset_7, 16, T[38]); - b = HH(b, c, d, a, M_offset_10, 23, T[39]); - a = HH(a, b, c, d, M_offset_13, 4, T[40]); - d = HH(d, a, b, c, M_offset_0, 11, T[41]); - c = HH(c, d, a, b, M_offset_3, 16, T[42]); - b = HH(b, c, d, a, M_offset_6, 23, T[43]); - a = HH(a, b, c, d, M_offset_9, 4, T[44]); - d = HH(d, a, b, c, M_offset_12, 11, T[45]); - c = HH(c, d, a, b, M_offset_15, 16, T[46]); - b = HH(b, c, d, a, M_offset_2, 23, T[47]); + if (res.cmpn(0) < 0) { + res.iadd(p); + } - a = II(a, b, c, d, M_offset_0, 6, T[48]); - d = II(d, a, b, c, M_offset_7, 10, T[49]); - c = II(c, d, a, b, M_offset_14, 15, T[50]); - b = II(b, c, d, a, M_offset_5, 21, T[51]); - a = II(a, b, c, d, M_offset_12, 6, T[52]); - d = II(d, a, b, c, M_offset_3, 10, T[53]); - c = II(c, d, a, b, M_offset_10, 15, T[54]); - b = II(b, c, d, a, M_offset_1, 21, T[55]); - a = II(a, b, c, d, M_offset_8, 6, T[56]); - d = II(d, a, b, c, M_offset_15, 10, T[57]); - c = II(c, d, a, b, M_offset_6, 15, T[58]); - b = II(b, c, d, a, M_offset_13, 21, T[59]); - a = II(a, b, c, d, M_offset_4, 6, T[60]); - d = II(d, a, b, c, M_offset_11, 10, T[61]); - c = II(c, d, a, b, M_offset_2, 15, T[62]); - b = II(b, c, d, a, M_offset_9, 21, T[63]); + return res; + }; - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - }, + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } - var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); - var nBitsTotalL = nBitsTotal; - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( - (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | - (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) - ); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | - (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) - ); + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } - data.sigBytes = (dataWords.length + 1) * 4; + a.isub(b); + } while (true); - // Hash final blocks - this._process(); + return b.iushln(shift); + }; - // Shortcuts - var hash = this._hash; - var H = hash.words; + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; - // Swap endian - for (var i = 0; i < 4; i++) { - // Shortcut - var H_i = H[i]; + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; - H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); - } + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; - // Return final computed hash - return hash; - }, + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; - return clone; - } - }); + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } - function FF(a, b, c, d, x, s, t) { - var n = a + ((b & c) | (~b & d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; - function GG(a, b, c, d, x, s, t) { - var n = a + ((b & d) | (c & ~d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; - function HH(a, b, c, d, x, s, t) { - var n = a + (b ^ c ^ d) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; - function II(a, b, c, d, x, s, t) { - var n = a + (c ^ (b | ~d)) + x + t; - return ((n << s) | (n >>> (32 - s))) + b; - } + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.MD5('message'); - * var hash = CryptoJS.MD5(wordArray); - */ - C.MD5 = Hasher._createHelper(MD5); + this._strip(); - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacMD5(message, key); - */ - C.HmacMD5 = Hasher._createHmacHelper(MD5); - }(Math)); + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + assert(num <= 0x3ffffff, 'Number is too big'); - return CryptoJS.MD5; + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; -})); -},{"./core":152}],161:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; - /** - * Cipher Feedback block mode. - */ - CryptoJS.mode.CFB = (function () { - var CFB = CryptoJS.lib.BlockCipherMode.extend(); + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; - CFB.Encryptor = CFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; - generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; - // Remember this block to use with next block - this._prevBlock = words.slice(offset, offset + blockSize); - } - }); + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; - CFB.Decryptor = CFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher; - var blockSize = cipher.blockSize; + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; - // Remember this block to use with next block - var thisBlock = words.slice(offset, offset + blockSize); + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; - generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; - // This block becomes the previous block - this._prevBlock = thisBlock; - } - }); + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; - function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { - // Shortcut - var iv = this._iv; + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; - // Generate keystream - if (iv) { - var keystream = iv.slice(0); + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; - // Remove IV for subsequent blocks - this._iv = undefined; - } else { - var keystream = this._prevBlock; - } - cipher.encryptBlock(keystream, 0); + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; - return CFB; - }()); + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; - return CryptoJS.mode.CFB; + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; -})); -},{"./cipher-core":151,"./core":152}],162:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; - /** @preserve - * Counter block mode compatible with Dr Brian Gladman fileenc.c - * derived from CryptoJS.mode.CTR - * Jan Hruby jhruby.web@gmail.com - */ - CryptoJS.mode.CTRGladman = (function () { - var CTRGladman = CryptoJS.lib.BlockCipherMode.extend(); + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; - function incWord(word) - { - if (((word >> 24) & 0xff) === 0xff) { //overflow - var b1 = (word >> 16)&0xff; - var b2 = (word >> 8)&0xff; - var b3 = word & 0xff; + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; - if (b1 === 0xff) // overflow b1 - { - b1 = 0; - if (b2 === 0xff) - { - b2 = 0; - if (b3 === 0xff) - { - b3 = 0; - } - else - { - ++b3; - } - } - else - { - ++b2; - } - } - else - { - ++b1; - } + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; - word = 0; - word += (b1 << 16); - word += (b2 << 8); - word += b3; - } - else - { - word += (0x01 << 24); - } - return word; - } + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; - function incCounter(counter) - { - if ((counter[0] = incWord(counter[0])) === 0) - { - // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 - counter[1] = incWord(counter[1]); - } - return counter; - } + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; - var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var counter = this._counter; + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; - // Generate keystream - if (iv) { - counter = this._counter = iv.slice(0); + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; - // Remove IV for subsequent blocks - this._iv = undefined; - } + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; - incCounter(counter); + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; - var keystream = counter.slice(0); - cipher.encryptBlock(keystream, 0); + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; - CTRGladman.Decryptor = Encryptor; + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; - return CTRGladman; - }()); + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; - return CryptoJS.mode.CTRGladman; + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; -})); -},{"./cipher-core":151,"./core":152}],163:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); - /** - * Counter block mode. - */ - CryptoJS.mode.CTR = (function () { - var CTR = CryptoJS.lib.BlockCipherMode.extend(); + this.tmp = this._tmp(); + } - var Encryptor = CTR.Encryptor = CTR.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var counter = this._counter; + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; - // Generate keystream - if (iv) { - counter = this._counter = iv.slice(0); + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; - // Remove IV for subsequent blocks - this._iv = undefined; - } - var keystream = counter.slice(0); - cipher.encryptBlock(keystream, 0); + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); - // Increment counter - counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0 + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); + return r; + }; - CTR.Decryptor = Encryptor; + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; - return CTR; - }()); + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); - return CryptoJS.mode.CTR; + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; -})); -},{"./cipher-core":151,"./core":152}],164:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; - /** - * Electronic Codebook block mode. - */ - CryptoJS.mode.ECB = (function () { - var ECB = CryptoJS.lib.BlockCipherMode.extend(); + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } - ECB.Encryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.encryptBlock(words, offset); - } - }); + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; - ECB.Decryptor = ECB.extend({ - processBlock: function (words, offset) { - this._cipher.decryptBlock(words, offset); - } - }); + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; - return ECB; - }()); + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } - return CryptoJS.mode.ECB; + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; -})); -},{"./cipher-core":151,"./core":152}],165:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); - /** - * Output Feedback block mode. - */ - CryptoJS.mode.OFB = (function () { - var OFB = CryptoJS.lib.BlockCipherMode.extend(); - - var Encryptor = OFB.Encryptor = OFB.extend({ - processBlock: function (words, offset) { - // Shortcuts - var cipher = this._cipher - var blockSize = cipher.blockSize; - var iv = this._iv; - var keystream = this._keystream; + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); - // Generate keystream - if (iv) { - keystream = this._keystream = iv.slice(0); + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); - // Remove IV for subsequent blocks - this._iv = undefined; - } - cipher.encryptBlock(keystream, 0); + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; - // Encrypt - for (var i = 0; i < blockSize; i++) { - words[offset + i] ^= keystream[i]; - } - } - }); + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; - OFB.Decryptor = Encryptor; + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; - return OFB; - }()); + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + return prime; + }; - return CryptoJS.mode.OFB; + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } -})); -},{"./cipher-core":151,"./core":152}],166:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; - /** - * ANSI X.923 padding strategy. - */ - CryptoJS.pad.AnsiX923 = { - pad: function (data, blockSize) { - // Shortcuts - var dataSigBytes = data.sigBytes; - var blockSizeBytes = blockSize * 4; + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; - // Count padding bytes - var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); - // Compute last byte position - var lastBytePos = dataSigBytes + nPaddingBytes - 1; + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; - // Pad - data.clamp(); - data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); - data.sigBytes += nPaddingBytes; - }, + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + return this.m.sub(a)._forceRed(this); + }; - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; - return CryptoJS.pad.Ansix923; + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); -})); -},{"./cipher-core":151,"./core":152}],167:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; - /** - * ISO 10126 padding strategy. - */ - CryptoJS.pad.Iso10126 = { - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); - // Count padding bytes - var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; - // Pad - data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)). - concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1)); - }, + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); - unpad: function (data) { - // Get number of padding bytes from last byte - var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; - // Remove padding - data.sigBytes -= nPaddingBytes; - } - }; + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; - return CryptoJS.pad.Iso10126; + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; -})); -},{"./cipher-core":151,"./core":152}],168:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; - /** - * ISO/IEC 9797-1 Padding Method 2. - */ - CryptoJS.pad.Iso97971 = { - pad: function (data, blockSize) { - // Add 0x80 byte - data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1)); + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; - // Zero pad the rest - CryptoJS.pad.ZeroPadding.pad(data, blockSize); - }, + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); - unpad: function (data) { - // Remove zero padding - CryptoJS.pad.ZeroPadding.unpad(data); + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); - // Remove one more byte -- the 0x80 byte - data.sigBytes--; - } - }; + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); - return CryptoJS.pad.Iso97971; + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); -})); -},{"./cipher-core":151,"./core":152}],169:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); - /** - * A noop padding strategy. - */ - CryptoJS.pad.NoPadding = { - pad: function () { - }, + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } - unpad: function () { - } - }; + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } - return CryptoJS.pad.NoPadding; + return r; + }; -})); -},{"./cipher-core":151,"./core":152}],170:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; - /** - * Zero padding strategy. - */ - CryptoJS.pad.ZeroPadding = { - pad: function (data, blockSize) { - // Shortcut - var blockSizeBytes = blockSize * 4; + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); - // Pad - data.clamp(); - data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); - }, + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } - unpad: function (data) { - // Shortcut - var dataWords = data.words; + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } - // Unpad - var i = data.sigBytes - 1; - while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { - i--; - } - data.sigBytes = i + 1; - } - }; + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } - return CryptoJS.pad.ZeroPadding; + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; -})); -},{"./cipher-core":151,"./core":152}],171:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./sha1", "./hmac"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Base = C_lib.Base; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var SHA1 = C_algo.SHA1; - var HMAC = C_algo.HMAC; + return res; + }; - /** - * Password-Based Key Derivation Function 2 algorithm. - */ - var PBKDF2 = C_algo.PBKDF2 = Base.extend({ - /** - * Configuration options. - * - * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) - * @property {Hasher} hasher The hasher to use. Default: SHA1 - * @property {number} iterations The number of iterations to perform. Default: 1 - */ - cfg: Base.extend({ - keySize: 128/32, - hasher: SHA1, - iterations: 1 - }), + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); - /** - * Initializes a newly created key derivation function. - * - * @param {Object} cfg (Optional) The configuration options to use for the derivation. - * - * @example - * - * var kdf = CryptoJS.algo.PBKDF2.create(); - * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); - * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); - */ - init: function (cfg) { - this.cfg = this.cfg.extend(cfg); - }, + return r === num ? r.clone() : r; + }; - /** - * Computes the Password-Based Key Derivation Function 2. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * - * @return {WordArray} The derived key. - * - * @example - * - * var key = kdf.compute(password, salt); - */ - compute: function (password, salt) { - // Shortcut - var cfg = this.cfg; + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; - // Init HMAC - var hmac = HMAC.create(cfg.hasher, password); + // + // Montgomery method engine + // - // Initial values - var derivedKey = WordArray.create(); - var blockIndex = WordArray.create([0x00000001]); + BN.mont = function mont (num) { + return new Mont(num); + }; - // Shortcuts - var derivedKeyWords = derivedKey.words; - var blockIndexWords = blockIndex.words; - var keySize = cfg.keySize; - var iterations = cfg.iterations; + function Mont (m) { + Red.call(this, m); - // Generate key - while (derivedKeyWords.length < keySize) { - var block = hmac.update(salt).finalize(blockIndex); - hmac.reset(); + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } - // Shortcuts - var blockWords = block.words; - var blockWordsLength = blockWords.length; + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); - // Iterations - var intermediate = block; - for (var i = 1; i < iterations; i++) { - intermediate = hmac.finalize(intermediate); - hmac.reset(); + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); - // Shortcut - var intermediateWords = intermediate.words; + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; - // XOR intermediate with block - for (var j = 0; j < blockWordsLength; j++) { - blockWords[j] ^= intermediateWords[j]; - } - } + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; - derivedKey.concat(block); - blockIndexWords[0]++; - } - derivedKey.sigBytes = keySize * 4; + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } - return derivedKey; - } - }); + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; - /** - * Computes the Password-Based Key Derivation Function 2. - * - * @param {WordArray|string} password The password. - * @param {WordArray|string} salt A salt. - * @param {Object} cfg (Optional) The configuration options to use for this computation. - * - * @return {WordArray} The derived key. - * - * @static - * - * @example - * - * var key = CryptoJS.PBKDF2(password, salt); - * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); - * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); - */ - C.PBKDF2 = function (password, salt, cfg) { - return PBKDF2.create(cfg).compute(password, salt); - }; - }()); + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + return res._forceRed(this); + }; - return CryptoJS.PBKDF2; + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); -})); -},{"./core":152,"./hmac":157,"./sha1":176}],172:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; + return res._forceRed(this); + }; - // Reusable objects - var S = []; - var C_ = []; - var G = []; + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})(typeof module === 'undefined' || module, this); - /** - * Rabbit stream cipher algorithm. - * - * This is a legacy version that neglected to convert the key to little-endian. - * This error doesn't affect the cipher's security, - * but it does affect its compatibility with other implementations. - */ - var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var K = this._key.words; - var iv = this.cfg.iv; +},{"buffer":219}],139:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js') +var randomBytes = require('randombytes') - // Generate initial state values - var X = this._X = [ - K[0], (K[3] << 16) | (K[2] >>> 16), - K[1], (K[0] << 16) | (K[3] >>> 16), - K[2], (K[1] << 16) | (K[0] >>> 16), - K[3], (K[2] << 16) | (K[1] >>> 16) - ]; +function blind (priv) { + var r = getr(priv) + var blinder = r.toRed(BN.mont(priv.modulus)).redPow(new BN(priv.publicExponent)).fromRed() + return { blinder: blinder, unblinder: r.invm(priv.modulus) } +} - // Generate initial counter values - var C = this._C = [ - (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), - (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), - (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), - (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) - ]; +function getr (priv) { + var len = priv.modulus.byteLength() + var r + do { + r = new BN(randomBytes(len)) + } while (r.cmp(priv.modulus) >= 0 || !r.umod(priv.prime1) || !r.umod(priv.prime2)) + return r +} - // Carry bit - this._b = 0; +function crt (msg, priv) { + var blinds = blind(priv) + var len = priv.modulus.byteLength() + var blinded = new BN(msg).mul(blinds.blinder).umod(priv.modulus) + var c1 = blinded.toRed(BN.mont(priv.prime1)) + var c2 = blinded.toRed(BN.mont(priv.prime2)) + var qinv = priv.coefficient + var p = priv.prime1 + var q = priv.prime2 + var m1 = c1.redPow(priv.exponent1).fromRed() + var m2 = c2.redPow(priv.exponent2).fromRed() + var h = m1.isub(m2).imul(qinv).umod(p).imul(q) + return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer, 'be', len) +} +crt.getr = getr + +module.exports = crt + +}).call(this)}).call(this,require("buffer").Buffer) +},{"bn.js":138,"buffer":110,"randombytes":303}],140:[function(require,module,exports){ +module.exports = require('./browser/algorithms.json') - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } +},{"./browser/algorithms.json":141}],141:[function(require,module,exports){ +module.exports={ + "sha224WithRSAEncryption": { + "sign": "rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "RSA-SHA224": { + "sign": "ecdsa/rsa", + "hash": "sha224", + "id": "302d300d06096086480165030402040500041c" + }, + "sha256WithRSAEncryption": { + "sign": "rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "RSA-SHA256": { + "sign": "ecdsa/rsa", + "hash": "sha256", + "id": "3031300d060960864801650304020105000420" + }, + "sha384WithRSAEncryption": { + "sign": "rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "RSA-SHA384": { + "sign": "ecdsa/rsa", + "hash": "sha384", + "id": "3041300d060960864801650304020205000430" + }, + "sha512WithRSAEncryption": { + "sign": "rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA512": { + "sign": "ecdsa/rsa", + "hash": "sha512", + "id": "3051300d060960864801650304020305000440" + }, + "RSA-SHA1": { + "sign": "rsa", + "hash": "sha1", + "id": "3021300906052b0e03021a05000414" + }, + "ecdsa-with-SHA1": { + "sign": "ecdsa", + "hash": "sha1", + "id": "" + }, + "sha256": { + "sign": "ecdsa", + "hash": "sha256", + "id": "" + }, + "sha224": { + "sign": "ecdsa", + "hash": "sha224", + "id": "" + }, + "sha384": { + "sign": "ecdsa", + "hash": "sha384", + "id": "" + }, + "sha512": { + "sign": "ecdsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-SHA1": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA": { + "sign": "dsa", + "hash": "sha1", + "id": "" + }, + "DSA-WITH-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-SHA224": { + "sign": "dsa", + "hash": "sha224", + "id": "" + }, + "DSA-WITH-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-SHA256": { + "sign": "dsa", + "hash": "sha256", + "id": "" + }, + "DSA-WITH-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-SHA384": { + "sign": "dsa", + "hash": "sha384", + "id": "" + }, + "DSA-WITH-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-SHA512": { + "sign": "dsa", + "hash": "sha512", + "id": "" + }, + "DSA-RIPEMD160": { + "sign": "dsa", + "hash": "rmd160", + "id": "" + }, + "ripemd160WithRSA": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "RSA-RIPEMD160": { + "sign": "rsa", + "hash": "rmd160", + "id": "3021300906052b2403020105000414" + }, + "md5WithRSAEncryption": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + }, + "RSA-MD5": { + "sign": "rsa", + "hash": "md5", + "id": "3020300c06082a864886f70d020505000410" + } +} - // Modify the counters - for (var i = 0; i < 8; i++) { - C[i] ^= X[(i + 4) & 7]; - } +},{}],142:[function(require,module,exports){ +module.exports={ + "1.3.132.0.10": "secp256k1", + "1.3.132.0.33": "p224", + "1.2.840.10045.3.1.1": "p192", + "1.2.840.10045.3.1.7": "p256", + "1.3.132.0.34": "p384", + "1.3.132.0.35": "p521" +} - // IV setup - if (iv) { - // Shortcuts - var IV = iv.words; - var IV_0 = IV[0]; - var IV_1 = IV[1]; +},{}],143:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var createHash = require('create-hash') +var stream = require('readable-stream') +var inherits = require('inherits') +var sign = require('./sign') +var verify = require('./verify') - // Generate four subvectors - var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); - var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); - var i1 = (i0 >>> 16) | (i2 & 0xffff0000); - var i3 = (i2 << 16) | (i0 & 0x0000ffff); +var algorithms = require('./algorithms.json') +Object.keys(algorithms).forEach(function (key) { + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') + algorithms[key.toLowerCase()] = algorithms[key] +}) - // Modify counter values - C[0] ^= i0; - C[1] ^= i1; - C[2] ^= i2; - C[3] ^= i3; - C[4] ^= i0; - C[5] ^= i1; - C[6] ^= i2; - C[7] ^= i3; +function Sign (algorithm) { + stream.Writable.call(this) - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - } - }, + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') - _doProcessBlock: function (M, offset) { - // Shortcut - var X = this._X; + this._hashType = data.hash + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Sign, stream.Writable) - // Iterate the system - nextState.call(this); +Sign.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} - // Generate four keystream words - S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); - S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); - S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); - S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); +Sign.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) - for (var i = 0; i < 4; i++) { - // Swap endian - S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | - (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + this._hash.update(data) + return this +} - // Encrypt - M[offset + i] ^= S[i]; - } - }, +Sign.prototype.sign = function signMethod (key, enc) { + this.end() + var hash = this._hash.digest() + var sig = sign(hash, key, this._hashType, this._signType, this._tag) - blockSize: 128/32, + return enc ? sig.toString(enc) : sig +} - ivSize: 64/32 - }); +function Verify (algorithm) { + stream.Writable.call(this) - function nextState() { - // Shortcuts - var X = this._X; - var C = this._C; + var data = algorithms[algorithm] + if (!data) throw new Error('Unknown message digest') - // Save old counter values - for (var i = 0; i < 8; i++) { - C_[i] = C[i]; - } + this._hash = createHash(data.hash) + this._tag = data.id + this._signType = data.sign +} +inherits(Verify, stream.Writable) - // Calculate new counter values - C[0] = (C[0] + 0x4d34d34d + this._b) | 0; - C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; - C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; - C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; - C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; - C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; - C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; - C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; - this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; +Verify.prototype._write = function _write (data, _, done) { + this._hash.update(data) + done() +} - // Calculate the g-values - for (var i = 0; i < 8; i++) { - var gx = X[i] + C[i]; +Verify.prototype.update = function update (data, enc) { + if (typeof data === 'string') data = Buffer.from(data, enc) - // Construct high and low argument for squaring - var ga = gx & 0xffff; - var gb = gx >>> 16; + this._hash.update(data) + return this +} - // Calculate high and low result of squaring - var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; - var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); +Verify.prototype.verify = function verifyMethod (key, sig, enc) { + if (typeof sig === 'string') sig = Buffer.from(sig, enc) - // High XOR low - G[i] = gh ^ gl; - } + this.end() + var hash = this._hash.digest() + return verify(sig, hash, key, this._signType, this._tag) +} - // Calculate new state values - X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; - X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; - X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; - X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; - X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; - X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; - X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; - X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; - } +function createSign (algorithm) { + return new Sign(algorithm) +} - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); - */ - C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy); - }()); +function createVerify (algorithm) { + return new Verify(algorithm) +} +module.exports = { + Sign: createSign, + Verify: createVerify, + createSign: createSign, + createVerify: createVerify +} - return CryptoJS.RabbitLegacy; - -})); -},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],173:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { +},{"./algorithms.json":141,"./sign":144,"./verify":145,"create-hash":118,"inherits":258,"readable-stream":319,"safe-buffer":321}],144:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var createHmac = require('create-hmac') +var crt = require('browserify-rsa') +var EC = require('elliptic').ec +var BN = require('bn.js') +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; +function sign (hash, key, hashType, signType, tag) { + var priv = parseKeys(key) + if (priv.curve) { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + return ecSign(hash, priv) + } else if (priv.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong private key type') + return dsaSign(hash, priv, hashType) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + } + hash = Buffer.concat([tag, hash]) + var len = priv.modulus.byteLength() + var pad = [0, 1] + while (hash.length + pad.length + 1 < len) pad.push(0xff) + pad.push(0x00) + var i = -1 + while (++i < hash.length) pad.push(hash[i]) - // Reusable objects - var S = []; - var C_ = []; - var G = []; + var out = crt(pad, priv) + return out +} - /** - * Rabbit stream cipher algorithm - */ - var Rabbit = C_algo.Rabbit = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var K = this._key.words; - var iv = this.cfg.iv; +function ecSign (hash, priv) { + var curveId = curves[priv.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) - // Swap endian - for (var i = 0; i < 4; i++) { - K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | - (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); - } + var curve = new EC(curveId) + var key = curve.keyFromPrivate(priv.privateKey) + var out = key.sign(hash) - // Generate initial state values - var X = this._X = [ - K[0], (K[3] << 16) | (K[2] >>> 16), - K[1], (K[0] << 16) | (K[3] >>> 16), - K[2], (K[1] << 16) | (K[0] >>> 16), - K[3], (K[2] << 16) | (K[1] >>> 16) - ]; + return Buffer.from(out.toDER()) +} - // Generate initial counter values - var C = this._C = [ - (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), - (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), - (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), - (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) - ]; +function dsaSign (hash, priv, algo) { + var x = priv.params.priv_key + var p = priv.params.p + var q = priv.params.q + var g = priv.params.g + var r = new BN(0) + var k + var H = bits2int(hash, q).mod(q) + var s = false + var kv = getKey(x, q, hash, algo) + while (s === false) { + k = makeKey(q, kv, algo) + r = makeR(g, k, p, q) + s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + if (s.cmpn(0) === 0) { + s = false + r = new BN(0) + } + } + return toDER(r, s) +} - // Carry bit - this._b = 0; +function toDER (r, s) { + r = r.toArray() + s = s.toArray() - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } + // Pad values + if (r[0] & 0x80) r = [0].concat(r) + if (s[0] & 0x80) s = [0].concat(s) - // Modify the counters - for (var i = 0; i < 8; i++) { - C[i] ^= X[(i + 4) & 7]; - } + var total = r.length + s.length + 4 + var res = [0x30, total, 0x02, r.length] + res = res.concat(r, [0x02, s.length], s) + return Buffer.from(res) +} - // IV setup - if (iv) { - // Shortcuts - var IV = iv.words; - var IV_0 = IV[0]; - var IV_1 = IV[1]; +function getKey (x, q, hash, algo) { + x = Buffer.from(x.toArray()) + if (x.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - x.length) + x = Buffer.concat([zeros, x]) + } + var hlen = hash.length + var hbits = bits2octets(hash, q) + var v = Buffer.alloc(hlen) + v.fill(1) + var k = Buffer.alloc(hlen) + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() + v = createHmac(algo, k).update(v).digest() + return { k: k, v: v } +} - // Generate four subvectors - var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); - var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); - var i1 = (i0 >>> 16) | (i2 & 0xffff0000); - var i3 = (i2 << 16) | (i0 & 0x0000ffff); +function bits2int (obits, q) { + var bits = new BN(obits) + var shift = (obits.length << 3) - q.bitLength() + if (shift > 0) bits.ishrn(shift) + return bits +} - // Modify counter values - C[0] ^= i0; - C[1] ^= i1; - C[2] ^= i2; - C[3] ^= i3; - C[4] ^= i0; - C[5] ^= i1; - C[6] ^= i2; - C[7] ^= i3; +function bits2octets (bits, q) { + bits = bits2int(bits, q) + bits = bits.mod(q) + var out = Buffer.from(bits.toArray()) + if (out.length < q.byteLength()) { + var zeros = Buffer.alloc(q.byteLength() - out.length) + out = Buffer.concat([zeros, out]) + } + return out +} - // Iterate the system four times - for (var i = 0; i < 4; i++) { - nextState.call(this); - } - } - }, +function makeKey (q, kv, algo) { + var t + var k - _doProcessBlock: function (M, offset) { - // Shortcut - var X = this._X; + do { + t = Buffer.alloc(0) - // Iterate the system - nextState.call(this); + while (t.length * 8 < q.bitLength()) { + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + t = Buffer.concat([t, kv.v]) + } - // Generate four keystream words - S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); - S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); - S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); - S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + k = bits2int(t, q) + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() + kv.v = createHmac(algo, kv.k).update(kv.v).digest() + } while (k.cmp(q) !== -1) - for (var i = 0; i < 4; i++) { - // Swap endian - S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | - (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + return k +} - // Encrypt - M[offset + i] ^= S[i]; - } - }, +function makeR (g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +} - blockSize: 128/32, +module.exports = sign +module.exports.getKey = getKey +module.exports.makeKey = makeKey - ivSize: 64/32 - }); +},{"./curves.json":142,"bn.js":138,"browserify-rsa":139,"create-hmac":120,"elliptic":202,"parse-asn1":150,"safe-buffer":321}],145:[function(require,module,exports){ +// much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js +var Buffer = require('safe-buffer').Buffer +var BN = require('bn.js') +var EC = require('elliptic').ec +var parseKeys = require('parse-asn1') +var curves = require('./curves.json') - function nextState() { - // Shortcuts - var X = this._X; - var C = this._C; +function verify (sig, hash, key, signType, tag) { + var pub = parseKeys(key) + if (pub.type === 'ec') { + // rsa keys can be interpreted as ecdsa ones in openssl + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + return ecVerify(sig, hash, pub) + } else if (pub.type === 'dsa') { + if (signType !== 'dsa') throw new Error('wrong public key type') + return dsaVerify(sig, hash, pub) + } else { + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + } + hash = Buffer.concat([tag, hash]) + var len = pub.modulus.byteLength() + var pad = [1] + var padNum = 0 + while (hash.length + pad.length + 2 < len) { + pad.push(0xff) + padNum++ + } + pad.push(0x00) + var i = -1 + while (++i < hash.length) { + pad.push(hash[i]) + } + pad = Buffer.from(pad) + var red = BN.mont(pub.modulus) + sig = new BN(sig).toRed(red) - // Save old counter values - for (var i = 0; i < 8; i++) { - C_[i] = C[i]; - } + sig = sig.redPow(new BN(pub.publicExponent)) + sig = Buffer.from(sig.fromRed().toArray()) + var out = padNum < 8 ? 1 : 0 + len = Math.min(sig.length, pad.length) + if (sig.length !== pad.length) out = 1 - // Calculate new counter values - C[0] = (C[0] + 0x4d34d34d + this._b) | 0; - C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; - C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; - C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; - C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; - C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; - C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; - C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; - this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + i = -1 + while (++i < len) out |= sig[i] ^ pad[i] + return out === 0 +} - // Calculate the g-values - for (var i = 0; i < 8; i++) { - var gx = X[i] + C[i]; +function ecVerify (sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')] + if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) - // Construct high and low argument for squaring - var ga = gx & 0xffff; - var gb = gx >>> 16; + var curve = new EC(curveId) + var pubkey = pub.data.subjectPrivateKey.data - // Calculate high and low result of squaring - var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; - var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + return curve.verify(hash, sig, pubkey) +} - // High XOR low - G[i] = gh ^ gl; - } +function dsaVerify (sig, hash, pub) { + var p = pub.data.p + var q = pub.data.q + var g = pub.data.g + var y = pub.data.pub_key + var unpacked = parseKeys.signature.decode(sig, 'der') + var s = unpacked.s + var r = unpacked.r + checkValue(s, q) + checkValue(r, q) + var montp = BN.mont(p) + var w = s.invm(q) + var v = g.toRed(montp) + .redPow(new BN(hash).mul(w).mod(q)) + .fromRed() + .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) + .mod(p) + .mod(q) + return v.cmp(r) === 0 +} - // Calculate new state values - X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; - X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; - X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; - X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; - X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; - X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; - X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; - X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; - } +function checkValue (b, q) { + if (b.cmpn(0) <= 0) throw new Error('invalid sig') + if (b.cmp(q) >= q) throw new Error('invalid sig') +} - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); - * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); - */ - C.Rabbit = StreamCipher._createHelper(Rabbit); - }()); +module.exports = verify +},{"./curves.json":142,"bn.js":138,"elliptic":202,"parse-asn1":150,"safe-buffer":321}],146:[function(require,module,exports){ +module.exports={"2.16.840.1.101.3.4.1.1": "aes-128-ecb", +"2.16.840.1.101.3.4.1.2": "aes-128-cbc", +"2.16.840.1.101.3.4.1.3": "aes-128-ofb", +"2.16.840.1.101.3.4.1.4": "aes-128-cfb", +"2.16.840.1.101.3.4.1.21": "aes-192-ecb", +"2.16.840.1.101.3.4.1.22": "aes-192-cbc", +"2.16.840.1.101.3.4.1.23": "aes-192-ofb", +"2.16.840.1.101.3.4.1.24": "aes-192-cfb", +"2.16.840.1.101.3.4.1.41": "aes-256-ecb", +"2.16.840.1.101.3.4.1.42": "aes-256-cbc", +"2.16.840.1.101.3.4.1.43": "aes-256-ofb", +"2.16.840.1.101.3.4.1.44": "aes-256-cfb" +} +},{}],147:[function(require,module,exports){ +// from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js +// Fedor, you are amazing. +'use strict' - return CryptoJS.Rabbit; +var asn1 = require('asn1.js') -})); -},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],174:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { +exports.certificate = require('./certificate') - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var StreamCipher = C_lib.StreamCipher; - var C_algo = C.algo; +var RSAPrivateKey = asn1.define('RSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('modulus').int(), + this.key('publicExponent').int(), + this.key('privateExponent').int(), + this.key('prime1').int(), + this.key('prime2').int(), + this.key('exponent1').int(), + this.key('exponent2').int(), + this.key('coefficient').int() + ) +}) +exports.RSAPrivateKey = RSAPrivateKey - /** - * RC4 stream cipher algorithm. - */ - var RC4 = C_algo.RC4 = StreamCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - var keySigBytes = key.sigBytes; +var RSAPublicKey = asn1.define('RSAPublicKey', function () { + this.seq().obj( + this.key('modulus').int(), + this.key('publicExponent').int() + ) +}) +exports.RSAPublicKey = RSAPublicKey - // Init sbox - var S = this._S = []; - for (var i = 0; i < 256; i++) { - S[i] = i; - } +var PublicKey = asn1.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) +exports.PublicKey = PublicKey - // Key setup - for (var i = 0, j = 0; i < 256; i++) { - var keyByteIndex = i % keySigBytes; - var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; +var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('none').null_().optional(), + this.key('curve').objid().optional(), + this.key('params').seq().obj( + this.key('p').int(), + this.key('q').int(), + this.key('g').int() + ).optional() + ) +}) - j = (j + S[i] + keyByte) % 256; +var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function () { + this.seq().obj( + this.key('version').int(), + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPrivateKey').octstr() + ) +}) +exports.PrivateKey = PrivateKeyInfo +var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function () { + this.seq().obj( + this.key('algorithm').seq().obj( + this.key('id').objid(), + this.key('decrypt').seq().obj( + this.key('kde').seq().obj( + this.key('id').objid(), + this.key('kdeparams').seq().obj( + this.key('salt').octstr(), + this.key('iters').int() + ) + ), + this.key('cipher').seq().obj( + this.key('algo').objid(), + this.key('iv').octstr() + ) + ) + ), + this.key('subjectPrivateKey').octstr() + ) +}) - // Swap - var t = S[i]; - S[i] = S[j]; - S[j] = t; - } +exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo - // Counters - this._i = this._j = 0; - }, +var DSAPrivateKey = asn1.define('DSAPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('p').int(), + this.key('q').int(), + this.key('g').int(), + this.key('pub_key').int(), + this.key('priv_key').int() + ) +}) +exports.DSAPrivateKey = DSAPrivateKey - _doProcessBlock: function (M, offset) { - M[offset] ^= generateKeystreamWord.call(this); - }, +exports.DSAparam = asn1.define('DSAparam', function () { + this.int() +}) - keySize: 256/32, +var ECPrivateKey = asn1.define('ECPrivateKey', function () { + this.seq().obj( + this.key('version').int(), + this.key('privateKey').octstr(), + this.key('parameters').optional().explicit(0).use(ECParameters), + this.key('publicKey').optional().explicit(1).bitstr() + ) +}) +exports.ECPrivateKey = ECPrivateKey - ivSize: 0 - }); +var ECParameters = asn1.define('ECParameters', function () { + this.choice({ + namedCurve: this.objid() + }) +}) - function generateKeystreamWord() { - // Shortcuts - var S = this._S; - var i = this._i; - var j = this._j; +exports.signature = asn1.define('signature', function () { + this.seq().obj( + this.key('r').int(), + this.key('s').int() + ) +}) - // Generate keystream word - var keystreamWord = 0; - for (var n = 0; n < 4; n++) { - i = (i + 1) % 256; - j = (j + S[i]) % 256; +},{"./certificate":148,"asn1.js":123}],148:[function(require,module,exports){ +// from https://github.com/Rantanen/node-dtls/blob/25a7dc861bda38cfeac93a723500eea4f0ac2e86/Certificate.js +// thanks to @Rantanen - // Swap - var t = S[i]; - S[i] = S[j]; - S[j] = t; +'use strict' - keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); - } +var asn = require('asn1.js') - // Update counters - this._i = i; - this._j = j; +var Time = asn.define('Time', function () { + this.choice({ + utcTime: this.utctime(), + generalTime: this.gentime() + }) +}) - return keystreamWord; - } +var AttributeTypeValue = asn.define('AttributeTypeValue', function () { + this.seq().obj( + this.key('type').objid(), + this.key('value').any() + ) +}) - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); - */ - C.RC4 = StreamCipher._createHelper(RC4); +var AlgorithmIdentifier = asn.define('AlgorithmIdentifier', function () { + this.seq().obj( + this.key('algorithm').objid(), + this.key('parameters').optional(), + this.key('curve').objid().optional() + ) +}) - /** - * Modified RC4 stream cipher algorithm. - */ - var RC4Drop = C_algo.RC4Drop = RC4.extend({ - /** - * Configuration options. - * - * @property {number} drop The number of keystream words to drop. Default 192 - */ - cfg: RC4.cfg.extend({ - drop: 192 - }), +var SubjectPublicKeyInfo = asn.define('SubjectPublicKeyInfo', function () { + this.seq().obj( + this.key('algorithm').use(AlgorithmIdentifier), + this.key('subjectPublicKey').bitstr() + ) +}) - _doReset: function () { - RC4._doReset.call(this); +var RelativeDistinguishedName = asn.define('RelativeDistinguishedName', function () { + this.setof(AttributeTypeValue) +}) - // Drop - for (var i = this.cfg.drop; i > 0; i--) { - generateKeystreamWord.call(this); - } - } - }); +var RDNSequence = asn.define('RDNSequence', function () { + this.seqof(RelativeDistinguishedName) +}) - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); - * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); - */ - C.RC4Drop = StreamCipher._createHelper(RC4Drop); - }()); +var Name = asn.define('Name', function () { + this.choice({ + rdnSequence: this.use(RDNSequence) + }) +}) +var Validity = asn.define('Validity', function () { + this.seq().obj( + this.key('notBefore').use(Time), + this.key('notAfter').use(Time) + ) +}) - return CryptoJS.RC4; +var Extension = asn.define('Extension', function () { + this.seq().obj( + this.key('extnID').objid(), + this.key('critical').bool().def(false), + this.key('extnValue').octstr() + ) +}) -})); -},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],175:[function(require,module,exports){ -;(function (root, factory) { +var TBSCertificate = asn.define('TBSCertificate', function () { + this.seq().obj( + this.key('version').explicit(0).int().optional(), + this.key('serialNumber').int(), + this.key('signature').use(AlgorithmIdentifier), + this.key('issuer').use(Name), + this.key('validity').use(Validity), + this.key('subject').use(Name), + this.key('subjectPublicKeyInfo').use(SubjectPublicKeyInfo), + this.key('issuerUniqueID').implicit(1).bitstr().optional(), + this.key('subjectUniqueID').implicit(2).bitstr().optional(), + this.key('extensions').explicit(3).seqof(Extension).optional() + ) +}) + +var X509Certificate = asn.define('X509Certificate', function () { + this.seq().obj( + this.key('tbsCertificate').use(TBSCertificate), + this.key('signatureAlgorithm').use(AlgorithmIdentifier), + this.key('signatureValue').bitstr() + ) +}) + +module.exports = X509Certificate + +},{"asn1.js":123}],149:[function(require,module,exports){ +// adapted from https://github.com/apatil/pemstrip +var findProc = /Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m +var startRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m +var fullRegex = /^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m +var evp = require('evp_bytestokey') +var ciphers = require('browserify-aes') +var Buffer = require('safe-buffer').Buffer +module.exports = function (okey, password) { + var key = okey.toString() + var match = key.match(findProc) + var decrypted + if (!match) { + var match2 = key.match(fullRegex) + decrypted = Buffer.from(match2[2].replace(/[\r\n]/g, ''), 'base64') + } else { + var suite = 'aes' + match[1] + var iv = Buffer.from(match[2], 'hex') + var cipherText = Buffer.from(match[3].replace(/[\r\n]/g, ''), 'base64') + var cipherKey = evp(password, iv.slice(0, 8), parseInt(match[1], 10)).key + var out = [] + var cipher = ciphers.createDecipheriv(suite, cipherKey, iv) + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + decrypted = Buffer.concat(out) + } + var tag = key.match(startRegex)[1] + return { + tag: tag, + data: decrypted + } +} + +},{"browserify-aes":86,"evp_bytestokey":218,"safe-buffer":321}],150:[function(require,module,exports){ +var asn1 = require('./asn1') +var aesid = require('./aesid.json') +var fixProc = require('./fixProc') +var ciphers = require('browserify-aes') +var compat = require('pbkdf2') +var Buffer = require('safe-buffer').Buffer +module.exports = parseKeys + +function parseKeys (buffer) { + var password + if (typeof buffer === 'object' && !Buffer.isBuffer(buffer)) { + password = buffer.passphrase + buffer = buffer.key + } + if (typeof buffer === 'string') { + buffer = Buffer.from(buffer) + } + + var stripped = fixProc(buffer, password) + + var type = stripped.tag + var data = stripped.data + var subtype, ndata + switch (type) { + case 'CERTIFICATE': + ndata = asn1.certificate.decode(data, 'der').tbsCertificate.subjectPublicKeyInfo + // falls through + case 'PUBLIC KEY': + if (!ndata) { + ndata = asn1.PublicKey.decode(data, 'der') + } + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPublicKey.decode(ndata.subjectPublicKey.data, 'der') + case '1.2.840.10045.2.1': + ndata.subjectPrivateKey = ndata.subjectPublicKey + return { + type: 'ec', + data: ndata + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.pub_key = asn1.DSAparam.decode(ndata.subjectPublicKey.data, 'der') + return { + type: 'dsa', + data: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'ENCRYPTED PRIVATE KEY': + data = asn1.EncryptedPrivateKey.decode(data, 'der') + data = decrypt(data, password) + // falls through + case 'PRIVATE KEY': + ndata = asn1.PrivateKey.decode(data, 'der') + subtype = ndata.algorithm.algorithm.join('.') + switch (subtype) { + case '1.2.840.113549.1.1.1': + return asn1.RSAPrivateKey.decode(ndata.subjectPrivateKey, 'der') + case '1.2.840.10045.2.1': + return { + curve: ndata.algorithm.curve, + privateKey: asn1.ECPrivateKey.decode(ndata.subjectPrivateKey, 'der').privateKey + } + case '1.2.840.10040.4.1': + ndata.algorithm.params.priv_key = asn1.DSAparam.decode(ndata.subjectPrivateKey, 'der') + return { + type: 'dsa', + params: ndata.algorithm.params + } + default: throw new Error('unknown key id ' + subtype) + } + // throw new Error('unknown key type ' + type) + case 'RSA PUBLIC KEY': + return asn1.RSAPublicKey.decode(data, 'der') + case 'RSA PRIVATE KEY': + return asn1.RSAPrivateKey.decode(data, 'der') + case 'DSA PRIVATE KEY': + return { + type: 'dsa', + params: asn1.DSAPrivateKey.decode(data, 'der') + } + case 'EC PRIVATE KEY': + data = asn1.ECPrivateKey.decode(data, 'der') + return { + curve: data.parameters.value, + privateKey: data.privateKey + } + default: throw new Error('unknown key type ' + type) + } +} +parseKeys.signature = asn1.signature +function decrypt (data, password) { + var salt = data.algorithm.decrypt.kde.kdeparams.salt + var iters = parseInt(data.algorithm.decrypt.kde.kdeparams.iters.toString(), 10) + var algo = aesid[data.algorithm.decrypt.cipher.algo.join('.')] + var iv = data.algorithm.decrypt.cipher.iv + var cipherText = data.subjectPrivateKey + var keylen = parseInt(algo.split('-')[1], 10) / 8 + var key = compat.pbkdf2Sync(password, salt, iters, keylen, 'sha1') + var cipher = ciphers.createDecipheriv(algo, key, iv) + var out = [] + out.push(cipher.update(cipherText)) + out.push(cipher.final()) + return Buffer.concat(out) +} + +},{"./aesid.json":146,"./asn1":147,"./fixProc":149,"browserify-aes":86,"pbkdf2":269,"safe-buffer":321}],151:[function(require,module,exports){ +;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS - module.exports = exports = factory(require("./core")); + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); } else if (typeof define === "function" && define.amd) { // AMD - define(["./core"], factory); + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); } else { // Global (browser) @@ -32975,267 +32661,232 @@ function decrypt (data, password) { } }(this, function (CryptoJS) { - /** @preserve - (c) 2012 by Cédric Mesnil. All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - (function (Math) { + (function () { // Shortcuts var C = CryptoJS; var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; + var BlockCipher = C_lib.BlockCipher; var C_algo = C.algo; - // Constants table - var _zl = WordArray.create([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); - var _zr = WordArray.create([ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); - var _sl = WordArray.create([ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]); - var _sr = WordArray.create([ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]); + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; - var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); - var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); + // Compute lookup tables + (function () { + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } - /** - * RIPEMD160 hash algorithm. - */ - var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ - _doReset: function () { - this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); - }, + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; - _doProcessBlock: function (M, offset) { + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; - // Swap endian - for (var i = 0; i < 16; i++) { - // Shortcuts - var offset_i = offset + i; - var M_offset_i = M[offset_i]; + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; - // Swap - M[offset_i] = ( - (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | - (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) - ); - } - // Shortcut - var H = this._hash.words; - var hl = _hl.words; - var hr = _hr.words; - var zl = _zl.words; - var zr = _zr.words; - var sl = _sl.words; - var sr = _sr.words; + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; - // Working variables - var al, bl, cl, dl, el; - var ar, br, cr, dr, er; + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); - ar = al = H[0]; - br = bl = H[1]; - cr = cl = H[2]; - dr = dl = H[3]; - er = el = H[4]; - // Computation - var t; - for (var i = 0; i < 80; i += 1) { - t = (al + M[offset+zl[i]])|0; - if (i<16){ - t += f1(bl,cl,dl) + hl[0]; - } else if (i<32) { - t += f2(bl,cl,dl) + hl[1]; - } else if (i<48) { - t += f3(bl,cl,dl) + hl[2]; - } else if (i<64) { - t += f4(bl,cl,dl) + hl[3]; - } else {// if (i<80) { - t += f5(bl,cl,dl) + hl[4]; - } - t = t|0; - t = rotl(t,sl[i]); - t = (t+el)|0; - al = el; - el = dl; - dl = rotl(cl, 10); - cl = bl; - bl = t; + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; - t = (ar + M[offset+zr[i]])|0; - if (i<16){ - t += f5(br,cr,dr) + hr[0]; - } else if (i<32) { - t += f4(br,cr,dr) + hr[1]; - } else if (i<48) { - t += f3(br,cr,dr) + hr[2]; - } else if (i<64) { - t += f2(br,cr,dr) + hr[3]; - } else {// if (i<80) { - t += f1(br,cr,dr) + hr[4]; - } - t = t|0; - t = rotl(t,sr[i]) ; - t = (t+er)|0; - ar = er; - er = dr; - dr = rotl(cr, 10); - cr = br; - br = t; + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; } - // Intermediate hash value - t = (H[1] + cl + dr)|0; - H[1] = (H[2] + dl + er)|0; - H[2] = (H[3] + el + ar)|0; - H[3] = (H[4] + al + br)|0; - H[4] = (H[0] + bl + cr)|0; - H[0] = t; - }, - _doFinalize: function () { // Shortcuts - var data = this._data; - var dataWords = data.words; + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( - (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | - (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) - ); - data.sigBytes = (dataWords.length + 1) * 4; + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; - // Hash final blocks - this._process(); + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + var t = keySchedule[ksRow - 1]; - // Shortcuts - var hash = this._hash; - var H = hash.words; + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); - // Swap endian - for (var i = 0; i < 5; i++) { - // Shortcut - var H_i = H[i]; + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; - // Swap - H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | - (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } } - // Return final computed hash - return hash; - }, + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } - return clone; - } - }); + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, - function f1(x, y, z) { - return ((x) ^ (y) ^ (z)); + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; - } + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); - function f2(x, y, z) { - return (((x)&(y)) | ((~x)&(z))); - } + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, - function f3(x, y, z) { - return (((x) | (~(y))) ^ (z)); - } + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; - function f4(x, y, z) { - return (((x) & (z)) | ((y)&(~(z)))); - } + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; - function f5(x, y, z) { - return ((x) ^ ((y) |(~(z)))); + // Key schedule row counter + var ksRow = 4; - } + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; - function rotl(x,n) { - return (x<>>(32-n)); - } + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.RIPEMD160('message'); - * var hash = CryptoJS.RIPEMD160(wordArray); - */ - C.RIPEMD160 = Hasher._createHelper(RIPEMD160); + keySize: 256/32 + }); /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static + * Shortcut functions to the cipher's object interface. * * @example * - * var hmac = CryptoJS.HmacRIPEMD160(message, key); + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); */ - C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); - }(Math)); + C.AES = BlockCipher._createHelper(AES); + }()); - return CryptoJS.RIPEMD160; + return CryptoJS.AES; })); -},{"./core":152}],176:[function(require,module,exports){ -;(function (root, factory) { +},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],152:[function(require,module,exports){ +;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS - module.exports = exports = factory(require("./core")); + module.exports = exports = factory(require("./core"), require("./evpkdf")); } else if (typeof define === "function" && define.amd) { // AMD - define(["./core"], factory); + define(["./core", "./evpkdf"], factory); } else { // Global (browser) @@ -33243,1163 +32894,1641 @@ function decrypt (data, password) { } }(this, function (CryptoJS) { - (function () { + /** + * Cipher core components. + */ + CryptoJS.lib.Cipher || (function (undefined) { // Shortcuts var C = CryptoJS; var C_lib = C.lib; + var Base = C_lib.Base; var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var Base64 = C_enc.Base64; var C_algo = C.algo; - - // Reusable object - var W = []; + var EvpKDF = C_algo.EvpKDF; /** - * SHA-1 hash algorithm. + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. */ - var SHA1 = C_algo.SHA1 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0x67452301, 0xefcdab89, - 0x98badcfe, 0x10325476, - 0xc3d2e1f0 - ]); + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function (key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); }, - _doProcessBlock: function (M, offset) { - // Shortcut - var H = this._hash.words; + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function (key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, - // Working variables - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; - var e = H[4]; + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function (xformMode, key, cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); - // Computation - for (var i = 0; i < 80; i++) { - if (i < 16) { - W[i] = M[offset + i] | 0; - } else { - var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; - W[i] = (n << 1) | (n >>> 31); - } + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; - var t = ((a << 5) | (a >>> 27)) + e + W[i]; - if (i < 20) { - t += ((b & c) | (~b & d)) + 0x5a827999; - } else if (i < 40) { - t += (b ^ c ^ d) + 0x6ed9eba1; - } else if (i < 60) { - t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; - } else /* if (i < 80) */ { - t += (b ^ c ^ d) - 0x359d3e2a; - } + // Set initial values + this.reset(); + }, - e = d; - d = c; - c = (b << 30) | (b >>> 2); - b = a; - a = t; - } + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - H[4] = (H[4] + e) | 0; + // Perform concrete-cipher logic + this._doReset(); }, - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function (dataUpdate) { + // Append + this._append(dataUpdate); - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; + // Process available blocks + return this._process(); + }, - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; - data.sigBytes = dataWords.length * 4; + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function (dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } - // Hash final blocks - this._process(); + // Perform concrete-cipher logic + var finalProcessedData = this._doFinalize(); - // Return final computed hash - return this._hash; + return finalProcessedData; }, - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); - - return clone; - } - }); + keySize: 128/32, - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA1('message'); - * var hash = CryptoJS.SHA1(wordArray); - */ - C.SHA1 = Hasher._createHelper(SHA1); + ivSize: 128/32, - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA1(message, key); - */ - C.HmacSHA1 = Hasher._createHmacHelper(SHA1); - }()); + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, - return CryptoJS.SHA1; + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: (function () { + function selectCipherStrategy(key) { + if (typeof key == 'string') { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } -})); -},{"./core":152}],177:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./sha256")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./sha256"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + return function (cipher) { + return { + encrypt: function (message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_algo = C.algo; - var SHA256 = C_algo.SHA256; + decrypt: function (ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + }()) + }); /** - * SHA-224 hash algorithm. + * Abstract base stream cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) */ - var SHA224 = C_algo.SHA224 = SHA256.extend({ - _doReset: function () { - this._hash = new WordArray.init([ - 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, - 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 - ]); - }, - + var StreamCipher = C_lib.StreamCipher = Cipher.extend({ _doFinalize: function () { - var hash = SHA256._doFinalize.call(this); + // Process partial blocks + var finalProcessedBlocks = this._process(!!'flush'); - hash.sigBytes -= 4; + return finalProcessedBlocks; + }, - return hash; - } + blockSize: 1 }); /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA224('message'); - * var hash = CryptoJS.SHA224(wordArray); + * Mode namespace. */ - C.SHA224 = SHA256._createHelper(SHA224); + var C_mode = C.mode = {}; /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA224(message, key); + * Abstract base block cipher mode template. */ - C.HmacSHA224 = SHA256._createHmacHelper(SHA224); - }()); - - - return CryptoJS.SHA224; + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function (cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, -})); -},{"./core":152,"./sha256":178}],178:[function(require,module,exports){ -;(function (root, factory) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function (cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, - (function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_algo = C.algo; + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function (cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); - // Initialization and round constants tables - var H = []; - var K = []; + /** + * Cipher Block Chaining mode. + */ + var CBC = C_mode.CBC = (function () { + /** + * Abstract base CBC mode. + */ + var CBC = BlockCipherMode.extend(); - // Compute constants - (function () { - function isPrime(n) { - var sqrtN = Math.sqrt(n); - for (var factor = 2; factor <= sqrtN; factor++) { - if (!(n % factor)) { - return false; - } + /** + * CBC encryptor. + */ + CBC.Encryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); } + }); - return true; - } + /** + * CBC decryptor. + */ + CBC.Decryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; - function getFractionalBits(n) { - return ((n - (n | 0)) * 0x100000000) | 0; - } + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); - var n = 2; - var nPrime = 0; - while (nPrime < 64) { - if (isPrime(n)) { - if (nPrime < 8) { - H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); - } - K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); - nPrime++; + // This block becomes the previous block + this._prevBlock = thisBlock; } + }); - n++; + function xorBlock(words, offset, blockSize) { + // Shortcut + var iv = this._iv; + + // Choose mixing block + if (iv) { + var block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + var block = this._prevBlock; + } + + // XOR blocks + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } } - }()); - // Reusable object - var W = []; + return CBC; + }()); /** - * SHA-256 hash algorithm. + * Padding namespace. */ - var SHA256 = C_algo.SHA256 = Hasher.extend({ - _doReset: function () { - this._hash = new WordArray.init(H.slice(0)); - }, + var C_pad = C.pad = {}; - _doProcessBlock: function (M, offset) { + /** + * PKCS #5/7 padding strategy. + */ + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function (data, blockSize) { // Shortcut - var H = this._hash.words; + var blockSizeBytes = blockSize * 4; - // Working variables - var a = H[0]; - var b = H[1]; - var c = H[2]; - var d = H[3]; - var e = H[4]; - var f = H[5]; - var g = H[6]; - var h = H[7]; + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; - // Computation - for (var i = 0; i < 64; i++) { - if (i < 16) { - W[i] = M[offset + i] | 0; - } else { - var gamma0x = W[i - 15]; - var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ - ((gamma0x << 14) | (gamma0x >>> 18)) ^ - (gamma0x >>> 3); + // Create padding word + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; - var gamma1x = W[i - 2]; - var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ - ((gamma1x << 13) | (gamma1x >>> 19)) ^ - (gamma1x >>> 10); + // Create padding + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); - W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; - } + // Add padding + data.concat(padding); + }, - var ch = (e & f) ^ (~e & g); - var maj = (a & b) ^ (a & c) ^ (b & c); + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); - var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; - var t1 = h + sigma1 + ch + K[i] + W[i]; - var t2 = sigma0 + maj; + /** + * Abstract base block cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + var BlockCipher = C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), - h = g; - g = f; - f = e; - e = (d + t1) | 0; - d = c; - c = b; - b = a; - a = (t1 + t2) | 0; + reset: function () { + // Reset cipher + Cipher.reset.call(this); + + // Shortcuts + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + + // Reset block mode + if (this._xformMode == this._ENC_XFORM_MODE) { + var modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + var modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; } - // Intermediate hash value - H[0] = (H[0] + a) | 0; - H[1] = (H[1] + b) | 0; - H[2] = (H[2] + c) | 0; - H[3] = (H[3] + d) | 0; - H[4] = (H[4] + e) | 0; - H[5] = (H[5] + f) | 0; - H[6] = (H[6] + g) | 0; - H[7] = (H[7] + h) | 0; + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + + _doProcessBlock: function (words, offset) { + this._mode.processBlock(words, offset); }, _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; + // Shortcut + var padding = this.cfg.padding; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; + // Finalize + if (this._xformMode == this._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; - data.sigBytes = dataWords.length * 4; + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ { + // Process final blocks + var finalProcessedBlocks = this._process(!!'flush'); - // Hash final blocks - this._process(); + // Unpad data + padding.unpad(finalProcessedBlocks); + } - // Return final computed hash - return this._hash; + return finalProcessedBlocks; }, - clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); + blockSize: 128/32 + }); - return clone; + /** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. + */ + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function (cipherParams) { + this.mixIn(cipherParams); + }, + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function (formatter) { + return (formatter || this.formatter).stringify(this); } }); /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA256('message'); - * var hash = CryptoJS.SHA256(wordArray); + * Format namespace. */ - C.SHA256 = Hasher._createHelper(SHA256); + var C_format = C.format = {}; /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA256(message, key); + * OpenSSL formatting strategy. */ - C.HmacSHA256 = Hasher._createHmacHelper(SHA256); - }(Math)); + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function (cipherParams) { + // Shortcuts + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + // Format + if (salt) { + var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + var wordArray = ciphertext; + } - return CryptoJS.SHA256; + return wordArray.toString(Base64); + }, -})); -},{"./core":152}],179:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./x64-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./x64-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function (openSSLStr) { + // Parse base64 + var ciphertext = Base64.parse(openSSLStr); - (function (Math) { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var Hasher = C_lib.Hasher; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var C_algo = C.algo; + // Shortcut + var ciphertextWords = ciphertext.words; - // Constants tables - var RHO_OFFSETS = []; - var PI_INDEXES = []; - var ROUND_CONSTANTS = []; + // Test for salt + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { + // Extract salt + var salt = WordArray.create(ciphertextWords.slice(2, 4)); - // Compute Constants - (function () { - // Compute rho offset constants - var x = 1, y = 0; - for (var t = 0; t < 24; t++) { - RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } - var newX = y % 5; - var newY = (2 * x + 3 * y) % 5; - x = newX; - y = newY; + return CipherParams.create({ ciphertext: ciphertext, salt: salt }); } - - // Compute pi index constants - for (var x = 0; x < 5; x++) { - for (var y = 0; y < 5; y++) { - PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; - } - } - - // Compute round constants - var LFSR = 0x01; - for (var i = 0; i < 24; i++) { - var roundConstantMsw = 0; - var roundConstantLsw = 0; - - for (var j = 0; j < 7; j++) { - if (LFSR & 0x01) { - var bitPosition = (1 << j) - 1; - if (bitPosition < 32) { - roundConstantLsw ^= 1 << bitPosition; - } else /* if (bitPosition >= 32) */ { - roundConstantMsw ^= 1 << (bitPosition - 32); - } - } - - // Compute next LFSR - if (LFSR & 0x80) { - // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 - LFSR = (LFSR << 1) ^ 0x71; - } else { - LFSR <<= 1; - } - } - - ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw); - } - }()); - - // Reusable objects for temporary values - var T = []; - (function () { - for (var i = 0; i < 25; i++) { - T[i] = X64Word.create(); - } - }()); + }; /** - * SHA-3 hash algorithm. + * A cipher wrapper that returns ciphertext as a serializable cipher params object. */ - var SHA3 = C_algo.SHA3 = Hasher.extend({ + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ /** * Configuration options. * - * @property {number} outputLength - * The desired number of bits in the output hash. - * Only values permitted are: 224, 256, 384, 512. - * Default: 512 + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL */ - cfg: Hasher.cfg.extend({ - outputLength: 512 + cfg: Base.extend({ + format: OpenSSLFormatter }), - _doReset: function () { - var state = this._state = [] - for (var i = 0; i < 25; i++) { - state[i] = new X64Word.init(); - } + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); - this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; - }, + // Encrypt + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); - _doProcessBlock: function (M, offset) { - // Shortcuts - var state = this._state; - var nBlockSizeLanes = this.blockSize / 2; + // Shortcut + var cipherCfg = encryptor.cfg; - // Absorb - for (var i = 0; i < nBlockSizeLanes; i++) { - // Shortcuts - var M2i = M[offset + 2 * i]; - var M2i1 = M[offset + 2 * i + 1]; + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext: ciphertext, + key: key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, - // Swap endian - M2i = ( - (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | - (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00) - ); - M2i1 = ( - (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | - (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00) - ); + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); - // Absorb message into state - var lane = state[i]; - lane.high ^= M2i1; - lane.low ^= M2i; - } + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); - // Rounds - for (var round = 0; round < 24; round++) { - // Theta - for (var x = 0; x < 5; x++) { - // Mix column lanes - var tMsw = 0, tLsw = 0; - for (var y = 0; y < 5; y++) { - var lane = state[x + 5 * y]; - tMsw ^= lane.high; - tLsw ^= lane.low; - } + // Decrypt + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); - // Temporary values - var Tx = T[x]; - Tx.high = tMsw; - Tx.low = tLsw; - } - for (var x = 0; x < 5; x++) { - // Shortcuts - var Tx4 = T[(x + 4) % 5]; - var Tx1 = T[(x + 1) % 5]; - var Tx1Msw = Tx1.high; - var Tx1Lsw = Tx1.low; + return plaintext; + }, - // Mix surrounding columns - var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); - var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); - for (var y = 0; y < 5; y++) { - var lane = state[x + 5 * y]; - lane.high ^= tMsw; - lane.low ^= tLsw; - } - } + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function (ciphertext, format) { + if (typeof ciphertext == 'string') { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); - // Rho Pi - for (var laneIndex = 1; laneIndex < 25; laneIndex++) { - // Shortcuts - var lane = state[laneIndex]; - var laneMsw = lane.high; - var laneLsw = lane.low; - var rhoOffset = RHO_OFFSETS[laneIndex]; + /** + * Key derivation function namespace. + */ + var C_kdf = C.kdf = {}; - // Rotate lanes - if (rhoOffset < 32) { - var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); - var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); - } else /* if (rhoOffset >= 32) */ { - var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); - var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); - } + /** + * OpenSSL key derivation function. + */ + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function (password, keySize, ivSize, salt) { + // Generate random salt + if (!salt) { + salt = WordArray.random(64/8); + } - // Transpose lanes - var TPiLane = T[PI_INDEXES[laneIndex]]; - TPiLane.high = tMsw; - TPiLane.low = tLsw; - } + // Derive key and IV + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); - // Rho pi at x = y = 0 - var T0 = T[0]; - var state0 = state[0]; - T0.high = state0.high; - T0.low = state0.low; + // Separate key and IV + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; - // Chi - for (var x = 0; x < 5; x++) { - for (var y = 0; y < 5; y++) { - // Shortcuts - var laneIndex = x + 5 * y; - var lane = state[laneIndex]; - var TLane = T[laneIndex]; - var Tx1Lane = T[((x + 1) % 5) + 5 * y]; - var Tx2Lane = T[((x + 2) % 5) + 5 * y]; + // Return params + return CipherParams.create({ key: key, iv: iv, salt: salt }); + } + }; - // Mix rows - lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); - lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); - } - } + /** + * A serializable cipher wrapper that derives the key from a password, + * and returns ciphertext as a serializable cipher params object. + */ + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), - // Iota - var lane = state[0]; - var roundConstant = ROUND_CONSTANTS[round]; - lane.high ^= roundConstant.high; - lane.low ^= roundConstant.low;; - } - }, + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); - _doFinalize: function () { - // Shortcuts - var data = this._data; - var dataWords = data.words; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; - var blockSizeBits = this.blockSize * 32; + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize); - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); - dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; - data.sigBytes = dataWords.length * 4; + // Add IV to config + cfg.iv = derivedParams.iv; - // Hash final blocks - this._process(); + // Encrypt + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); - // Shortcuts - var state = this._state; - var outputLengthBytes = this.cfg.outputLength / 8; - var outputLengthLanes = outputLengthBytes / 8; + // Mix in derived params + ciphertext.mixIn(derivedParams); - // Squeeze - var hashWords = []; - for (var i = 0; i < outputLengthLanes; i++) { - // Shortcuts - var lane = state[i]; - var laneMsw = lane.high; - var laneLsw = lane.low; + return ciphertext; + }, - // Swap endian - laneMsw = ( - (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | - (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00) - ); - laneLsw = ( - (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | - (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00) - ); + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); - // Squeeze state to retrieve hash - hashWords.push(laneLsw); - hashWords.push(laneMsw); - } + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); - // Return final computed hash - return new WordArray.init(hashWords, outputLengthBytes); - }, + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt); - clone: function () { - var clone = Hasher.clone.call(this); + // Add IV to config + cfg.iv = derivedParams.iv; - var state = clone._state = this._state.slice(0); - for (var i = 0; i < 25; i++) { - state[i] = state[i].clone(); - } + // Decrypt + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); - return clone; + return plaintext; } }); + }()); - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA3('message'); - * var hash = CryptoJS.SHA3(wordArray); - */ - C.SHA3 = Hasher._createHelper(SHA3); - - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA3(message, key); - */ - C.HmacSHA3 = Hasher._createHmacHelper(SHA3); - }(Math)); - - - return CryptoJS.SHA3; })); -},{"./core":152,"./x64-core":183}],180:[function(require,module,exports){ -;(function (root, factory, undef) { +},{"./core":153,"./evpkdf":156}],153:[function(require,module,exports){ +;(function (root, factory) { if (typeof exports === "object") { // CommonJS - module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512")); + module.exports = exports = factory(); } else if (typeof define === "function" && define.amd) { // AMD - define(["./core", "./x64-core", "./sha512"], factory); + define([], factory); } else { // Global (browser) - factory(root.CryptoJS); + root.CryptoJS = factory(); } -}(this, function (CryptoJS) { - - (function () { - // Shortcuts - var C = CryptoJS; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var X64WordArray = C_x64.WordArray; - var C_algo = C.algo; - var SHA512 = C_algo.SHA512; +}(this, function () { - /** - * SHA-384 hash algorithm. + /** + * CryptoJS core components. + */ + var CryptoJS = CryptoJS || (function (Math, undefined) { + /* + * Local polyfil of Object.create */ - var SHA384 = C_algo.SHA384 = SHA512.extend({ - _doReset: function () { - this._hash = new X64WordArray.init([ - new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), - new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), - new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), - new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) - ]); - }, + var create = Object.create || (function () { + function F() {}; - _doFinalize: function () { - var hash = SHA512._doFinalize.call(this); + return function (obj) { + var subtype; - hash.sigBytes -= 16; + F.prototype = obj; - return hash; - } - }); + subtype = new F(); - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA384('message'); - * var hash = CryptoJS.SHA384(wordArray); - */ - C.SHA384 = SHA512._createHelper(SHA384); + F.prototype = null; + + return subtype; + }; + }()) /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. - * - * @static - * - * @example - * - * var hmac = CryptoJS.HmacSHA384(message, key); + * CryptoJS namespace. */ - C.HmacSHA384 = SHA512._createHmacHelper(SHA384); - }()); - - - return CryptoJS.SHA384; - -})); -},{"./core":152,"./sha512":181,"./x64-core":183}],181:[function(require,module,exports){ -;(function (root, factory, undef) { - if (typeof exports === "object") { - // CommonJS - module.exports = exports = factory(require("./core"), require("./x64-core")); - } - else if (typeof define === "function" && define.amd) { - // AMD - define(["./core", "./x64-core"], factory); - } - else { - // Global (browser) - factory(root.CryptoJS); - } -}(this, function (CryptoJS) { - - (function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var Hasher = C_lib.Hasher; - var C_x64 = C.x64; - var X64Word = C_x64.Word; - var X64WordArray = C_x64.WordArray; - var C_algo = C.algo; - - function X64Word_create() { - return X64Word.create.apply(X64Word, arguments); - } - - // Constants - var K = [ - X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd), - X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc), - X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019), - X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118), - X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe), - X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2), - X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1), - X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694), - X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3), - X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65), - X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483), - X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5), - X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210), - X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4), - X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725), - X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70), - X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926), - X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df), - X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8), - X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b), - X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001), - X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30), - X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910), - X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8), - X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53), - X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8), - X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb), - X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3), - X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60), - X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec), - X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9), - X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b), - X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207), - X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178), - X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6), - X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b), - X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493), - X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c), - X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a), - X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817) - ]; + var C = {}; - // Reusable objects - var W = []; - (function () { - for (var i = 0; i < 80; i++) { - W[i] = X64Word_create(); - } - }()); + /** + * Library namespace. + */ + var C_lib = C.lib = {}; /** - * SHA-512 hash algorithm. + * Base object for prototypal inheritance. */ - var SHA512 = C_algo.SHA512 = Hasher.extend({ - _doReset: function () { - this._hash = new X64WordArray.init([ - new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b), - new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1), - new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f), - new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179) - ]); - }, + var Base = C_lib.Base = (function () { - _doProcessBlock: function (M, offset) { - // Shortcuts - var H = this._hash.words; - var H0 = H[0]; - var H1 = H[1]; - var H2 = H[2]; - var H3 = H[3]; - var H4 = H[4]; - var H5 = H[5]; - var H6 = H[6]; - var H7 = H[7]; + return { + /** + * Creates a new object that inherits from this object. + * + * @param {Object} overrides Properties to copy into the new object. + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * field: 'value', + * + * method: function () { + * } + * }); + */ + extend: function (overrides) { + // Spawn + var subtype = create(this); - var H0h = H0.high; - var H0l = H0.low; - var H1h = H1.high; - var H1l = H1.low; - var H2h = H2.high; - var H2l = H2.low; - var H3h = H3.high; - var H3l = H3.low; - var H4h = H4.high; - var H4l = H4.low; - var H5h = H5.high; - var H5l = H5.low; - var H6h = H6.high; - var H6l = H6.low; - var H7h = H7.high; - var H7l = H7.low; + // Augment + if (overrides) { + subtype.mixIn(overrides); + } - // Working variables - var ah = H0h; - var al = H0l; - var bh = H1h; - var bl = H1l; - var ch = H2h; - var cl = H2l; - var dh = H3h; - var dl = H3l; - var eh = H4h; - var el = H4l; - var fh = H5h; - var fl = H5l; - var gh = H6h; - var gl = H6l; - var hh = H7h; - var hl = H7l; + // Create default initializer + if (!subtype.hasOwnProperty('init') || this.init === subtype.init) { + subtype.init = function () { + subtype.$super.init.apply(this, arguments); + }; + } - // Rounds - for (var i = 0; i < 80; i++) { - // Shortcut - var Wi = W[i]; + // Initializer's prototype is the subtype object + subtype.init.prototype = subtype; - // Extend message - if (i < 16) { - var Wih = Wi.high = M[offset + i * 2] | 0; - var Wil = Wi.low = M[offset + i * 2 + 1] | 0; - } else { - // Gamma0 - var gamma0x = W[i - 15]; - var gamma0xh = gamma0x.high; - var gamma0xl = gamma0x.low; - var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7); - var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); + // Reference supertype + subtype.$super = this; - // Gamma1 - var gamma1x = W[i - 2]; - var gamma1xh = gamma1x.high; - var gamma1xl = gamma1x.low; - var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); - var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); + return subtype; + }, - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7 = W[i - 7]; - var Wi7h = Wi7.high; - var Wi7l = Wi7.low; + /** + * Extends this object and runs the init method. + * Arguments to create() will be passed to init(). + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var instance = MyType.create(); + */ + create: function () { + var instance = this.extend(); + instance.init.apply(instance, arguments); - var Wi16 = W[i - 16]; - var Wi16h = Wi16.high; - var Wi16l = Wi16.low; + return instance; + }, - var Wil = gamma0l + Wi7l; - var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); - var Wil = Wil + gamma1l; - var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); - var Wil = Wil + Wi16l; - var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); + /** + * Initializes a newly created object. + * Override this method to add some logic when your objects are created. + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * init: function () { + * // ... + * } + * }); + */ + init: function () { + }, - Wi.high = Wih; - Wi.low = Wil; + /** + * Copies properties into this object. + * + * @param {Object} properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn: function (properties) { + for (var propertyName in properties) { + if (properties.hasOwnProperty(propertyName)) { + this[propertyName] = properties[propertyName]; + } } - var chh = (eh & fh) ^ (~eh & gh); - var chl = (el & fl) ^ (~el & gl); - var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); - var majl = (al & bl) ^ (al & cl) ^ (bl & cl); - - var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); - var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); - var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); - var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); - - // t1 = h + sigma1 + ch + K[i] + W[i] - var Ki = K[i]; - var Kih = Ki.high; - var Kil = Ki.low; + // IE won't copy toString using the loop above + if (properties.hasOwnProperty('toString')) { + this.toString = properties.toString; + } + }, - var t1l = hl + sigma1l; - var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); - var t1l = t1l + chl; - var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); - var t1l = t1l + Kil; - var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); - var t1l = t1l + Wil; - var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = instance.clone(); + */ + clone: function () { + return this.init.prototype.extend(this); + } + }; + }()); - // t2 = sigma0 + maj - var t2l = sigma0l + majl; - var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); + /** + * An array of 32-bit words. + * + * @property {Array} words The array of 32-bit words. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var WordArray = C_lib.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of 32-bit words. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.create(); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + */ + init: function (words, sigBytes) { + words = this.words = words || []; - // Update working variables - hh = gh; - hl = gl; - gh = fh; - gl = fl; - fh = eh; - fl = el; - el = (dl + t1l) | 0; - eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; - dh = ch; - dl = cl; - ch = bh; - cl = bl; - bh = ah; - bl = al; - al = (t1l + t2l) | 0; - ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 4; } + }, - // Intermediate hash value - H0l = H0.low = (H0l + al); - H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); - H1l = H1.low = (H1l + bl); - H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); - H2l = H2.low = (H2l + cl); - H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); - H3l = H3.low = (H3l + dl); - H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); - H4l = H4.low = (H4l + el); - H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); - H5l = H5.low = (H5l + fl); - H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); - H6l = H6.low = (H6l + gl); - H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); - H7l = H7.low = (H7l + hl); - H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); + /** + * Converts this word array to a string. + * + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return {string} The stringified word array. + * + * @example + * + * var string = wordArray + ''; + * var string = wordArray.toString(); + * var string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString: function (encoder) { + return (encoder || Hex).stringify(this); }, - _doFinalize: function () { + /** + * Concatenates a word array to this word array. + * + * @param {WordArray} wordArray The word array to append. + * + * @return {WordArray} This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat: function (wordArray) { // Shortcuts - var data = this._data; - var dataWords = data.words; + var thisWords = this.words; + var thatWords = wordArray.words; + var thisSigBytes = this.sigBytes; + var thatSigBytes = wordArray.sigBytes; - var nBitsTotal = this._nDataBytes * 8; - var nBitsLeft = data.sigBytes * 8; + // Clamp excess bits + this.clamp(); - // Add padding - dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); - dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); - dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; - data.sigBytes = dataWords.length * 4; + // Concat + if (thisSigBytes % 4) { + // Copy one byte at a time + for (var i = 0; i < thatSigBytes; i++) { + var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8); + } + } else { + // Copy one word at a time + for (var i = 0; i < thatSigBytes; i += 4) { + thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2]; + } + } + this.sigBytes += thatSigBytes; - // Hash final blocks - this._process(); + // Chainable + return this; + }, - // Convert hash to 32-bit word array before returning - var hash = this._hash.toX32(); + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp: function () { + // Shortcuts + var words = this.words; + var sigBytes = this.sigBytes; - // Return final computed hash - return hash; + // Clamp + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); + words.length = Math.ceil(sigBytes / 4); }, + /** + * Creates a copy of this word array. + * + * @return {WordArray} The clone. + * + * @example + * + * var clone = wordArray.clone(); + */ clone: function () { - var clone = Hasher.clone.call(this); - clone._hash = this._hash.clone(); + var clone = Base.clone.call(this); + clone.words = this.words.slice(0); return clone; }, - blockSize: 1024/32 - }); - - /** - * Shortcut function to the hasher's object interface. - * - * @param {WordArray|string} message The message to hash. - * - * @return {WordArray} The hash. - * - * @static - * - * @example - * - * var hash = CryptoJS.SHA512('message'); - * var hash = CryptoJS.SHA512(wordArray); - */ - C.SHA512 = Hasher._createHelper(SHA512); + /** + * Creates a word array filled with random bytes. + * + * @param {number} nBytes The number of random bytes to generate. + * + * @return {WordArray} The random word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.random(16); + */ + random: function (nBytes) { + var words = []; - /** - * Shortcut function to the HMAC's object interface. - * - * @param {WordArray|string} message The message to hash. - * @param {WordArray|string} key The secret key. - * - * @return {WordArray} The HMAC. + var r = (function (m_w) { + var m_w = m_w; + var m_z = 0x3ade68b1; + var mask = 0xffffffff; + + return function () { + m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask; + m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask; + var result = ((m_z << 0x10) + m_w) & mask; + result /= 0x100000000; + result += 0.5; + return result * (Math.random() > .5 ? 1 : -1); + } + }); + + for (var i = 0, rcache; i < nBytes; i += 4) { + var _r = r((rcache || Math.random()) * 0x100000000); + + rcache = _r() * 0x3ade67b7; + words.push((_r() * 0x100000000) | 0); + } + + return new WordArray.init(words, nBytes); + } + }); + + /** + * Encoder namespace. + */ + var C_enc = C.enc = {}; + + /** + * Hex encoding strategy. + */ + var Hex = C_enc.Hex = { + /** + * Converts a word array to a hex string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The hex string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var hexChars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + hexChars.push((bite >>> 4).toString(16)); + hexChars.push((bite & 0x0f).toString(16)); + } + + return hexChars.join(''); + }, + + /** + * Converts a hex string to a word array. + * + * @param {string} hexStr The hex string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse: function (hexStr) { + // Shortcut + var hexStrLength = hexStr.length; + + // Convert + var words = []; + for (var i = 0; i < hexStrLength; i += 2) { + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + } + + return new WordArray.init(words, hexStrLength / 2); + } + }; + + /** + * Latin1 encoding strategy. + */ + var Latin1 = C_enc.Latin1 = { + /** + * Converts a word array to a Latin1 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Latin1 string. + * + * @static + * + * @example + * + * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var latin1Chars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + latin1Chars.push(String.fromCharCode(bite)); + } + + return latin1Chars.join(''); + }, + + /** + * Converts a Latin1 string to a word array. + * + * @param {string} latin1Str The Latin1 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + */ + parse: function (latin1Str) { + // Shortcut + var latin1StrLength = latin1Str.length; + + // Convert + var words = []; + for (var i = 0; i < latin1StrLength; i++) { + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); + } + + return new WordArray.init(words, latin1StrLength); + } + }; + + /** + * UTF-8 encoding strategy. + */ + var Utf8 = C_enc.Utf8 = { + /** + * Converts a word array to a UTF-8 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-8 string. + * + * @static + * + * @example + * + * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + */ + stringify: function (wordArray) { + try { + return decodeURIComponent(escape(Latin1.stringify(wordArray))); + } catch (e) { + throw new Error('Malformed UTF-8 data'); + } + }, + + /** + * Converts a UTF-8 string to a word array. + * + * @param {string} utf8Str The UTF-8 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + */ + parse: function (utf8Str) { + return Latin1.parse(unescape(encodeURIComponent(utf8Str))); + } + }; + + /** + * Abstract buffered block algorithm template. * - * @static + * The property blockSize must be implemented in a concrete subtype. * - * @example + * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({ + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset: function () { + // Initial values + this._data = new WordArray.init(); + this._nDataBytes = 0; + }, + + /** + * Adds new data to this block algorithm's buffer. + * + * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append: function (data) { + // Convert string to WordArray, else assume WordArray already + if (typeof data == 'string') { + data = Utf8.parse(data); + } + + // Append + this._data.concat(data); + this._nDataBytes += data.sigBytes; + }, + + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. + * + * @return {WordArray} The processed data. + * + * @example + * + * var processedData = bufferedBlockAlgorithm._process(); + * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process: function (doFlush) { + // Shortcuts + var data = this._data; + var dataWords = data.words; + var dataSigBytes = data.sigBytes; + var blockSize = this.blockSize; + var blockSizeBytes = blockSize * 4; + + // Count blocks ready + var nBlocksReady = dataSigBytes / blockSizeBytes; + if (doFlush) { + // Round up to include partial blocks + nBlocksReady = Math.ceil(nBlocksReady); + } else { + // Round down to include only full blocks, + // less the number of blocks that must remain in the buffer + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0); + } + + // Count words ready + var nWordsReady = nBlocksReady * blockSize; + + // Count bytes ready + var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + + // Process blocks + if (nWordsReady) { + for (var offset = 0; offset < nWordsReady; offset += blockSize) { + // Perform concrete-algorithm logic + this._doProcessBlock(dataWords, offset); + } + + // Remove processed words + var processedWords = dataWords.splice(0, nWordsReady); + data.sigBytes -= nBytesReady; + } + + // Return processed words + return new WordArray.init(processedWords, nBytesReady); + }, + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = bufferedBlockAlgorithm.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + clone._data = this._data.clone(); + + return clone; + }, + + _minBufferSize: 0 + }); + + /** + * Abstract hasher template. * - * var hmac = CryptoJS.HmacSHA512(message, key); + * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) */ - C.HmacSHA512 = Hasher._createHmacHelper(SHA512); - }()); + var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + */ + cfg: Base.extend(), + + /** + * Initializes a newly created hasher. + * + * @param {Object} cfg (Optional) The configuration options to use for this hash computation. + * + * @example + * + * var hasher = CryptoJS.algo.SHA256.create(); + */ + init: function (cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + // Set initial values + this.reset(); + }, + + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-hasher logic + this._doReset(); + }, + + /** + * Updates this hasher with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {Hasher} This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update: function (messageUpdate) { + // Append + this._append(messageUpdate); + + // Update the hash + this._process(); + + // Chainable + return this; + }, + + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The hash. + * + * @example + * + * var hash = hasher.finalize(); + * var hash = hasher.finalize('message'); + * var hash = hasher.finalize(wordArray); + */ + finalize: function (messageUpdate) { + // Final message update + if (messageUpdate) { + this._append(messageUpdate); + } + + // Perform concrete-hasher logic + var hash = this._doFinalize(); + + return hash; + }, + + blockSize: 512/32, + + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param {Hasher} hasher The hasher to create a helper for. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + _createHelper: function (hasher) { + return function (message, cfg) { + return new hasher.init(cfg).finalize(message); + }; + }, + + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param {Hasher} hasher The hasher to use in this HMAC helper. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + _createHmacHelper: function (hasher) { + return function (message, key) { + return new C_algo.HMAC.init(hasher, key).finalize(message); + }; + } + }); + + /** + * Algorithm namespace. + */ + var C_algo = C.algo = {}; + + return C; + }(Math)); - return CryptoJS.SHA512; + + return CryptoJS; })); -},{"./core":152,"./x64-core":183}],182:[function(require,module,exports){ -;(function (root, factory, undef) { +},{}],154:[function(require,module,exports){ +;(function (root, factory) { if (typeof exports === "object") { // CommonJS - module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + module.exports = exports = factory(require("./core")); } else if (typeof define === "function" && define.amd) { // AMD - define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + define(["./core"], factory); } else { // Global (browser) @@ -34412,765 +34541,280 @@ function decrypt (data, password) { var C = CryptoJS; var C_lib = C.lib; var WordArray = C_lib.WordArray; - var BlockCipher = C_lib.BlockCipher; - var C_algo = C.algo; + var C_enc = C.enc; - // Permuted Choice 1 constants - var PC1 = [ - 57, 49, 41, 33, 25, 17, 9, 1, - 58, 50, 42, 34, 26, 18, 10, 2, - 59, 51, 43, 35, 27, 19, 11, 3, - 60, 52, 44, 36, 63, 55, 47, 39, - 31, 23, 15, 7, 62, 54, 46, 38, - 30, 22, 14, 6, 61, 53, 45, 37, - 29, 21, 13, 5, 28, 20, 12, 4 - ]; + /** + * Base64 encoding strategy. + */ + var Base64 = C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; - // Permuted Choice 2 constants - var PC2 = [ - 14, 17, 11, 24, 1, 5, - 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, - 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, - 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, - 46, 42, 50, 36, 29, 32 - ]; + // Clamp excess bits + wordArray.clamp(); - // Cumulative bit shift constants - var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; - // SBOXes and round permutation constants - var SBOX_P = [ - { - 0x0: 0x808200, - 0x10000000: 0x8000, - 0x20000000: 0x808002, - 0x30000000: 0x2, - 0x40000000: 0x200, - 0x50000000: 0x808202, - 0x60000000: 0x800202, - 0x70000000: 0x800000, - 0x80000000: 0x202, - 0x90000000: 0x800200, - 0xa0000000: 0x8200, - 0xb0000000: 0x808000, - 0xc0000000: 0x8002, - 0xd0000000: 0x800002, - 0xe0000000: 0x0, - 0xf0000000: 0x8202, - 0x8000000: 0x0, - 0x18000000: 0x808202, - 0x28000000: 0x8202, - 0x38000000: 0x8000, - 0x48000000: 0x808200, - 0x58000000: 0x200, - 0x68000000: 0x808002, - 0x78000000: 0x2, - 0x88000000: 0x800200, - 0x98000000: 0x8200, - 0xa8000000: 0x808000, - 0xb8000000: 0x800202, - 0xc8000000: 0x800002, - 0xd8000000: 0x8002, - 0xe8000000: 0x202, - 0xf8000000: 0x800000, - 0x1: 0x8000, - 0x10000001: 0x2, - 0x20000001: 0x808200, - 0x30000001: 0x800000, - 0x40000001: 0x808002, - 0x50000001: 0x8200, - 0x60000001: 0x200, - 0x70000001: 0x800202, - 0x80000001: 0x808202, - 0x90000001: 0x808000, - 0xa0000001: 0x800002, - 0xb0000001: 0x8202, - 0xc0000001: 0x202, - 0xd0000001: 0x800200, - 0xe0000001: 0x8002, - 0xf0000001: 0x0, - 0x8000001: 0x808202, - 0x18000001: 0x808000, - 0x28000001: 0x800000, - 0x38000001: 0x200, - 0x48000001: 0x8000, - 0x58000001: 0x800002, - 0x68000001: 0x2, - 0x78000001: 0x8202, - 0x88000001: 0x8002, - 0x98000001: 0x800202, - 0xa8000001: 0x202, - 0xb8000001: 0x808200, - 0xc8000001: 0x800200, - 0xd8000001: 0x0, - 0xe8000001: 0x8200, - 0xf8000001: 0x808002 + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); }, - { - 0x0: 0x40084010, - 0x1000000: 0x4000, - 0x2000000: 0x80000, - 0x3000000: 0x40080010, - 0x4000000: 0x40000010, - 0x5000000: 0x40084000, - 0x6000000: 0x40004000, - 0x7000000: 0x10, - 0x8000000: 0x84000, - 0x9000000: 0x40004010, - 0xa000000: 0x40000000, - 0xb000000: 0x84010, - 0xc000000: 0x80010, - 0xd000000: 0x0, - 0xe000000: 0x4010, - 0xf000000: 0x40080000, - 0x800000: 0x40004000, - 0x1800000: 0x84010, - 0x2800000: 0x10, - 0x3800000: 0x40004010, - 0x4800000: 0x40084010, - 0x5800000: 0x40000000, - 0x6800000: 0x80000, - 0x7800000: 0x40080010, - 0x8800000: 0x80010, - 0x9800000: 0x0, - 0xa800000: 0x4000, - 0xb800000: 0x40080000, - 0xc800000: 0x40000010, - 0xd800000: 0x84000, - 0xe800000: 0x40084000, - 0xf800000: 0x4010, - 0x10000000: 0x0, - 0x11000000: 0x40080010, - 0x12000000: 0x40004010, - 0x13000000: 0x40084000, - 0x14000000: 0x40080000, - 0x15000000: 0x10, - 0x16000000: 0x84010, - 0x17000000: 0x4000, - 0x18000000: 0x4010, - 0x19000000: 0x80000, - 0x1a000000: 0x80010, - 0x1b000000: 0x40000010, - 0x1c000000: 0x84000, - 0x1d000000: 0x40004000, - 0x1e000000: 0x40000000, - 0x1f000000: 0x40084010, - 0x10800000: 0x84010, - 0x11800000: 0x80000, - 0x12800000: 0x40080000, - 0x13800000: 0x4000, - 0x14800000: 0x40004000, - 0x15800000: 0x40084010, - 0x16800000: 0x10, - 0x17800000: 0x40000000, - 0x18800000: 0x40084000, - 0x19800000: 0x40000010, - 0x1a800000: 0x40004010, - 0x1b800000: 0x80010, - 0x1c800000: 0x0, - 0x1d800000: 0x4010, - 0x1e800000: 0x40080010, - 0x1f800000: 0x84000 + + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function (base64Str) { + // Shortcuts + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + return parseLoop(base64Str, base64StrLength, reverseMap); + }, - { - 0x0: 0x104, - 0x100000: 0x0, - 0x200000: 0x4000100, - 0x300000: 0x10104, - 0x400000: 0x10004, - 0x500000: 0x4000004, - 0x600000: 0x4010104, - 0x700000: 0x4010000, - 0x800000: 0x4000000, - 0x900000: 0x4010100, - 0xa00000: 0x10100, - 0xb00000: 0x4010004, - 0xc00000: 0x4000104, - 0xd00000: 0x10000, - 0xe00000: 0x4, - 0xf00000: 0x100, - 0x80000: 0x4010100, - 0x180000: 0x4010004, - 0x280000: 0x0, - 0x380000: 0x4000100, - 0x480000: 0x4000004, - 0x580000: 0x10000, - 0x680000: 0x10004, - 0x780000: 0x104, - 0x880000: 0x4, - 0x980000: 0x100, - 0xa80000: 0x4010000, - 0xb80000: 0x10104, - 0xc80000: 0x10100, - 0xd80000: 0x4000104, - 0xe80000: 0x4010104, - 0xf80000: 0x4000000, - 0x1000000: 0x4010100, - 0x1100000: 0x10004, - 0x1200000: 0x10000, - 0x1300000: 0x4000100, - 0x1400000: 0x100, - 0x1500000: 0x4010104, - 0x1600000: 0x4000004, - 0x1700000: 0x0, - 0x1800000: 0x4000104, - 0x1900000: 0x4000000, - 0x1a00000: 0x4, - 0x1b00000: 0x10100, - 0x1c00000: 0x4010000, - 0x1d00000: 0x104, - 0x1e00000: 0x10104, - 0x1f00000: 0x4010004, - 0x1080000: 0x4000000, - 0x1180000: 0x104, - 0x1280000: 0x4010100, - 0x1380000: 0x0, - 0x1480000: 0x10004, - 0x1580000: 0x4000100, - 0x1680000: 0x100, - 0x1780000: 0x4010004, - 0x1880000: 0x10000, - 0x1980000: 0x4010104, - 0x1a80000: 0x10104, - 0x1b80000: 0x4000004, - 0x1c80000: 0x4000104, - 0x1d80000: 0x4010000, - 0x1e80000: 0x4, - 0x1f80000: 0x10100 + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + }; + + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); + words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + }()); + + + return CryptoJS.enc.Base64; + +})); +},{"./core":153}],155:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * UTF-16 BE encoding strategy. + */ + var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = { + /** + * Converts a word array to a UTF-16 BE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 BE string. + * + * @static + * + * @example + * + * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); }, - { - 0x0: 0x80401000, - 0x10000: 0x80001040, - 0x20000: 0x401040, - 0x30000: 0x80400000, - 0x40000: 0x0, - 0x50000: 0x401000, - 0x60000: 0x80000040, - 0x70000: 0x400040, - 0x80000: 0x80000000, - 0x90000: 0x400000, - 0xa0000: 0x40, - 0xb0000: 0x80001000, - 0xc0000: 0x80400040, - 0xd0000: 0x1040, - 0xe0000: 0x1000, - 0xf0000: 0x80401040, - 0x8000: 0x80001040, - 0x18000: 0x40, - 0x28000: 0x80400040, - 0x38000: 0x80001000, - 0x48000: 0x401000, - 0x58000: 0x80401040, - 0x68000: 0x0, - 0x78000: 0x80400000, - 0x88000: 0x1000, - 0x98000: 0x80401000, - 0xa8000: 0x400000, - 0xb8000: 0x1040, - 0xc8000: 0x80000000, - 0xd8000: 0x400040, - 0xe8000: 0x401040, - 0xf8000: 0x80000040, - 0x100000: 0x400040, - 0x110000: 0x401000, - 0x120000: 0x80000040, - 0x130000: 0x0, - 0x140000: 0x1040, - 0x150000: 0x80400040, - 0x160000: 0x80401000, - 0x170000: 0x80001040, - 0x180000: 0x80401040, - 0x190000: 0x80000000, - 0x1a0000: 0x80400000, - 0x1b0000: 0x401040, - 0x1c0000: 0x80001000, - 0x1d0000: 0x400000, - 0x1e0000: 0x40, - 0x1f0000: 0x1000, - 0x108000: 0x80400000, - 0x118000: 0x80401040, - 0x128000: 0x0, - 0x138000: 0x401000, - 0x148000: 0x400040, - 0x158000: 0x80000000, - 0x168000: 0x80001040, - 0x178000: 0x40, - 0x188000: 0x80000040, - 0x198000: 0x1000, - 0x1a8000: 0x80001000, - 0x1b8000: 0x80400040, - 0x1c8000: 0x1040, - 0x1d8000: 0x80401000, - 0x1e8000: 0x400000, - 0x1f8000: 0x401040 + + /** + * Converts a UTF-16 BE string to a word array. + * + * @param {string} utf16Str The UTF-16 BE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; + + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); + } + + return WordArray.create(words, utf16StrLength * 2); + } + }; + + /** + * UTF-16 LE encoding strategy. + */ + C_enc.Utf16LE = { + /** + * Converts a word array to a UTF-16 LE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 LE string. + * + * @static + * + * @example + * + * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); }, - { - 0x0: 0x80, - 0x1000: 0x1040000, - 0x2000: 0x40000, - 0x3000: 0x20000000, - 0x4000: 0x20040080, - 0x5000: 0x1000080, - 0x6000: 0x21000080, - 0x7000: 0x40080, - 0x8000: 0x1000000, - 0x9000: 0x20040000, - 0xa000: 0x20000080, - 0xb000: 0x21040080, - 0xc000: 0x21040000, - 0xd000: 0x0, - 0xe000: 0x1040080, - 0xf000: 0x21000000, - 0x800: 0x1040080, - 0x1800: 0x21000080, - 0x2800: 0x80, - 0x3800: 0x1040000, - 0x4800: 0x40000, - 0x5800: 0x20040080, - 0x6800: 0x21040000, - 0x7800: 0x20000000, - 0x8800: 0x20040000, - 0x9800: 0x0, - 0xa800: 0x21040080, - 0xb800: 0x1000080, - 0xc800: 0x20000080, - 0xd800: 0x21000000, - 0xe800: 0x1000000, - 0xf800: 0x40080, - 0x10000: 0x40000, - 0x11000: 0x80, - 0x12000: 0x20000000, - 0x13000: 0x21000080, - 0x14000: 0x1000080, - 0x15000: 0x21040000, - 0x16000: 0x20040080, - 0x17000: 0x1000000, - 0x18000: 0x21040080, - 0x19000: 0x21000000, - 0x1a000: 0x1040000, - 0x1b000: 0x20040000, - 0x1c000: 0x40080, - 0x1d000: 0x20000080, - 0x1e000: 0x0, - 0x1f000: 0x1040080, - 0x10800: 0x21000080, - 0x11800: 0x1000000, - 0x12800: 0x1040000, - 0x13800: 0x20040080, - 0x14800: 0x20000000, - 0x15800: 0x1040080, - 0x16800: 0x80, - 0x17800: 0x21040000, - 0x18800: 0x40080, - 0x19800: 0x21040080, - 0x1a800: 0x0, - 0x1b800: 0x21000000, - 0x1c800: 0x1000080, - 0x1d800: 0x40000, - 0x1e800: 0x20040000, - 0x1f800: 0x20000080 - }, - { - 0x0: 0x10000008, - 0x100: 0x2000, - 0x200: 0x10200000, - 0x300: 0x10202008, - 0x400: 0x10002000, - 0x500: 0x200000, - 0x600: 0x200008, - 0x700: 0x10000000, - 0x800: 0x0, - 0x900: 0x10002008, - 0xa00: 0x202000, - 0xb00: 0x8, - 0xc00: 0x10200008, - 0xd00: 0x202008, - 0xe00: 0x2008, - 0xf00: 0x10202000, - 0x80: 0x10200000, - 0x180: 0x10202008, - 0x280: 0x8, - 0x380: 0x200000, - 0x480: 0x202008, - 0x580: 0x10000008, - 0x680: 0x10002000, - 0x780: 0x2008, - 0x880: 0x200008, - 0x980: 0x2000, - 0xa80: 0x10002008, - 0xb80: 0x10200008, - 0xc80: 0x0, - 0xd80: 0x10202000, - 0xe80: 0x202000, - 0xf80: 0x10000000, - 0x1000: 0x10002000, - 0x1100: 0x10200008, - 0x1200: 0x10202008, - 0x1300: 0x2008, - 0x1400: 0x200000, - 0x1500: 0x10000000, - 0x1600: 0x10000008, - 0x1700: 0x202000, - 0x1800: 0x202008, - 0x1900: 0x0, - 0x1a00: 0x8, - 0x1b00: 0x10200000, - 0x1c00: 0x2000, - 0x1d00: 0x10002008, - 0x1e00: 0x10202000, - 0x1f00: 0x200008, - 0x1080: 0x8, - 0x1180: 0x202000, - 0x1280: 0x200000, - 0x1380: 0x10000008, - 0x1480: 0x10002000, - 0x1580: 0x2008, - 0x1680: 0x10202008, - 0x1780: 0x10200000, - 0x1880: 0x10202000, - 0x1980: 0x10200008, - 0x1a80: 0x2000, - 0x1b80: 0x202008, - 0x1c80: 0x200008, - 0x1d80: 0x0, - 0x1e80: 0x10000000, - 0x1f80: 0x10002008 - }, - { - 0x0: 0x100000, - 0x10: 0x2000401, - 0x20: 0x400, - 0x30: 0x100401, - 0x40: 0x2100401, - 0x50: 0x0, - 0x60: 0x1, - 0x70: 0x2100001, - 0x80: 0x2000400, - 0x90: 0x100001, - 0xa0: 0x2000001, - 0xb0: 0x2100400, - 0xc0: 0x2100000, - 0xd0: 0x401, - 0xe0: 0x100400, - 0xf0: 0x2000000, - 0x8: 0x2100001, - 0x18: 0x0, - 0x28: 0x2000401, - 0x38: 0x2100400, - 0x48: 0x100000, - 0x58: 0x2000001, - 0x68: 0x2000000, - 0x78: 0x401, - 0x88: 0x100401, - 0x98: 0x2000400, - 0xa8: 0x2100000, - 0xb8: 0x100001, - 0xc8: 0x400, - 0xd8: 0x2100401, - 0xe8: 0x1, - 0xf8: 0x100400, - 0x100: 0x2000000, - 0x110: 0x100000, - 0x120: 0x2000401, - 0x130: 0x2100001, - 0x140: 0x100001, - 0x150: 0x2000400, - 0x160: 0x2100400, - 0x170: 0x100401, - 0x180: 0x401, - 0x190: 0x2100401, - 0x1a0: 0x100400, - 0x1b0: 0x1, - 0x1c0: 0x0, - 0x1d0: 0x2100000, - 0x1e0: 0x2000001, - 0x1f0: 0x400, - 0x108: 0x100400, - 0x118: 0x2000401, - 0x128: 0x2100001, - 0x138: 0x1, - 0x148: 0x2000000, - 0x158: 0x100000, - 0x168: 0x401, - 0x178: 0x2100400, - 0x188: 0x2000001, - 0x198: 0x2100000, - 0x1a8: 0x0, - 0x1b8: 0x2100401, - 0x1c8: 0x100401, - 0x1d8: 0x400, - 0x1e8: 0x2000400, - 0x1f8: 0x100001 - }, - { - 0x0: 0x8000820, - 0x1: 0x20000, - 0x2: 0x8000000, - 0x3: 0x20, - 0x4: 0x20020, - 0x5: 0x8020820, - 0x6: 0x8020800, - 0x7: 0x800, - 0x8: 0x8020000, - 0x9: 0x8000800, - 0xa: 0x20800, - 0xb: 0x8020020, - 0xc: 0x820, - 0xd: 0x0, - 0xe: 0x8000020, - 0xf: 0x20820, - 0x80000000: 0x800, - 0x80000001: 0x8020820, - 0x80000002: 0x8000820, - 0x80000003: 0x8000000, - 0x80000004: 0x8020000, - 0x80000005: 0x20800, - 0x80000006: 0x20820, - 0x80000007: 0x20, - 0x80000008: 0x8000020, - 0x80000009: 0x820, - 0x8000000a: 0x20020, - 0x8000000b: 0x8020800, - 0x8000000c: 0x0, - 0x8000000d: 0x8020020, - 0x8000000e: 0x8000800, - 0x8000000f: 0x20000, - 0x10: 0x20820, - 0x11: 0x8020800, - 0x12: 0x20, - 0x13: 0x800, - 0x14: 0x8000800, - 0x15: 0x8000020, - 0x16: 0x8020020, - 0x17: 0x20000, - 0x18: 0x0, - 0x19: 0x20020, - 0x1a: 0x8020000, - 0x1b: 0x8000820, - 0x1c: 0x8020820, - 0x1d: 0x20800, - 0x1e: 0x820, - 0x1f: 0x8000000, - 0x80000010: 0x20000, - 0x80000011: 0x800, - 0x80000012: 0x8020020, - 0x80000013: 0x20820, - 0x80000014: 0x20, - 0x80000015: 0x8020000, - 0x80000016: 0x8000000, - 0x80000017: 0x8000820, - 0x80000018: 0x8020820, - 0x80000019: 0x8000020, - 0x8000001a: 0x8000800, - 0x8000001b: 0x0, - 0x8000001c: 0x20800, - 0x8000001d: 0x820, - 0x8000001e: 0x20020, - 0x8000001f: 0x8020800 - } - ]; - - // Masks that select the SBOX input - var SBOX_MASK = [ - 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, - 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f - ]; - - /** - * DES block cipher algorithm. - */ - var DES = C_algo.DES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - - // Select 56 bits according to PC1 - var keyBits = []; - for (var i = 0; i < 56; i++) { - var keyBitPos = PC1[i] - 1; - keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; - } - - // Assemble 16 subkeys - var subKeys = this._subKeys = []; - for (var nSubKey = 0; nSubKey < 16; nSubKey++) { - // Create subkey - var subKey = subKeys[nSubKey] = []; - - // Shortcut - var bitShift = BIT_SHIFTS[nSubKey]; - - // Select 48 bits according to PC2 - for (var i = 0; i < 24; i++) { - // Select from the left 28 key bits - subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); - - // Select from the right 28 key bits - subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); - } - - // Since each subkey is applied to an expanded 32-bit input, - // the subkey can be broken into 8 values scaled to 32-bits, - // which allows the key to be used without expansion - subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); - for (var i = 1; i < 7; i++) { - subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); - } - subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); - } - - // Compute inverse subkeys - var invSubKeys = this._invSubKeys = []; - for (var i = 0; i < 16; i++) { - invSubKeys[i] = subKeys[15 - i]; - } - }, - - encryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._subKeys); - }, - - decryptBlock: function (M, offset) { - this._doCryptBlock(M, offset, this._invSubKeys); - }, - - _doCryptBlock: function (M, offset, subKeys) { - // Get input - this._lBlock = M[offset]; - this._rBlock = M[offset + 1]; - - // Initial permutation - exchangeLR.call(this, 4, 0x0f0f0f0f); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeRL.call(this, 2, 0x33333333); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeLR.call(this, 1, 0x55555555); - // Rounds - for (var round = 0; round < 16; round++) { - // Shortcuts - var subKey = subKeys[round]; - var lBlock = this._lBlock; - var rBlock = this._rBlock; + /** + * Converts a UTF-16 LE string to a word array. + * + * @param {string} utf16Str The UTF-16 LE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; - // Feistel function - var f = 0; - for (var i = 0; i < 8; i++) { - f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; - } - this._lBlock = rBlock; - this._rBlock = lBlock ^ f; + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); } - // Undo swap from last round - var t = this._lBlock; - this._lBlock = this._rBlock; - this._rBlock = t; - - // Final permutation - exchangeLR.call(this, 1, 0x55555555); - exchangeRL.call(this, 8, 0x00ff00ff); - exchangeRL.call(this, 2, 0x33333333); - exchangeLR.call(this, 16, 0x0000ffff); - exchangeLR.call(this, 4, 0x0f0f0f0f); - - // Set output - M[offset] = this._lBlock; - M[offset + 1] = this._rBlock; - }, - - keySize: 64/32, - - ivSize: 64/32, - - blockSize: 64/32 - }); - - // Swap bits across the left and right words - function exchangeLR(offset, mask) { - var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; - this._rBlock ^= t; - this._lBlock ^= t << offset; - } + return WordArray.create(words, utf16StrLength * 2); + } + }; - function exchangeRL(offset, mask) { - var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; - this._lBlock ^= t; - this._rBlock ^= t << offset; + function swapEndian(word) { + return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); } - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); - */ - C.DES = BlockCipher._createHelper(DES); - - /** - * Triple-DES block cipher algorithm. - */ - var TripleDES = C_algo.TripleDES = BlockCipher.extend({ - _doReset: function () { - // Shortcuts - var key = this._key; - var keyWords = key.words; - - // Create DES instances - this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); - this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); - this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); - }, - - encryptBlock: function (M, offset) { - this._des1.encryptBlock(M, offset); - this._des2.decryptBlock(M, offset); - this._des3.encryptBlock(M, offset); - }, - - decryptBlock: function (M, offset) { - this._des3.decryptBlock(M, offset); - this._des2.encryptBlock(M, offset); - this._des1.decryptBlock(M, offset); - }, - - keySize: 192/32, - - ivSize: 64/32, - - blockSize: 64/32 - }); - - /** - * Shortcut functions to the cipher's object interface. - * - * @example - * - * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); - * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); - */ - C.TripleDES = BlockCipher._createHelper(TripleDES); }()); - return CryptoJS.TripleDES; + return CryptoJS.enc.Utf16; })); -},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],183:[function(require,module,exports){ -;(function (root, factory) { +},{"./core":153}],156:[function(require,module,exports){ +;(function (root, factory, undef) { if (typeof exports === "object") { // CommonJS - module.exports = exports = factory(require("./core")); + module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); } else if (typeof define === "function" && define.amd) { // AMD - define(["./core"], factory); + define(["./core", "./sha1", "./hmac"], factory); } else { // Global (browser) @@ -35178,6143 +34822,13489 @@ function decrypt (data, password) { } }(this, function (CryptoJS) { - (function (undefined) { + (function () { // Shortcuts var C = CryptoJS; var C_lib = C.lib; var Base = C_lib.Base; - var X32WordArray = C_lib.WordArray; - - /** - * x64 namespace. - */ - var C_x64 = C.x64 = {}; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; /** - * A 64-bit word. + * This key derivation function is meant to conform with EVP_BytesToKey. + * www.openssl.org/docs/crypto/EVP_BytesToKey.html */ - var X64Word = C_x64.Word = Base.extend({ + var EvpKDF = C_algo.EvpKDF = Base.extend({ /** - * Initializes a newly created 64-bit word. - * - * @param {number} high The high 32 bits. - * @param {number} low The low 32 bits. - * - * @example + * Configuration options. * - * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 */ - init: function (high, low) { - this.high = high; - this.low = low; - } + cfg: Base.extend({ + keySize: 128/32, + hasher: MD5, + iterations: 1 + }), /** - * Bitwise NOTs this word. + * Initializes a newly created key derivation function. * - * @return {X64Word} A new x64-Word object after negating. + * @param {Object} cfg (Optional) The configuration options to use for the derivation. * * @example * - * var negated = x64Word.not(); + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); */ - // not: function () { - // var high = ~this.high; - // var low = ~this.low; - - // return X64Word.create(high, low); - // }, + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, /** - * Bitwise ANDs this word with the passed word. + * Derives a key from a password. * - * @param {X64Word} word The x64-Word to AND with this word. + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. * - * @return {X64Word} A new x64-Word object after ANDing. + * @return {WordArray} The derived key. * * @example * - * var anded = x64Word.and(anotherX64Word); + * var key = kdf.compute(password, salt); */ - // and: function (word) { - // var high = this.high & word.high; - // var low = this.low & word.low; + compute: function (password, salt) { + // Shortcut + var cfg = this.cfg; - // return X64Word.create(high, low); - // }, + // Init hasher + var hasher = cfg.hasher.create(); - /** - * Bitwise ORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to OR with this word. - * - * @return {X64Word} A new x64-Word object after ORing. - * - * @example - * - * var ored = x64Word.or(anotherX64Word); - */ - // or: function (word) { - // var high = this.high | word.high; - // var low = this.low | word.low; + // Initial values + var derivedKey = WordArray.create(); - // return X64Word.create(high, low); - // }, + // Shortcuts + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; - /** - * Bitwise XORs this word with the passed word. - * - * @param {X64Word} word The x64-Word to XOR with this word. - * - * @return {X64Word} A new x64-Word object after XORing. - * - * @example - * - * var xored = x64Word.xor(anotherX64Word); - */ - // xor: function (word) { - // var high = this.high ^ word.high; - // var low = this.low ^ word.low; + // Generate key + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + var block = hasher.update(password).finalize(salt); + hasher.reset(); - // return X64Word.create(high, low); - // }, + // Iterations + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } - /** - * Shifts this word n bits to the left. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftL(25); - */ - // shiftL: function (n) { - // if (n < 32) { - // var high = (this.high << n) | (this.low >>> (32 - n)); - // var low = this.low << n; - // } else { - // var high = this.low << (n - 32); - // var low = 0; - // } + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; - // return X64Word.create(high, low); - // }, + return derivedKey; + } + }); - /** - * Shifts this word n bits to the right. - * - * @param {number} n The number of bits to shift. - * - * @return {X64Word} A new x64-Word object after shifting. - * - * @example - * - * var shifted = x64Word.shiftR(7); - */ - // shiftR: function (n) { - // if (n < 32) { - // var low = (this.low >>> n) | (this.high << (32 - n)); - // var high = this.high >>> n; - // } else { - // var low = this.high >>> (n - 32); - // var high = 0; - // } + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.EvpKDF(password, salt); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.EvpKDF = function (password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + }()); - // return X64Word.create(high, low); - // }, + return CryptoJS.EvpKDF; + +})); +},{"./core":153,"./hmac":158,"./sha1":177}],157:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var CipherParams = C_lib.CipherParams; + var C_enc = C.enc; + var Hex = C_enc.Hex; + var C_format = C.format; + + var HexFormatter = C_format.Hex = { /** - * Rotates this word n bits to the left. + * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. * - * @param {number} n The number of bits to rotate. + * @param {CipherParams} cipherParams The cipher params object. * - * @return {X64Word} A new x64-Word object after rotating. + * @return {string} The hexadecimally encoded string. + * + * @static * * @example * - * var rotated = x64Word.rotL(25); + * var hexString = CryptoJS.format.Hex.stringify(cipherParams); */ - // rotL: function (n) { - // return this.shiftL(n).or(this.shiftR(64 - n)); - // }, + stringify: function (cipherParams) { + return cipherParams.ciphertext.toString(Hex); + }, /** - * Rotates this word n bits to the right. + * Converts a hexadecimally encoded ciphertext string to a cipher params object. * - * @param {number} n The number of bits to rotate. + * @param {string} input The hexadecimally encoded string. * - * @return {X64Word} A new x64-Word object after rotating. + * @return {CipherParams} The cipher params object. + * + * @static * * @example * - * var rotated = x64Word.rotR(7); + * var cipherParams = CryptoJS.format.Hex.parse(hexString); */ - // rotR: function (n) { - // return this.shiftR(n).or(this.shiftL(64 - n)); - // }, + parse: function (input) { + var ciphertext = Hex.parse(input); + return CipherParams.create({ ciphertext: ciphertext }); + } + }; + }()); + + + return CryptoJS.format.Hex; + +})); +},{"./cipher-core":152,"./core":153}],158:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var C_algo = C.algo; + /** + * HMAC algorithm. + */ + var HMAC = C_algo.HMAC = Base.extend({ /** - * Adds this word with the passed word. - * - * @param {X64Word} word The x64-Word to add with this word. + * Initializes a newly created HMAC. * - * @return {X64Word} A new x64-Word object after adding. + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. * * @example * - * var added = x64Word.add(anotherX64Word); + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); */ - // add: function (word) { - // var low = (this.low + word.low) | 0; - // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; - // var high = (this.high + word.high + carry) | 0; + init: function (hasher, key) { + // Init hasher + hasher = this._hasher = new hasher.init(); - // return X64Word.create(high, low); - // } - }); + // Convert string to WordArray, else assume WordArray already + if (typeof key == 'string') { + key = Utf8.parse(key); + } + + // Shortcuts + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + + // Allow arbitrary length keys + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + + // Clamp excess bits + key.clamp(); + + // Clone key for inner and outer pads + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + + // Shortcuts + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + + // XOR keys with pad constants + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 0x5c5c5c5c; + iKeyWords[i] ^= 0x36363636; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + + // Set initial values + this.reset(); + }, - /** - * An array of 64-bit words. - * - * @property {Array} words The array of CryptoJS.x64.Word objects. - * @property {number} sigBytes The number of significant bytes in this word array. - */ - var X64WordArray = C_x64.WordArray = Base.extend({ /** - * Initializes a newly created word array. - * - * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. - * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * Resets this HMAC to its initial state. * * @example * - * var wordArray = CryptoJS.x64.WordArray.create(); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ]); - * - * var wordArray = CryptoJS.x64.WordArray.create([ - * CryptoJS.x64.Word.create(0x00010203, 0x04050607), - * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) - * ], 10); + * hmacHasher.reset(); */ - init: function (words, sigBytes) { - words = this.words = words || []; + reset: function () { + // Shortcut + var hasher = this._hasher; - if (sigBytes != undefined) { - this.sigBytes = sigBytes; - } else { - this.sigBytes = words.length * 8; - } + // Reset + hasher.reset(); + hasher.update(this._iKey); }, /** - * Converts this 64-bit word array to a 32-bit word array. + * Updates this HMAC with a message. * - * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. * * @example * - * var x32WordArray = x64WordArray.toX32(); + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); */ - toX32: function () { - // Shortcuts - var x64Words = this.words; - var x64WordsLength = x64Words.length; - - // Convert - var x32Words = []; - for (var i = 0; i < x64WordsLength; i++) { - var x64Word = x64Words[i]; - x32Words.push(x64Word.high); - x32Words.push(x64Word.low); - } + update: function (messageUpdate) { + this._hasher.update(messageUpdate); - return X32WordArray.create(x32Words, this.sigBytes); + // Chainable + return this; }, /** - * Creates a copy of this word array. + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. * - * @return {X64WordArray} The clone. + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The HMAC. * * @example * - * var clone = x64WordArray.clone(); + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); */ - clone: function () { - var clone = Base.clone.call(this); - - // Clone "words" array - var words = clone.words = this.words.slice(0); + finalize: function (messageUpdate) { + // Shortcut + var hasher = this._hasher; - // Clone each X64Word object - var wordsLength = words.length; - for (var i = 0; i < wordsLength; i++) { - words[i] = words[i].clone(); - } + // Compute HMAC + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); - return clone; + return hmac; } }); }()); +})); +},{"./core":153}],159:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory); + } + else { + // Global (browser) + root.CryptoJS = factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + return CryptoJS; })); -},{"./core":152}],184:[function(require,module,exports){ -(function (process){ -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ +},{"./aes":151,"./cipher-core":152,"./core":153,"./enc-base64":154,"./enc-utf16":155,"./evpkdf":156,"./format-hex":157,"./hmac":158,"./lib-typedarrays":160,"./md5":161,"./mode-cfb":162,"./mode-ctr":164,"./mode-ctr-gladman":163,"./mode-ecb":165,"./mode-ofb":166,"./pad-ansix923":167,"./pad-iso10126":168,"./pad-iso97971":169,"./pad-nopadding":170,"./pad-zeropadding":171,"./pbkdf2":172,"./rabbit":174,"./rabbit-legacy":173,"./rc4":175,"./ripemd160":176,"./sha1":177,"./sha224":178,"./sha256":179,"./sha3":180,"./sha384":181,"./sha512":182,"./tripledes":183,"./x64-core":184}],160:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); + (function () { + // Check if typed arrays are supported + if (typeof ArrayBuffer != 'function') { + return; + } -/** - * Colors. - */ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; + // Reference original init + var superInit = WordArray.init; -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ + // Augment WordArray.init to handle typed arrays + var subInit = WordArray.init = function (typedArray) { + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } -function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { - return true; - } + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } - // is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || - // double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); -} + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + var typedArrayByteLength = typedArray.byteLength; -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + // Extract bytes + var words = []; + for (var i = 0; i < typedArrayByteLength; i++) { + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } -exports.formatters.j = function(v) { - try { - return JSON.stringify(v); - } catch (err) { - return '[UnexpectedJSONParseError]: ' + err.message; - } -}; + // Initialize this word array + superInit.call(this, words, typedArrayByteLength); + } else { + // Else call normal init + superInit.apply(this, arguments); + } + }; + subInit.prototype = WordArray; + }()); -/** - * Colorize log arguments if enabled. - * - * @api public - */ -function formatArgs(args) { - var useColors = this.useColors; + return CryptoJS.lib.WordArray; - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); +})); +},{"./core":153}],161:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - if (!useColors) return; + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit') + // Constants table + var T = []; - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); + // Compute constants + (function () { + for (var i = 0; i < 64; i++) { + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; + } + }()); - args.splice(lastC, 0, c); -} + /** + * MD5 hash algorithm. + */ + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476 + ]); + }, -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ + _doProcessBlock: function (M, offset) { + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ + // Shortcuts + var H = this._hash.words; -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ + // Working varialbes + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} + // Computation + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); - return r; -} + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); -exports.enable(load()); + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + }, -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; -function localstorage() { - try { - return window.localStorage; - } catch (e) {} -} + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; -}).call(this,require('_process')) -},{"./debug":185,"_process":250}],185:[function(require,module,exports){ + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ + var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); + var nBitsTotalL = nBitsTotal; + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( + (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | + (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) + ); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | + (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) + ); -exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); + data.sigBytes = (dataWords.length + 1) * 4; -/** - * The currently active debug mode names, and names to skip. - */ + // Hash final blocks + this._process(); -exports.names = []; -exports.skips = []; + // Shortcuts + var hash = this._hash; + var H = hash.words; -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ + // Swap endian + for (var i = 0; i < 4; i++) { + // Shortcut + var H_i = H[i]; -exports.formatters = {}; + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } -/** - * Previous log timestamp. - */ + // Return final computed hash + return hash; + }, -var prevTime; + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); -/** - * Select a color. - * @param {String} namespace - * @return {Number} - * @api private - */ + return clone; + } + }); -function selectColor(namespace) { - var hash = 0, i; + function FF(a, b, c, d, x, s, t) { + var n = a + ((b & c) | (~b & d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } - for (i in namespace) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + function GG(a, b, c, d, x, s, t) { + var n = a + ((b & d) | (c & ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } - return exports.colors[Math.abs(hash) % exports.colors.length]; -} + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } -function createDebug(namespace) { + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.MD5('message'); + * var hash = CryptoJS.MD5(wordArray); + */ + C.MD5 = Hasher._createHelper(MD5); - function debug() { - // disabled? - if (!debug.enabled) return; + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacMD5(message, key); + */ + C.HmacMD5 = Hasher._createHmacHelper(MD5); + }(Math)); - var self = debug; - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + return CryptoJS.MD5; - // turn the `arguments` into a proper Array - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } +})); +},{"./core":153}],162:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - args[0] = exports.coerce(args[0]); + /** + * Cipher Feedback block mode. + */ + CryptoJS.mode.CFB = (function () { + var CFB = CryptoJS.lib.BlockCipherMode.extend(); - if ('string' !== typeof args[0]) { - // anything else let's inspect with %O - args.unshift('%O'); - } + CFB.Encryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); - // apply env-specific formatting (colors, etc.) - exports.formatArgs.call(self, args); + CFB.Decryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; - var logFn = debug.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); - debug.namespace = namespace; - debug.enabled = exports.enabled(namespace); - debug.useColors = exports.useColors(); - debug.color = selectColor(namespace); + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); - // env-specific initialization logic for debug instances - if ('function' === typeof exports.init) { - exports.init(debug); - } + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); - return debug; -} + function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { + // Shortcut + var iv = this._iv; -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ + // Generate keystream + if (iv) { + var keystream = iv.slice(0); -function enable(namespaces) { - exports.save(namespaces); + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + var keystream = this._prevBlock; + } + cipher.encryptBlock(keystream, 0); - exports.names = []; - exports.skips = []; + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; + return CFB; + }()); - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} -/** - * Disable debug output. - * - * @api public - */ + return CryptoJS.mode.CFB; -function disable() { - exports.enable(''); -} +})); +},{"./cipher-core":152,"./core":153}],163:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ + /** @preserve + * Counter block mode compatible with Dr Brian Gladman fileenc.c + * derived from CryptoJS.mode.CTR + * Jan Hruby jhruby.web@gmail.com + */ + CryptoJS.mode.CTRGladman = (function () { + var CTRGladman = CryptoJS.lib.BlockCipherMode.extend(); -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} + function incWord(word) + { + if (((word >> 24) & 0xff) === 0xff) { //overflow + var b1 = (word >> 16)&0xff; + var b2 = (word >> 8)&0xff; + var b3 = word & 0xff; -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ + if (b1 === 0xff) // overflow b1 + { + b1 = 0; + if (b2 === 0xff) + { + b2 = 0; + if (b3 === 0xff) + { + b3 = 0; + } + else + { + ++b3; + } + } + else + { + ++b2; + } + } + else + { + ++b1; + } -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} + word = 0; + word += (b1 << 16); + word += (b2 << 8); + word += b3; + } + else + { + word += (0x01 << 24); + } + return word; + } -},{"ms":247}],186:[function(require,module,exports){ -'use strict'; + function incCounter(counter) + { + if ((counter[0] = incWord(counter[0])) === 0) + { + // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 + counter[1] = incWord(counter[1]); + } + return counter; + } -exports.utils = require('./des/utils'); -exports.Cipher = require('./des/cipher'); -exports.DES = require('./des/des'); -exports.CBC = require('./des/cbc'); -exports.EDE = require('./des/ede'); + var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; -},{"./des/cbc":187,"./des/cipher":188,"./des/des":189,"./des/ede":190,"./des/utils":191}],187:[function(require,module,exports){ -'use strict'; + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); + // Remove IV for subsequent blocks + this._iv = undefined; + } -var proto = {}; + incCounter(counter); -function CBCState(iv) { - assert.equal(iv.length, 8, 'Invalid IV length'); + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); - this.iv = new Array(8); - for (var i = 0; i < this.iv.length; i++) - this.iv[i] = iv[i]; -} + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); -function instantiate(Base) { - function CBC(options) { - Base.call(this, options); - this._cbcInit(); - } - inherits(CBC, Base); + CTRGladman.Decryptor = Encryptor; - var keys = Object.keys(proto); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - CBC.prototype[key] = proto[key]; - } + return CTRGladman; + }()); - CBC.create = function create(options) { - return new CBC(options); - }; - return CBC; -} -exports.instantiate = instantiate; -proto._cbcInit = function _cbcInit() { - var state = new CBCState(this.options.iv); - this._cbcState = state; -}; + return CryptoJS.mode.CTRGladman; -proto._update = function _update(inp, inOff, out, outOff) { - var state = this._cbcState; - var superProto = this.constructor.super_.prototype; +})); +},{"./cipher-core":152,"./core":153}],164:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - var iv = state.iv; - if (this.type === 'encrypt') { - for (var i = 0; i < this.blockSize; i++) - iv[i] ^= inp[inOff + i]; + /** + * Counter block mode. + */ + CryptoJS.mode.CTR = (function () { + var CTR = CryptoJS.lib.BlockCipherMode.extend(); - superProto._update.call(this, iv, 0, out, outOff); + var Encryptor = CTR.Encryptor = CTR.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; - for (var i = 0; i < this.blockSize; i++) - iv[i] = out[outOff + i]; - } else { - superProto._update.call(this, inp, inOff, out, outOff); + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); - for (var i = 0; i < this.blockSize; i++) - out[outOff + i] ^= iv[i]; + // Remove IV for subsequent blocks + this._iv = undefined; + } + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); - for (var i = 0; i < this.blockSize; i++) - iv[i] = inp[inOff + i]; - } -}; + // Increment counter + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0 -},{"inherits":238,"minimalistic-assert":245}],188:[function(require,module,exports){ -'use strict'; + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); -var assert = require('minimalistic-assert'); + CTR.Decryptor = Encryptor; -function Cipher(options) { - this.options = options; + return CTR; + }()); - this.type = this.options.type; - this.blockSize = 8; - this._init(); - this.buffer = new Array(this.blockSize); - this.bufferOff = 0; -} -module.exports = Cipher; + return CryptoJS.mode.CTR; -Cipher.prototype._init = function _init() { - // Might be overrided -}; +})); +},{"./cipher-core":152,"./core":153}],165:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -Cipher.prototype.update = function update(data) { - if (data.length === 0) - return []; + /** + * Electronic Codebook block mode. + */ + CryptoJS.mode.ECB = (function () { + var ECB = CryptoJS.lib.BlockCipherMode.extend(); - if (this.type === 'decrypt') - return this._updateDecrypt(data); - else - return this._updateEncrypt(data); -}; + ECB.Encryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.encryptBlock(words, offset); + } + }); -Cipher.prototype._buffer = function _buffer(data, off) { - // Append data to buffer - var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); - for (var i = 0; i < min; i++) - this.buffer[this.bufferOff + i] = data[off + i]; - this.bufferOff += min; + ECB.Decryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.decryptBlock(words, offset); + } + }); - // Shift next - return min; -}; + return ECB; + }()); -Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { - this._update(this.buffer, 0, out, off); - this.bufferOff = 0; - return this.blockSize; -}; -Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { - var inputOff = 0; - var outputOff = 0; + return CryptoJS.mode.ECB; - var count = ((this.bufferOff + data.length) / this.blockSize) | 0; - var out = new Array(count * this.blockSize); +})); +},{"./cipher-core":152,"./core":153}],166:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - if (this.bufferOff !== 0) { - inputOff += this._buffer(data, inputOff); + /** + * Output Feedback block mode. + */ + CryptoJS.mode.OFB = (function () { + var OFB = CryptoJS.lib.BlockCipherMode.extend(); - if (this.bufferOff === this.buffer.length) - outputOff += this._flushBuffer(out, outputOff); - } + var Encryptor = OFB.Encryptor = OFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher + var blockSize = cipher.blockSize; + var iv = this._iv; + var keystream = this._keystream; - // Write blocks - var max = data.length - ((data.length - inputOff) % this.blockSize); - for (; inputOff < max; inputOff += this.blockSize) { - this._update(data, inputOff, out, outputOff); - outputOff += this.blockSize; - } + // Generate keystream + if (iv) { + keystream = this._keystream = iv.slice(0); - // Queue rest - for (; inputOff < data.length; inputOff++, this.bufferOff++) - this.buffer[this.bufferOff] = data[inputOff]; + // Remove IV for subsequent blocks + this._iv = undefined; + } + cipher.encryptBlock(keystream, 0); - return out; -}; + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); -Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { - var inputOff = 0; - var outputOff = 0; + OFB.Decryptor = Encryptor; - var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; - var out = new Array(count * this.blockSize); + return OFB; + }()); - // TODO(indutny): optimize it, this is far from optimal - for (; count > 0; count--) { - inputOff += this._buffer(data, inputOff); - outputOff += this._flushBuffer(out, outputOff); - } - // Buffer rest of the input - inputOff += this._buffer(data, inputOff); + return CryptoJS.mode.OFB; - return out; -}; +})); +},{"./cipher-core":152,"./core":153}],167:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -Cipher.prototype.final = function final(buffer) { - var first; - if (buffer) - first = this.update(buffer); + /** + * ANSI X.923 padding strategy. + */ + CryptoJS.pad.AnsiX923 = { + pad: function (data, blockSize) { + // Shortcuts + var dataSigBytes = data.sigBytes; + var blockSizeBytes = blockSize * 4; - var last; - if (this.type === 'encrypt') - last = this._finalEncrypt(); - else - last = this._finalDecrypt(); + // Count padding bytes + var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; - if (first) - return first.concat(last); - else - return last; -}; + // Compute last byte position + var lastBytePos = dataSigBytes + nPaddingBytes - 1; -Cipher.prototype._pad = function _pad(buffer, off) { - if (off === 0) - return false; + // Pad + data.clamp(); + data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); + data.sigBytes += nPaddingBytes; + }, - while (off < buffer.length) - buffer[off++] = 0; + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; - return true; -}; + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; -Cipher.prototype._finalEncrypt = function _finalEncrypt() { - if (!this._pad(this.buffer, this.bufferOff)) - return []; - var out = new Array(this.blockSize); - this._update(this.buffer, 0, out, 0); - return out; -}; + return CryptoJS.pad.Ansix923; -Cipher.prototype._unpad = function _unpad(buffer) { - return buffer; -}; +})); +},{"./cipher-core":152,"./core":153}],168:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -Cipher.prototype._finalDecrypt = function _finalDecrypt() { - assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); - var out = new Array(this.blockSize); - this._flushBuffer(out, 0); + /** + * ISO 10126 padding strategy. + */ + CryptoJS.pad.Iso10126 = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; - return this._unpad(out); -}; + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; -},{"minimalistic-assert":245}],189:[function(require,module,exports){ -'use strict'; + // Pad + data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)). + concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1)); + }, -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; -var des = require('../des'); -var utils = des.utils; -var Cipher = des.Cipher; + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; -function DESState() { - this.tmp = new Array(2); - this.keys = null; -} -function DES(options) { - Cipher.call(this, options); + return CryptoJS.pad.Iso10126; - var state = new DESState(); - this._desState = state; +})); +},{"./cipher-core":152,"./core":153}],169:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - this.deriveKeys(state, options.key); -} -inherits(DES, Cipher); -module.exports = DES; + /** + * ISO/IEC 9797-1 Padding Method 2. + */ + CryptoJS.pad.Iso97971 = { + pad: function (data, blockSize) { + // Add 0x80 byte + data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1)); -DES.create = function create(options) { - return new DES(options); -}; + // Zero pad the rest + CryptoJS.pad.ZeroPadding.pad(data, blockSize); + }, -var shiftTable = [ - 1, 1, 2, 2, 2, 2, 2, 2, - 1, 2, 2, 2, 2, 2, 2, 1 -]; + unpad: function (data) { + // Remove zero padding + CryptoJS.pad.ZeroPadding.unpad(data); -DES.prototype.deriveKeys = function deriveKeys(state, key) { - state.keys = new Array(16 * 2); + // Remove one more byte -- the 0x80 byte + data.sigBytes--; + } + }; - assert.equal(key.length, this.blockSize, 'Invalid key length'); - var kL = utils.readUInt32BE(key, 0); - var kR = utils.readUInt32BE(key, 4); + return CryptoJS.pad.Iso97971; - utils.pc1(kL, kR, state.tmp, 0); - kL = state.tmp[0]; - kR = state.tmp[1]; - for (var i = 0; i < state.keys.length; i += 2) { - var shift = shiftTable[i >>> 1]; - kL = utils.r28shl(kL, shift); - kR = utils.r28shl(kR, shift); - utils.pc2(kL, kR, state.keys, i); - } -}; +})); +},{"./cipher-core":152,"./core":153}],170:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -DES.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._desState; + /** + * A noop padding strategy. + */ + CryptoJS.pad.NoPadding = { + pad: function () { + }, - var l = utils.readUInt32BE(inp, inOff); - var r = utils.readUInt32BE(inp, inOff + 4); + unpad: function () { + } + }; - // Initial Permutation - utils.ip(l, r, state.tmp, 0); - l = state.tmp[0]; - r = state.tmp[1]; - if (this.type === 'encrypt') - this._encrypt(state, l, r, state.tmp, 0); - else - this._decrypt(state, l, r, state.tmp, 0); + return CryptoJS.pad.NoPadding; - l = state.tmp[0]; - r = state.tmp[1]; +})); +},{"./cipher-core":152,"./core":153}],171:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - utils.writeUInt32BE(out, l, outOff); - utils.writeUInt32BE(out, r, outOff + 4); -}; + /** + * Zero padding strategy. + */ + CryptoJS.pad.ZeroPadding = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; -DES.prototype._pad = function _pad(buffer, off) { - var value = buffer.length - off; - for (var i = off; i < buffer.length; i++) - buffer[i] = value; + // Pad + data.clamp(); + data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); + }, - return true; -}; + unpad: function (data) { + // Shortcut + var dataWords = data.words; -DES.prototype._unpad = function _unpad(buffer) { - var pad = buffer[buffer.length - 1]; - for (var i = buffer.length - pad; i < buffer.length; i++) - assert.equal(buffer[i], pad); + // Unpad + var i = data.sigBytes - 1; + while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { + i--; + } + data.sigBytes = i + 1; + } + }; - return buffer.slice(0, buffer.length - pad); -}; -DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { - var l = lStart; - var r = rStart; + return CryptoJS.pad.ZeroPadding; - // Apply f() x16 times - for (var i = 0; i < state.keys.length; i += 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; +})); +},{"./cipher-core":152,"./core":153}],172:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./sha1", "./hmac"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - // f(r, k) - utils.expand(r, state.tmp, 0); + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA1 = C_algo.SHA1; + var HMAC = C_algo.HMAC; - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); + /** + * Password-Based Key Derivation Function 2 algorithm. + */ + var PBKDF2 = C_algo.PBKDF2 = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hasher to use. Default: SHA1 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128/32, + hasher: SHA1, + iterations: 1 + }), - var t = r; - r = (l ^ f) >>> 0; - l = t; - } + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.PBKDF2.create(); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); + */ + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, - // Reverse Initial Permutation - utils.rip(r, l, out, off); -}; + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function (password, salt) { + // Shortcut + var cfg = this.cfg; -DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { - var l = rStart; - var r = lStart; + // Init HMAC + var hmac = HMAC.create(cfg.hasher, password); - // Apply f() x16 times - for (var i = state.keys.length - 2; i >= 0; i -= 2) { - var keyL = state.keys[i]; - var keyR = state.keys[i + 1]; + // Initial values + var derivedKey = WordArray.create(); + var blockIndex = WordArray.create([0x00000001]); - // f(r, k) - utils.expand(l, state.tmp, 0); + // Shortcuts + var derivedKeyWords = derivedKey.words; + var blockIndexWords = blockIndex.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; - keyL ^= state.tmp[0]; - keyR ^= state.tmp[1]; - var s = utils.substitute(keyL, keyR); - var f = utils.permute(s); + // Generate key + while (derivedKeyWords.length < keySize) { + var block = hmac.update(salt).finalize(blockIndex); + hmac.reset(); - var t = l; - l = (r ^ f) >>> 0; - r = t; - } + // Shortcuts + var blockWords = block.words; + var blockWordsLength = blockWords.length; - // Reverse Initial Permutation - utils.rip(l, r, out, off); -}; + // Iterations + var intermediate = block; + for (var i = 1; i < iterations; i++) { + intermediate = hmac.finalize(intermediate); + hmac.reset(); -},{"../des":186,"inherits":238,"minimalistic-assert":245}],190:[function(require,module,exports){ -'use strict'; + // Shortcut + var intermediateWords = intermediate.words; -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); + // XOR intermediate with block + for (var j = 0; j < blockWordsLength; j++) { + blockWords[j] ^= intermediateWords[j]; + } + } -var des = require('../des'); -var Cipher = des.Cipher; -var DES = des.DES; + derivedKey.concat(block); + blockIndexWords[0]++; + } + derivedKey.sigBytes = keySize * 4; -function EDEState(type, key) { - assert.equal(key.length, 24, 'Invalid key length'); + return derivedKey; + } + }); - var k1 = key.slice(0, 8); - var k2 = key.slice(8, 16); - var k3 = key.slice(16, 24); + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.PBKDF2(password, salt); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.PBKDF2 = function (password, salt, cfg) { + return PBKDF2.create(cfg).compute(password, salt); + }; + }()); - if (type === 'encrypt') { - this.ciphers = [ - DES.create({ type: 'encrypt', key: k1 }), - DES.create({ type: 'decrypt', key: k2 }), - DES.create({ type: 'encrypt', key: k3 }) - ]; - } else { - this.ciphers = [ - DES.create({ type: 'decrypt', key: k3 }), - DES.create({ type: 'encrypt', key: k2 }), - DES.create({ type: 'decrypt', key: k1 }) - ]; - } -} -function EDE(options) { - Cipher.call(this, options); + return CryptoJS.PBKDF2; - var state = new EDEState(this.type, this.options.key); - this._edeState = state; -} -inherits(EDE, Cipher); +})); +},{"./core":153,"./hmac":158,"./sha1":177}],173:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -module.exports = EDE; + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; -EDE.create = function create(options) { - return new EDE(options); -}; + // Reusable objects + var S = []; + var C_ = []; + var G = []; -EDE.prototype._update = function _update(inp, inOff, out, outOff) { - var state = this._edeState; + /** + * Rabbit stream cipher algorithm. + * + * This is a legacy version that neglected to convert the key to little-endian. + * This error doesn't affect the cipher's security, + * but it does affect its compatibility with other implementations. + */ + var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; - state.ciphers[0]._update(inp, inOff, out, outOff); - state.ciphers[1]._update(out, outOff, out, outOff); - state.ciphers[2]._update(out, outOff, out, outOff); -}; + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; -EDE.prototype._pad = DES.prototype._pad; -EDE.prototype._unpad = DES.prototype._unpad; + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; -},{"../des":186,"inherits":238,"minimalistic-assert":245}],191:[function(require,module,exports){ -'use strict'; + // Carry bit + this._b = 0; -exports.readUInt32BE = function readUInt32BE(bytes, off) { - var res = (bytes[0 + off] << 24) | - (bytes[1 + off] << 16) | - (bytes[2 + off] << 8) | - bytes[3 + off]; - return res >>> 0; -}; + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } -exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { - bytes[0 + off] = value >>> 24; - bytes[1 + off] = (value >>> 16) & 0xff; - bytes[2 + off] = (value >>> 8) & 0xff; - bytes[3 + off] = value & 0xff; -}; + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } -exports.ip = function ip(inL, inR, out, off) { - var outL = 0; - var outR = 0; + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; - for (var i = 6; i >= 0; i -= 2) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); - for (var i = 6; i >= 0; i -= 2) { - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - } - for (var j = 1; j <= 25; j += 8) { - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, -exports.rip = function rip(inL, inR, out, off) { - var outL = 0; - var outR = 0; + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; - for (var i = 0; i < 4; i++) { - for (var j = 24; j >= 0; j -= 8) { - outL <<= 1; - outL |= (inR >>> (j + i)) & 1; - outL <<= 1; - outL |= (inL >>> (j + i)) & 1; - } - } - for (var i = 4; i < 8; i++) { - for (var j = 24; j >= 0; j -= 8) { - outR <<= 1; - outR |= (inR >>> (j + i)) & 1; - outR <<= 1; - outR |= (inL >>> (j + i)) & 1; - } - } + // Iterate the system + nextState.call(this); - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); -exports.pc1 = function pc1(inL, inR, out, off) { - var outL = 0; - var outR = 0; + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); - // 7, 15, 23, 31, 39, 47, 55, 63 - // 6, 14, 22, 30, 39, 47, 55, 63 - // 5, 13, 21, 29, 39, 47, 55, 63 - // 4, 12, 20, 28 - for (var i = 7; i >= 5; i--) { - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outL <<= 1; - outL |= (inR >> (j + i)) & 1; - } - - // 1, 9, 17, 25, 33, 41, 49, 57 - // 2, 10, 18, 26, 34, 42, 50, 58 - // 3, 11, 19, 27, 35, 43, 51, 59 - // 36, 44, 52, 60 - for (var i = 1; i <= 3; i++) { - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inR >> (j + i)) & 1; - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } - } - for (var j = 0; j <= 24; j += 8) { - outR <<= 1; - outR |= (inL >> (j + i)) & 1; - } + // Encrypt + M[offset + i] ^= S[i]; + } + }, - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + blockSize: 128/32, -exports.r28shl = function r28shl(num, shift) { - return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); -}; + ivSize: 64/32 + }); -var pc2table = [ - // inL => outL - 14, 11, 17, 4, 27, 23, 25, 0, - 13, 22, 7, 18, 5, 9, 16, 24, - 2, 20, 12, 21, 1, 8, 15, 26, + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; - // inR => outR - 15, 4, 25, 19, 9, 1, 26, 16, - 5, 11, 23, 8, 12, 7, 17, 0, - 22, 3, 10, 14, 6, 20, 27, 24 -]; + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } -exports.pc2 = function pc2(inL, inR, out, off) { - var outL = 0; - var outR = 0; + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; - var len = pc2table.length >>> 1; - for (var i = 0; i < len; i++) { - outL <<= 1; - outL |= (inL >>> pc2table[i]) & 0x1; - } - for (var i = len; i < pc2table.length; i++) { - outR <<= 1; - outR |= (inR >>> pc2table[i]) & 0x1; - } + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; -exports.expand = function expand(r, out, off) { - var outL = 0; - var outR = 0; + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); - outL = ((r & 1) << 5) | (r >>> 27); - for (var i = 23; i >= 15; i -= 4) { - outL <<= 6; - outL |= (r >>> i) & 0x3f; - } - for (var i = 11; i >= 3; i -= 4) { - outR |= (r >>> i) & 0x3f; - outR <<= 6; - } - outR |= ((r & 0x1f) << 1) | (r >>> 31); + // High XOR low + G[i] = gh ^ gl; + } - out[off + 0] = outL >>> 0; - out[off + 1] = outR >>> 0; -}; + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } -var sTable = [ - 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, - 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, - 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, - 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); + */ + C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy); + }()); - 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, - 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, - 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, - 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, - 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, - 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, - 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, - 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, + return CryptoJS.RabbitLegacy; - 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, - 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, - 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, - 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, +})); +},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],174:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, - 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, - 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, - 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; - 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, - 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, - 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, - 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, + // Reusable objects + var S = []; + var C_ = []; + var G = []; - 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, - 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, - 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, - 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, + /** + * Rabbit stream cipher algorithm + */ + var Rabbit = C_algo.Rabbit = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; - 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, - 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, - 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, - 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 -]; + // Swap endian + for (var i = 0; i < 4; i++) { + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | + (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); + } -exports.substitute = function substitute(inL, inR) { - var out = 0; - for (var i = 0; i < 4; i++) { - var b = (inL >>> (18 - i * 6)) & 0x3f; - var sb = sTable[i * 0x40 + b]; + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; - out <<= 4; - out |= sb; - } - for (var i = 0; i < 4; i++) { - var b = (inR >>> (18 - i * 6)) & 0x3f; - var sb = sTable[4 * 0x40 + i * 0x40 + b]; + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; - out <<= 4; - out |= sb; - } - return out >>> 0; -}; + // Carry bit + this._b = 0; -var permuteTable = [ - 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, - 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 -]; + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } -exports.permute = function permute(num) { - var out = 0; - for (var i = 0; i < permuteTable.length; i++) { - out <<= 1; - out |= (num >>> permuteTable[i]) & 0x1; - } - return out >>> 0; -}; + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } -exports.padSplit = function padSplit(num, size, group) { - var str = num.toString(2); - while (str.length < size) - str = '0' + str; + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; - var out = []; - for (var i = 0; i < size; i += group) - out.push(str.slice(i, i + group)); - return out.join(' '); -}; + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); -},{}],192:[function(require,module,exports){ -(function (Buffer){ -var generatePrime = require('./lib/generatePrime') -var primes = require('./lib/primes.json') + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; -var DH = require('./lib/dh') + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, -function getDiffieHellman (mod) { - var prime = new Buffer(primes[mod].prime, 'hex') - var gen = new Buffer(primes[mod].gen, 'hex') + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; - return new DH(prime, gen) -} + // Iterate the system + nextState.call(this); -var ENCODINGS = { - 'binary': true, 'hex': true, 'base64': true -} + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); -function createDiffieHellman (prime, enc, generator, genc) { - if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { - return createDiffieHellman(prime, 'binary', enc, generator) - } + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); - enc = enc || 'binary' - genc = genc || 'binary' - generator = generator || new Buffer([2]) + // Encrypt + M[offset + i] ^= S[i]; + } + }, - if (!Buffer.isBuffer(generator)) { - generator = new Buffer(generator, genc) - } + blockSize: 128/32, - if (typeof prime === 'number') { - return new DH(generatePrime(prime, generator), generator, true) - } + ivSize: 64/32 + }); - if (!Buffer.isBuffer(prime)) { - prime = new Buffer(prime, enc) - } + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; - return new DH(prime, generator, true) -} + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } -exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman -exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; -}).call(this,require("buffer").Buffer) -},{"./lib/dh":193,"./lib/generatePrime":194,"./lib/primes.json":195,"buffer":111}],193:[function(require,module,exports){ -(function (Buffer){ -var BN = require('bn.js'); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var TWENTYFOUR = new BN(24); -var ELEVEN = new BN(11); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var primes = require('./generatePrime'); -var randomBytes = require('randombytes'); -module.exports = DH; + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; -function setPublicKey(pub, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(pub)) { - pub = new Buffer(pub, enc); - } - this._pub = new BN(pub); - return this; -} + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; -function setPrivateKey(priv, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(priv)) { - priv = new Buffer(priv, enc); - } - this._priv = new BN(priv); - return this; -} + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); -var primeCache = {}; -function checkPrime(prime, generator) { - var gen = generator.toString('hex'); - var hex = [gen, prime.toString(16)].join('_'); - if (hex in primeCache) { - return primeCache[hex]; - } - var error = 0; + // High XOR low + G[i] = gh ^ gl; + } - if (prime.isEven() || - !primes.simpleSieve || - !primes.fermatTest(prime) || - !millerRabin.test(prime)) { - //not a prime so +1 - error += 1; + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } - if (gen === '02' || gen === '05') { - // we'd be able to check the generator - // it would fail so +8 - error += 8; - } else { - //we wouldn't be able to test the generator - // so +4 - error += 4; - } - primeCache[hex] = error; - return error; - } - if (!millerRabin.test(prime.shrn(1))) { - //not a safe prime - error += 2; - } - var rem; - switch (gen) { - case '02': - if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { - // unsuidable generator - error += 8; - } - break; - case '05': - rem = prime.mod(TEN); - if (rem.cmp(THREE) && rem.cmp(SEVEN)) { - // prime mod 10 needs to equal 3 or 7 - error += 8; - } - break; - default: - error += 4; - } - primeCache[hex] = error; - return error; -} + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); + */ + C.Rabbit = StreamCipher._createHelper(Rabbit); + }()); -function DH(prime, generator, malleable) { - this.setGenerator(generator); - this.__prime = new BN(prime); - this._prime = BN.mont(this.__prime); - this._primeLen = prime.length; - this._pub = undefined; - this._priv = undefined; - this._primeCode = undefined; - if (malleable) { - this.setPublicKey = setPublicKey; - this.setPrivateKey = setPrivateKey; - } else { - this._primeCode = 8; - } -} -Object.defineProperty(DH.prototype, 'verifyError', { - enumerable: true, - get: function () { - if (typeof this._primeCode !== 'number') { - this._primeCode = checkPrime(this.__prime, this.__gen); - } - return this._primeCode; - } -}); -DH.prototype.generateKeys = function () { - if (!this._priv) { - this._priv = new BN(randomBytes(this._primeLen)); - } - this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); - return this.getPublicKey(); -}; -DH.prototype.computeSecret = function (other) { - other = new BN(other); - other = other.toRed(this._prime); - var secret = other.redPow(this._priv).fromRed(); - var out = new Buffer(secret.toArray()); - var prime = this.getPrime(); - if (out.length < prime.length) { - var front = new Buffer(prime.length - out.length); - front.fill(0); - out = Buffer.concat([front, out]); - } - return out; -}; + return CryptoJS.Rabbit; -DH.prototype.getPublicKey = function getPublicKey(enc) { - return formatReturnValue(this._pub, enc); -}; - -DH.prototype.getPrivateKey = function getPrivateKey(enc) { - return formatReturnValue(this._priv, enc); -}; +})); +},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],175:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -DH.prototype.getPrime = function (enc) { - return formatReturnValue(this.__prime, enc); -}; + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; -DH.prototype.getGenerator = function (enc) { - return formatReturnValue(this._gen, enc); -}; + /** + * RC4 stream cipher algorithm. + */ + var RC4 = C_algo.RC4 = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + var keySigBytes = key.sigBytes; -DH.prototype.setGenerator = function (gen, enc) { - enc = enc || 'utf8'; - if (!Buffer.isBuffer(gen)) { - gen = new Buffer(gen, enc); - } - this.__gen = gen; - this._gen = new BN(gen); - return this; -}; + // Init sbox + var S = this._S = []; + for (var i = 0; i < 256; i++) { + S[i] = i; + } -function formatReturnValue(bn, enc) { - var buf = new Buffer(bn.toArray()); - if (!enc) { - return buf; - } else { - return buf.toString(enc); - } -} + // Key setup + for (var i = 0, j = 0; i < 256; i++) { + var keyByteIndex = i % keySigBytes; + var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; -}).call(this,require("buffer").Buffer) -},{"./generatePrime":194,"bn.js":82,"buffer":111,"miller-rabin":244,"randombytes":282}],194:[function(require,module,exports){ -var randomBytes = require('randombytes'); -module.exports = findPrime; -findPrime.simpleSieve = simpleSieve; -findPrime.fermatTest = fermatTest; -var BN = require('bn.js'); -var TWENTYFOUR = new BN(24); -var MillerRabin = require('miller-rabin'); -var millerRabin = new MillerRabin(); -var ONE = new BN(1); -var TWO = new BN(2); -var FIVE = new BN(5); -var SIXTEEN = new BN(16); -var EIGHT = new BN(8); -var TEN = new BN(10); -var THREE = new BN(3); -var SEVEN = new BN(7); -var ELEVEN = new BN(11); -var FOUR = new BN(4); -var TWELVE = new BN(12); -var primes = null; + j = (j + S[i] + keyByte) % 256; -function _getPrimes() { - if (primes !== null) - return primes; + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; + } - var limit = 0x100000; - var res = []; - res[0] = 2; - for (var i = 1, k = 3; k < limit; k += 2) { - var sqrt = Math.ceil(Math.sqrt(k)); - for (var j = 0; j < i && res[j] <= sqrt; j++) - if (k % res[j] === 0) - break; + // Counters + this._i = this._j = 0; + }, - if (i !== j && res[j] <= sqrt) - continue; + _doProcessBlock: function (M, offset) { + M[offset] ^= generateKeystreamWord.call(this); + }, - res[i++] = k; - } - primes = res; - return res; -} + keySize: 256/32, -function simpleSieve(p) { - var primes = _getPrimes(); + ivSize: 0 + }); - for (var i = 0; i < primes.length; i++) - if (p.modn(primes[i]) === 0) { - if (p.cmpn(primes[i]) === 0) { - return true; - } else { - return false; - } - } + function generateKeystreamWord() { + // Shortcuts + var S = this._S; + var i = this._i; + var j = this._j; - return true; -} + // Generate keystream word + var keystreamWord = 0; + for (var n = 0; n < 4; n++) { + i = (i + 1) % 256; + j = (j + S[i]) % 256; -function fermatTest(p) { - var red = BN.mont(p); - return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; -} + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; -function findPrime(bits, gen) { - if (bits < 16) { - // this is what openssl does - if (gen === 2 || gen === 5) { - return new BN([0x8c, 0x7b]); - } else { - return new BN([0x8c, 0x27]); - } - } - gen = new BN(gen); + keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); + } - var num, n2; + // Update counters + this._i = i; + this._j = j; - while (true) { - num = new BN(randomBytes(Math.ceil(bits / 8))); - while (num.bitLength() > bits) { - num.ishrn(1); - } - if (num.isEven()) { - num.iadd(ONE); - } - if (!num.testn(1)) { - num.iadd(TWO); - } - if (!gen.cmp(TWO)) { - while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { - num.iadd(FOUR); - } - } else if (!gen.cmp(FIVE)) { - while (num.mod(TEN).cmp(THREE)) { - num.iadd(FOUR); - } - } - n2 = num.shrn(1); - if (simpleSieve(n2) && simpleSieve(num) && - fermatTest(n2) && fermatTest(num) && - millerRabin.test(n2) && millerRabin.test(num)) { - return num; - } - } + return keystreamWord; + } -} + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); + */ + C.RC4 = StreamCipher._createHelper(RC4); -},{"bn.js":82,"miller-rabin":244,"randombytes":282}],195:[function(require,module,exports){ -module.exports={ - "modp1": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" - }, - "modp2": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" - }, - "modp5": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" - }, - "modp14": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" - }, - "modp15": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" - }, - "modp16": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" - }, - "modp17": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" - }, - "modp18": { - "gen": "02", - "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" - } -} -},{}],196:[function(require,module,exports){ -var assert = require('assert') -var BigInteger = require('bigi') + /** + * Modified RC4 stream cipher algorithm. + */ + var RC4Drop = C_algo.RC4Drop = RC4.extend({ + /** + * Configuration options. + * + * @property {number} drop The number of keystream words to drop. Default 192 + */ + cfg: RC4.cfg.extend({ + drop: 192 + }), -var Point = require('./point') + _doReset: function () { + RC4._doReset.call(this); -function Curve (p, a, b, Gx, Gy, n, h) { - this.p = p - this.a = a - this.b = b - this.G = Point.fromAffine(this, Gx, Gy) - this.n = n - this.h = h + // Drop + for (var i = this.cfg.drop; i > 0; i--) { + generateKeystreamWord.call(this); + } + } + }); - this.infinity = new Point(this, null, null, BigInteger.ZERO) + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); + */ + C.RC4Drop = StreamCipher._createHelper(RC4Drop); + }()); - // result caching - this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) - // determine size of p in bytes - this.pLength = Math.floor((this.p.bitLength() + 7) / 8) -} + return CryptoJS.RC4; -Curve.prototype.pointFromX = function (isOdd, x) { - var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) - var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves +})); +},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],176:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - var y = beta - if (beta.isEven() ^ !isOdd) { - y = this.p.subtract(y) // -y % p - } + /** @preserve + (c) 2012 by Cédric Mesnil. All rights reserved. - return Point.fromAffine(this, x, y) -} + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -Curve.prototype.isInfinity = function (Q) { - if (Q === this.infinity) return true + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - return Q.z.signum() === 0 && Q.y.signum() !== 0 -} + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ -Curve.prototype.isOnCurve = function (Q) { - if (this.isInfinity(Q)) return true + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; - var x = Q.affineX - var y = Q.affineY - var a = this.a - var b = this.b - var p = this.p + // Constants table + var _zl = WordArray.create([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); + var _zr = WordArray.create([ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); + var _sl = WordArray.create([ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]); + var _sr = WordArray.create([ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]); - // Check that xQ and yQ are integers in the interval [0, p - 1] - if (x.signum() < 0 || x.compareTo(p) >= 0) return false - if (y.signum() < 0 || y.compareTo(p) >= 0) return false + var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); + var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); - // and check that y^2 = x^3 + ax + b (mod p) - var lhs = y.square().mod(p) - var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) - return lhs.equals(rhs) -} + /** + * RIPEMD160 hash algorithm. + */ + var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ + _doReset: function () { + this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); + }, -/** - * Validate an elliptic curve point. - * - * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive - */ -Curve.prototype.validate = function (Q) { - // Check Q != O - assert(!this.isInfinity(Q), 'Point is at infinity') - assert(this.isOnCurve(Q), 'Point is not on the curve') + _doProcessBlock: function (M, offset) { - // Check nQ = O (where Q is a scalar multiple of G) - var nQ = Q.multiply(this.n) - assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; - return true -} + // Swap + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + // Shortcut + var H = this._hash.words; + var hl = _hl.words; + var hr = _hr.words; + var zl = _zl.words; + var zr = _zr.words; + var sl = _sl.words; + var sr = _sr.words; -module.exports = Curve + // Working variables + var al, bl, cl, dl, el; + var ar, br, cr, dr, er; -},{"./point":200,"assert":23,"bigi":32}],197:[function(require,module,exports){ -module.exports={ - "secp128r1": { - "p": "fffffffdffffffffffffffffffffffff", - "a": "fffffffdfffffffffffffffffffffffc", - "b": "e87579c11079f43dd824993c2cee5ed3", - "n": "fffffffe0000000075a30d1b9038a115", - "h": "01", - "Gx": "161ff7528b899b2d0c28607ca52c5b86", - "Gy": "cf5ac8395bafeb13c02da292dded7a83" - }, - "secp160k1": { - "p": "fffffffffffffffffffffffffffffffeffffac73", - "a": "00", - "b": "07", - "n": "0100000000000000000001b8fa16dfab9aca16b6b3", - "h": "01", - "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", - "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" - }, - "secp160r1": { - "p": "ffffffffffffffffffffffffffffffff7fffffff", - "a": "ffffffffffffffffffffffffffffffff7ffffffc", - "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", - "n": "0100000000000000000001f4c8f927aed3ca752257", - "h": "01", - "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", - "Gy": "23a628553168947d59dcc912042351377ac5fb32" - }, - "secp192k1": { - "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", - "a": "00", - "b": "03", - "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", - "h": "01", - "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", - "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" - }, - "secp192r1": { - "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", - "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", - "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", - "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", - "h": "01", - "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", - "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" - }, - "secp256k1": { - "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", - "a": "00", - "b": "07", - "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", - "h": "01", - "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" - }, - "secp256r1": { - "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", - "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", - "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", - "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", - "h": "01", - "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", - "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" - } -} + ar = al = H[0]; + br = bl = H[1]; + cr = cl = H[2]; + dr = dl = H[3]; + er = el = H[4]; + // Computation + var t; + for (var i = 0; i < 80; i += 1) { + t = (al + M[offset+zl[i]])|0; + if (i<16){ + t += f1(bl,cl,dl) + hl[0]; + } else if (i<32) { + t += f2(bl,cl,dl) + hl[1]; + } else if (i<48) { + t += f3(bl,cl,dl) + hl[2]; + } else if (i<64) { + t += f4(bl,cl,dl) + hl[3]; + } else {// if (i<80) { + t += f5(bl,cl,dl) + hl[4]; + } + t = t|0; + t = rotl(t,sl[i]); + t = (t+el)|0; + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = t; -},{}],198:[function(require,module,exports){ -var Point = require('./point') -var Curve = require('./curve') - -var getCurveByName = require('./names') - -module.exports = { - Curve: Curve, - Point: Point, - getCurveByName: getCurveByName -} + t = (ar + M[offset+zr[i]])|0; + if (i<16){ + t += f5(br,cr,dr) + hr[0]; + } else if (i<32) { + t += f4(br,cr,dr) + hr[1]; + } else if (i<48) { + t += f3(br,cr,dr) + hr[2]; + } else if (i<64) { + t += f2(br,cr,dr) + hr[3]; + } else {// if (i<80) { + t += f1(br,cr,dr) + hr[4]; + } + t = t|0; + t = rotl(t,sr[i]) ; + t = (t+er)|0; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = t; + } + // Intermediate hash value + t = (H[1] + cl + dr)|0; + H[1] = (H[2] + dl + er)|0; + H[2] = (H[3] + el + ar)|0; + H[3] = (H[4] + al + br)|0; + H[4] = (H[0] + bl + cr)|0; + H[0] = t; + }, -},{"./curve":196,"./names":199,"./point":200}],199:[function(require,module,exports){ -var BigInteger = require('bigi') + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; -var curves = require('./curves.json') -var Curve = require('./curve') + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; -function getCurveByName (name) { - var curve = curves[name] - if (!curve) return null + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | + (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) + ); + data.sigBytes = (dataWords.length + 1) * 4; - var p = new BigInteger(curve.p, 16) - var a = new BigInteger(curve.a, 16) - var b = new BigInteger(curve.b, 16) - var n = new BigInteger(curve.n, 16) - var h = new BigInteger(curve.h, 16) - var Gx = new BigInteger(curve.Gx, 16) - var Gy = new BigInteger(curve.Gy, 16) + // Hash final blocks + this._process(); - return new Curve(p, a, b, Gx, Gy, n, h) -} + // Shortcuts + var hash = this._hash; + var H = hash.words; -module.exports = getCurveByName + // Swap endian + for (var i = 0; i < 5; i++) { + // Shortcut + var H_i = H[i]; -},{"./curve":196,"./curves.json":197,"bigi":32}],200:[function(require,module,exports){ -var assert = require('assert') -var Buffer = require('safe-buffer').Buffer -var BigInteger = require('bigi') + // Swap + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } -var THREE = BigInteger.valueOf(3) + // Return final computed hash + return hash; + }, -function Point (curve, x, y, z) { - assert.notStrictEqual(z, undefined, 'Missing Z coordinate') + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); - this.curve = curve - this.x = x - this.y = y - this.z = z - this._zInv = null + return clone; + } + }); - this.compressed = true -} -Object.defineProperty(Point.prototype, 'zInv', { - get: function () { - if (this._zInv === null) { - this._zInv = this.z.modInverse(this.curve.p) - } + function f1(x, y, z) { + return ((x) ^ (y) ^ (z)); - return this._zInv - } -}) + } -Object.defineProperty(Point.prototype, 'affineX', { - get: function () { - return this.x.multiply(this.zInv).mod(this.curve.p) - } -}) + function f2(x, y, z) { + return (((x)&(y)) | ((~x)&(z))); + } -Object.defineProperty(Point.prototype, 'affineY', { - get: function () { - return this.y.multiply(this.zInv).mod(this.curve.p) - } -}) + function f3(x, y, z) { + return (((x) | (~(y))) ^ (z)); + } -Point.fromAffine = function (curve, x, y) { - return new Point(curve, x, y, BigInteger.ONE) -} + function f4(x, y, z) { + return (((x) & (z)) | ((y)&(~(z)))); + } -Point.prototype.equals = function (other) { - if (other === this) return true - if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) - if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) + function f5(x, y, z) { + return ((x) ^ ((y) |(~(z)))); - // u = Y2 * Z1 - Y1 * Z2 - var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) + } - if (u.signum() !== 0) return false + function rotl(x,n) { + return (x<>>(32-n)); + } - // v = X2 * Z1 - X1 * Z2 - var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) - return v.signum() === 0 -} + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.RIPEMD160('message'); + * var hash = CryptoJS.RIPEMD160(wordArray); + */ + C.RIPEMD160 = Hasher._createHelper(RIPEMD160); -Point.prototype.negate = function () { - var y = this.curve.p.subtract(this.y) + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacRIPEMD160(message, key); + */ + C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); + }(Math)); - return new Point(this.curve, this.x, y, this.z) -} -Point.prototype.add = function (b) { - if (this.curve.isInfinity(this)) return b - if (this.curve.isInfinity(b)) return this + return CryptoJS.RIPEMD160; - var x1 = this.x - var y1 = this.y - var x2 = b.x - var y2 = b.y +})); +},{"./core":153}],177:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - // u = Y2 * Z1 - Y1 * Z2 - var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) - // v = X2 * Z1 - X1 * Z2 - var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; - if (v.signum() === 0) { - if (u.signum() === 0) { - return this.twice() // this == b, so double - } + // Reusable object + var W = []; - return this.curve.infinity // this = -b, so infinity - } + /** + * SHA-1 hash algorithm. + */ + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476, + 0xc3d2e1f0 + ]); + }, - var v2 = v.square() - var v3 = v2.multiply(v) - var x1v2 = x1.multiply(v2) - var zu2 = u.square().multiply(this.z) + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; - // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) - var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) - // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 - var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) - // z3 = v^3 * z1 * z2 - var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; - return new Point(this.curve, x3, y3, z3) -} + // Computation + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = (n << 1) | (n >>> 31); + } -Point.prototype.twice = function () { - if (this.curve.isInfinity(this)) return this - if (this.y.signum() === 0) return this.curve.infinity + var t = ((a << 5) | (a >>> 27)) + e + W[i]; + if (i < 20) { + t += ((b & c) | (~b & d)) + 0x5a827999; + } else if (i < 40) { + t += (b ^ c ^ d) + 0x6ed9eba1; + } else if (i < 60) { + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; + } else /* if (i < 80) */ { + t += (b ^ c ^ d) - 0x359d3e2a; + } - var x1 = this.x - var y1 = this.y + e = d; + d = c; + c = (b << 30) | (b >>> 2); + b = a; + a = t; + } - var y1z1 = y1.multiply(this.z).mod(this.curve.p) - var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) - var a = this.curve.a + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + }, - // w = 3 * x1^2 + a * z1^2 - var w = x1.square().multiply(THREE) + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; - if (a.signum() !== 0) { - w = w.add(this.z.square().multiply(a)) - } + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; - w = w.mod(this.curve.p) - // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) - var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) - // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 - var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) - // z3 = 8 * (y1 * z1)^3 - var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; - return new Point(this.curve, x3, y3, z3) -} + // Hash final blocks + this._process(); -// Simple NAF (Non-Adjacent Form) multiplication algorithm -// TODO: modularize the multiplication algorithm -Point.prototype.multiply = function (k) { - if (this.curve.isInfinity(this)) return this - if (k.signum() === 0) return this.curve.infinity + // Return final computed hash + return this._hash; + }, - var e = k - var h = e.multiply(THREE) + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); - var neg = this.negate() - var R = this + return clone; + } + }); - for (var i = h.bitLength() - 2; i > 0; --i) { - var hBit = h.testBit(i) - var eBit = e.testBit(i) + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA1('message'); + * var hash = CryptoJS.SHA1(wordArray); + */ + C.SHA1 = Hasher._createHelper(SHA1); - R = R.twice() + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA1(message, key); + */ + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + }()); - if (hBit !== eBit) { - R = R.add(hBit ? this : neg) - } - } - return R -} + return CryptoJS.SHA1; -// Compute this*j + x*k (simultaneous multiplication) -Point.prototype.multiplyTwo = function (j, x, k) { - var i = Math.max(j.bitLength(), k.bitLength()) - 1 - var R = this.curve.infinity - var both = this.add(x) +})); +},{"./core":153}],178:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./sha256")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./sha256"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - while (i >= 0) { - var jBit = j.testBit(i) - var kBit = k.testBit(i) + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA256 = C_algo.SHA256; - R = R.twice() + /** + * SHA-224 hash algorithm. + */ + var SHA224 = C_algo.SHA224 = SHA256.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 + ]); + }, - if (jBit) { - if (kBit) { - R = R.add(both) - } else { - R = R.add(this) - } - } else if (kBit) { - R = R.add(x) - } - --i - } + _doFinalize: function () { + var hash = SHA256._doFinalize.call(this); - return R -} + hash.sigBytes -= 4; -Point.prototype.getEncoded = function (compressed) { - if (compressed == null) compressed = this.compressed - if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' + return hash; + } + }); - var x = this.affineX - var y = this.affineY - var byteLength = this.curve.pLength - var buffer + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA224('message'); + * var hash = CryptoJS.SHA224(wordArray); + */ + C.SHA224 = SHA256._createHelper(SHA224); - // 0x02/0x03 | X - if (compressed) { - buffer = Buffer.allocUnsafe(1 + byteLength) - buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA224(message, key); + */ + C.HmacSHA224 = SHA256._createHmacHelper(SHA224); + }()); - // 0x04 | X | Y - } else { - buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) - buffer.writeUInt8(0x04, 0) - y.toBuffer(byteLength).copy(buffer, 1 + byteLength) - } + return CryptoJS.SHA224; - x.toBuffer(byteLength).copy(buffer, 1) +})); +},{"./core":153,"./sha256":179}],179:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - return buffer -} + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; -Point.decodeFrom = function (curve, buffer) { - var type = buffer.readUInt8(0) - var compressed = (type !== 4) + // Initialization and round constants tables + var H = []; + var K = []; - var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) - var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) + // Compute constants + (function () { + function isPrime(n) { + var sqrtN = Math.sqrt(n); + for (var factor = 2; factor <= sqrtN; factor++) { + if (!(n % factor)) { + return false; + } + } - var Q - if (compressed) { - assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') - assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') + return true; + } - var isOdd = (type === 0x03) - Q = curve.pointFromX(isOdd, x) - } else { - assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') + function getFractionalBits(n) { + return ((n - (n | 0)) * 0x100000000) | 0; + } - var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) - Q = Point.fromAffine(curve, x, y) - } + var n = 2; + var nPrime = 0; + while (nPrime < 64) { + if (isPrime(n)) { + if (nPrime < 8) { + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); + } + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); - Q.compressed = compressed - return Q -} + nPrime++; + } -Point.prototype.toString = function () { - if (this.curve.isInfinity(this)) return '(INFINITY)' + n++; + } + }()); - return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' -} + // Reusable object + var W = []; -module.exports = Point + /** + * SHA-256 hash algorithm. + */ + var SHA256 = C_algo.SHA256 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init(H.slice(0)); + }, -},{"assert":23,"bigi":32,"safe-buffer":298}],201:[function(require,module,exports){ -'use strict'; + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; -var elliptic = exports; + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + var f = H[5]; + var g = H[6]; + var h = H[7]; -elliptic.version = require('../package.json').version; -elliptic.utils = require('./elliptic/utils'); -elliptic.rand = require('brorand'); -elliptic.curve = require('./elliptic/curve'); -elliptic.curves = require('./elliptic/curves'); + // Computation + for (var i = 0; i < 64; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var gamma0x = W[i - 15]; + var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ + ((gamma0x << 14) | (gamma0x >>> 18)) ^ + (gamma0x >>> 3); -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); + var gamma1x = W[i - 2]; + var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ + ((gamma1x << 13) | (gamma1x >>> 19)) ^ + (gamma1x >>> 10); -},{"../package.json":216,"./elliptic/curve":204,"./elliptic/curves":207,"./elliptic/ec":208,"./elliptic/eddsa":211,"./elliptic/utils":215,"brorand":83}],202:[function(require,module,exports){ -'use strict'; + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; + } -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; + var ch = (e & f) ^ (~e & g); + var maj = (a & b) ^ (a & c) ^ (b & c); -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); + var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); + var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + var t1 = h + sigma1 + ch + K[i] + W[i]; + var t2 = sigma0 + maj; - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + H[5] = (H[5] + f) | 0; + H[6] = (H[6] + g) | 0; + H[7] = (H[7] + h) | 0; + }, - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; - } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); - } -} -module.exports = BaseCurve; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; + // Hash final blocks + this._process(); -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); + // Return final computed hash + return this._hash; + }, - var naf = getNAF(k, 1); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); - // Translate into more windowed form - var repr = []; - for (var j = 0; j < naf.length; j += doubles.step) { - var nafW = 0; - for (var k = j + doubles.step - 1; k >= j; k--) - nafW = (nafW << 1) + naf[k]; - repr.push(nafW); - } + return clone; + } + }); - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (var j = 0; j < repr.length; j++) { - var nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); -}; + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA256('message'); + * var hash = CryptoJS.SHA256(wordArray); + */ + C.SHA256 = Hasher._createHelper(SHA256); -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA256(message, key); + */ + C.HmacSHA256 = Hasher._createHmacHelper(SHA256); + }(Math)); - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; - // Get NAF form - var naf = getNAF(k, w); + return CryptoJS.SHA256; - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var k = 0; i >= 0 && naf[i] === 0; i--) - k++; - if (i >= 0) - k++; - acc = acc.dblp(k); +})); +},{"./core":153}],180:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; -}; + (function (Math) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var C_algo = C.algo; -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; + // Constants tables + var RHO_OFFSETS = []; + var PI_INDEXES = []; + var ROUND_CONSTANTS = []; - // Fill all arrays - var max = 0; - for (var i = 0; i < len; i++) { - var p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } + // Compute Constants + (function () { + // Compute rho offset constants + var x = 1, y = 0; + for (var t = 0; t < 24; t++) { + RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; - // Comb small window NAFs - for (var i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a]); - naf[b] = getNAF(coeffs[b], wndWidth[b]); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } + var newX = y % 5; + var newY = (2 * x + 3 * y) % 5; + x = newX; + y = newY; + } - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b] /* 7 */ - ]; + // Compute pi index constants + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; + } + } - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } + // Compute round constants + var LFSR = 0x01; + for (var i = 0; i < 24; i++) { + var roundConstantMsw = 0; + var roundConstantLsw = 0; - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3 /* 1 1 */ - ]; + for (var j = 0; j < 7; j++) { + if (LFSR & 0x01) { + var bitPosition = (1 << j) - 1; + if (bitPosition < 32) { + roundConstantLsw ^= 1 << bitPosition; + } else /* if (bitPosition >= 32) */ { + roundConstantMsw ^= 1 << (bitPosition - 32); + } + } - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (var j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; + // Compute next LFSR + if (LFSR & 0x80) { + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 + LFSR = (LFSR << 1) ^ 0x71; + } else { + LFSR <<= 1; + } + } - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } + ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw); + } + }()); - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (var i = max; i >= 0; i--) { - var k = 0; + // Reusable objects for temporary values + var T = []; + (function () { + for (var i = 0; i < 25; i++) { + T[i] = X64Word.create(); + } + }()); - while (i >= 0) { - var zero = true; - for (var j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; + /** + * SHA-3 hash algorithm. + */ + var SHA3 = C_algo.SHA3 = Hasher.extend({ + /** + * Configuration options. + * + * @property {number} outputLength + * The desired number of bits in the output hash. + * Only values permitted are: 224, 256, 384, 512. + * Default: 512 + */ + cfg: Hasher.cfg.extend({ + outputLength: 512 + }), - for (var j = 0; j < len; j++) { - var z = tmp[j]; - var p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); + _doReset: function () { + var state = this._state = [] + for (var i = 0; i < 25; i++) { + state[i] = new X64Word.init(); + } - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (var i = 0; i < len; i++) - wnd[i] = null; + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; + }, - if (jacobianResult) - return acc; - else - return acc.toP(); -}; + _doProcessBlock: function (M, offset) { + // Shortcuts + var state = this._state; + var nBlockSizeLanes = this.blockSize / 2; -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; -} -BaseCurve.BasePoint = BasePoint; + // Absorb + for (var i = 0; i < nBlockSizeLanes; i++) { + // Shortcuts + var M2i = M[offset + 2 * i]; + var M2i1 = M[offset + 2 * i + 1]; -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); -}; + // Swap endian + M2i = ( + (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | + (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00) + ); + M2i1 = ( + (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | + (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00) + ); -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); -}; + // Absorb message into state + var lane = state[i]; + lane.high ^= M2i1; + lane.low ^= M2i; + } -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); - - var len = this.p.byteLength(); + // Rounds + for (var round = 0; round < 24; round++) { + // Theta + for (var x = 0; x < 5; x++) { + // Mix column lanes + var tMsw = 0, tLsw = 0; + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + tMsw ^= lane.high; + tLsw ^= lane.low; + } - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); + // Temporary values + var Tx = T[x]; + Tx.high = tMsw; + Tx.low = tLsw; + } + for (var x = 0; x < 5; x++) { + // Shortcuts + var Tx4 = T[(x + 4) % 5]; + var Tx1 = T[(x + 1) % 5]; + var Tx1Msw = Tx1.high; + var Tx1Lsw = Tx1.low; - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); + // Mix surrounding columns + var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); + var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + lane.high ^= tMsw; + lane.low ^= tLsw; + } + } - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); - } - throw new Error('Unknown point format'); -}; + // Rho Pi + for (var laneIndex = 1; laneIndex < 25; laneIndex++) { + // Shortcuts + var lane = state[laneIndex]; + var laneMsw = lane.high; + var laneLsw = lane.low; + var rhoOffset = RHO_OFFSETS[laneIndex]; -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; + // Rotate lanes + if (rhoOffset < 32) { + var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); + var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); + } else /* if (rhoOffset >= 32) */ { + var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); + var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); + } -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); + // Transpose lanes + var TPiLane = T[PI_INDEXES[laneIndex]]; + TPiLane.high = tMsw; + TPiLane.low = tLsw; + } - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + // Rho pi at x = y = 0 + var T0 = T[0]; + var state0 = state[0]; + T0.high = state0.high; + T0.low = state0.low; - return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; -}; + // Chi + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + // Shortcuts + var laneIndex = x + 5 * y; + var lane = state[laneIndex]; + var TLane = T[laneIndex]; + var Tx1Lane = T[((x + 1) % 5) + 5 * y]; + var Tx2Lane = T[((x + 2) % 5) + 5 * y]; -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; + // Mix rows + lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); + lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); + } + } -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; + // Iota + var lane = state[0]; + var roundConstant = ROUND_CONSTANTS[round]; + lane.high ^= roundConstant.high; + lane.low ^= roundConstant.low;; + } + }, - var precomputed = { - doubles: null, - naf: null, - beta: null - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + var blockSizeBits = this.blockSize * 32; - return this; -}; + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; + data.sigBytes = dataWords.length * 4; -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; + // Hash final blocks + this._process(); - var doubles = this.precomputed.doubles; - if (!doubles) - return false; + // Shortcuts + var state = this._state; + var outputLengthBytes = this.cfg.outputLength / 8; + var outputLengthLanes = outputLengthBytes / 8; - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; + // Squeeze + var hashWords = []; + for (var i = 0; i < outputLengthLanes; i++) { + // Shortcuts + var lane = state[i]; + var laneMsw = lane.high; + var laneLsw = lane.low; -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; + // Swap endian + laneMsw = ( + (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | + (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00) + ); + laneLsw = ( + (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | + (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00) + ); - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); - } - return { - step: step, - points: doubles - }; -}; + // Squeeze state to retrieve hash + hashWords.push(laneLsw); + hashWords.push(laneMsw); + } -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; + // Return final computed hash + return new WordArray.init(hashWords, outputLengthBytes); + }, - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res - }; -}; + clone: function () { + var clone = Hasher.clone.call(this); -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; + var state = clone._state = this._state.slice(0); + for (var i = 0; i < 25; i++) { + state[i] = state[i].clone(); + } -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; + return clone; + } + }); -},{"../../elliptic":201,"bn.js":82}],203:[function(require,module,exports){ -'use strict'; + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA3('message'); + * var hash = CryptoJS.SHA3(wordArray); + */ + C.SHA3 = Hasher._createHelper(SHA3); -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA3(message, key); + */ + C.HmacSHA3 = Hasher._createHmacHelper(SHA3); + }(Math)); -var assert = elliptic.utils.assert; -function EdwardsCurve(conf) { - // NOTE: Important as we are creating point in Base.call() - this.twisted = (conf.a | 0) !== 1; - this.mOneA = this.twisted && (conf.a | 0) === -1; - this.extended = this.mOneA; + return CryptoJS.SHA3; - Base.call(this, 'edwards', conf); +})); +},{"./core":153,"./x64-core":184}],181:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core", "./sha512"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { - this.a = new BN(conf.a, 16).umod(this.red.m); - this.a = this.a.toRed(this.red); - this.c = new BN(conf.c, 16).toRed(this.red); - this.c2 = this.c.redSqr(); - this.d = new BN(conf.d, 16).toRed(this.red); - this.dd = this.d.redAdd(this.d); + (function () { + // Shortcuts + var C = CryptoJS; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; + var SHA512 = C_algo.SHA512; - assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); - this.oneC = (conf.c | 0) === 1; -} -inherits(EdwardsCurve, Base); -module.exports = EdwardsCurve; + /** + * SHA-384 hash algorithm. + */ + var SHA384 = C_algo.SHA384 = SHA512.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), + new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), + new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), + new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) + ]); + }, -EdwardsCurve.prototype._mulA = function _mulA(num) { - if (this.mOneA) - return num.redNeg(); - else - return this.a.redMul(num); -}; + _doFinalize: function () { + var hash = SHA512._doFinalize.call(this); -EdwardsCurve.prototype._mulC = function _mulC(num) { - if (this.oneC) - return num; - else - return this.c.redMul(num); -}; + hash.sigBytes -= 16; -// Just for compatibility with Short curve -EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { - return this.point(x, y, z, t); -}; + return hash; + } + }); -EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA384('message'); + * var hash = CryptoJS.SHA384(wordArray); + */ + C.SHA384 = SHA512._createHelper(SHA384); - var x2 = x.redSqr(); - var rhs = this.c2.redSub(this.a.redMul(x2)); - var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA384(message, key); + */ + C.HmacSHA384 = SHA512._createHmacHelper(SHA384); + }()); - var y2 = rhs.redMul(lhs.redInvm()); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + return CryptoJS.SHA384; - return this.point(x, y); -}; +})); +},{"./core":153,"./sha512":182,"./x64-core":184}],182:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./x64-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./x64-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { - y = new BN(y, 16); - if (!y.red) - y = y.toRed(this.red); + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; - // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) - var y2 = y.redSqr(); - var lhs = y2.redSub(this.c2); - var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); - var x2 = lhs.redMul(rhs.redInvm()); + function X64Word_create() { + return X64Word.create.apply(X64Word, arguments); + } - if (x2.cmp(this.zero) === 0) { - if (odd) - throw new Error('invalid point'); - else - return this.point(this.zero, y); - } + // Constants + var K = [ + X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd), + X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc), + X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019), + X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118), + X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe), + X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2), + X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1), + X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694), + X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3), + X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65), + X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483), + X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5), + X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210), + X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4), + X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725), + X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70), + X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926), + X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df), + X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8), + X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b), + X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001), + X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30), + X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910), + X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8), + X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53), + X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8), + X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb), + X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3), + X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60), + X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec), + X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9), + X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b), + X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207), + X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178), + X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6), + X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b), + X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493), + X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c), + X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a), + X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817) + ]; - var x = x2.redSqrt(); - if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) - throw new Error('invalid point'); + // Reusable objects + var W = []; + (function () { + for (var i = 0; i < 80; i++) { + W[i] = X64Word_create(); + } + }()); - if (x.fromRed().isOdd() !== odd) - x = x.redNeg(); + /** + * SHA-512 hash algorithm. + */ + var SHA512 = C_algo.SHA512 = Hasher.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b), + new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1), + new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f), + new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179) + ]); + }, - return this.point(x, y); -}; + _doProcessBlock: function (M, offset) { + // Shortcuts + var H = this._hash.words; -EdwardsCurve.prototype.validate = function validate(point) { - if (point.isInfinity()) - return true; + var H0 = H[0]; + var H1 = H[1]; + var H2 = H[2]; + var H3 = H[3]; + var H4 = H[4]; + var H5 = H[5]; + var H6 = H[6]; + var H7 = H[7]; - // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) - point.normalize(); + var H0h = H0.high; + var H0l = H0.low; + var H1h = H1.high; + var H1l = H1.low; + var H2h = H2.high; + var H2l = H2.low; + var H3h = H3.high; + var H3l = H3.low; + var H4h = H4.high; + var H4l = H4.low; + var H5h = H5.high; + var H5l = H5.low; + var H6h = H6.high; + var H6l = H6.low; + var H7h = H7.high; + var H7l = H7.low; - var x2 = point.x.redSqr(); - var y2 = point.y.redSqr(); - var lhs = x2.redMul(this.a).redAdd(y2); - var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); - - return lhs.cmp(rhs) === 0; -}; - -function Point(curve, x, y, z, t) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && y === null && z === null) { - this.x = this.curve.zero; - this.y = this.curve.one; - this.z = this.curve.one; - this.t = this.curve.zero; - this.zOne = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = z ? new BN(z, 16) : this.curve.one; - this.t = t && new BN(t, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - if (this.t && !this.t.red) - this.t = this.t.toRed(this.curve.red); - this.zOne = this.z === this.curve.one; - - // Use extended coordinates - if (this.curve.extended && !this.t) { - this.t = this.x.redMul(this.y); - if (!this.zOne) - this.t = this.t.redMul(this.z.redInvm()); - } - } -} -inherits(Point, Base.BasePoint); - -EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; - -EdwardsCurve.prototype.point = function point(x, y, z, t) { - return new Point(this, x, y, z, t); -}; - -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1], obj[2]); -}; + // Working variables + var ah = H0h; + var al = H0l; + var bh = H1h; + var bl = H1l; + var ch = H2h; + var cl = H2l; + var dh = H3h; + var dl = H3l; + var eh = H4h; + var el = H4l; + var fh = H5h; + var fl = H5l; + var gh = H6h; + var gl = H6l; + var hh = H7h; + var hl = H7l; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + // Rounds + for (var i = 0; i < 80; i++) { + // Shortcut + var Wi = W[i]; -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.x.cmpn(0) === 0 && - (this.y.cmp(this.z) === 0 || - (this.zOne && this.y.cmp(this.curve.c) === 0)); -}; + // Extend message + if (i < 16) { + var Wih = Wi.high = M[offset + i * 2] | 0; + var Wil = Wi.low = M[offset + i * 2 + 1] | 0; + } else { + // Gamma0 + var gamma0x = W[i - 15]; + var gamma0xh = gamma0x.high; + var gamma0xl = gamma0x.low; + var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7); + var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); -Point.prototype._extDbl = function _extDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #doubling-dbl-2008-hwcd - // 4M + 4S + // Gamma1 + var gamma1x = W[i - 2]; + var gamma1xh = gamma1x.high; + var gamma1xl = gamma1x.low; + var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); + var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = 2 * Z1^2 - var c = this.z.redSqr(); - c = c.redIAdd(c); - // D = a * A - var d = this.curve._mulA(a); - // E = (X1 + Y1)^2 - A - B - var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); - // G = D + B - var g = d.redAdd(b); - // F = G - C - var f = g.redSub(c); - // H = D - B - var h = d.redSub(b); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); -}; + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7 = W[i - 7]; + var Wi7h = Wi7.high; + var Wi7l = Wi7.low; -Point.prototype._projDbl = function _projDbl() { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #doubling-dbl-2008-bbjlp - // #doubling-dbl-2007-bl - // and others - // Generally 3M + 4S or 2M + 4S + var Wi16 = W[i - 16]; + var Wi16h = Wi16.high; + var Wi16l = Wi16.low; - // B = (X1 + Y1)^2 - var b = this.x.redAdd(this.y).redSqr(); - // C = X1^2 - var c = this.x.redSqr(); - // D = Y1^2 - var d = this.y.redSqr(); + var Wil = gamma0l + Wi7l; + var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); + var Wil = Wil + gamma1l; + var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); + var Wil = Wil + Wi16l; + var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); - var nx; - var ny; - var nz; - if (this.curve.twisted) { - // E = a * C - var e = this.curve._mulA(c); - // F = E + D - var f = e.redAdd(d); - if (this.zOne) { - // X3 = (B - C - D) * (F - 2) - nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F^2 - 2 * F - nz = f.redSqr().redSub(f).redSub(f); - } else { - // H = Z1^2 - var h = this.z.redSqr(); - // J = F - 2 * H - var j = f.redSub(h).redISub(h); - // X3 = (B-C-D)*J - nx = b.redSub(c).redISub(d).redMul(j); - // Y3 = F * (E - D) - ny = f.redMul(e.redSub(d)); - // Z3 = F * J - nz = f.redMul(j); - } - } else { - // E = C + D - var e = c.redAdd(d); - // H = (c * Z1)^2 - var h = this.curve._mulC(this.z).redSqr(); - // J = E - 2 * H - var j = e.redSub(h).redSub(h); - // X3 = c * (B - E) * J - nx = this.curve._mulC(b.redISub(e)).redMul(j); - // Y3 = c * E * (C - D) - ny = this.curve._mulC(e).redMul(c.redISub(d)); - // Z3 = E * J - nz = e.redMul(j); - } - return this.curve.point(nx, ny, nz); -}; + Wi.high = Wih; + Wi.low = Wil; + } -Point.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; + var chh = (eh & fh) ^ (~eh & gh); + var chl = (el & fl) ^ (~el & gl); + var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); + var majl = (al & bl) ^ (al & cl) ^ (bl & cl); - // Double in extended coordinates - if (this.curve.extended) - return this._extDbl(); - else - return this._projDbl(); -}; + var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); + var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); + var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); + var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); -Point.prototype._extAdd = function _extAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html - // #addition-add-2008-hwcd-3 - // 8M + // t1 = h + sigma1 + ch + K[i] + W[i] + var Ki = K[i]; + var Kih = Ki.high; + var Kil = Ki.low; - // A = (Y1 - X1) * (Y2 - X2) - var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); - // B = (Y1 + X1) * (Y2 + X2) - var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); - // C = T1 * k * T2 - var c = this.t.redMul(this.curve.dd).redMul(p.t); - // D = Z1 * 2 * Z2 - var d = this.z.redMul(p.z.redAdd(p.z)); - // E = B - A - var e = b.redSub(a); - // F = D - C - var f = d.redSub(c); - // G = D + C - var g = d.redAdd(c); - // H = B + A - var h = b.redAdd(a); - // X3 = E * F - var nx = e.redMul(f); - // Y3 = G * H - var ny = g.redMul(h); - // T3 = E * H - var nt = e.redMul(h); - // Z3 = F * G - var nz = f.redMul(g); - return this.curve.point(nx, ny, nz, nt); -}; + var t1l = hl + sigma1l; + var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); + var t1l = t1l + chl; + var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); + var t1l = t1l + Kil; + var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); + var t1l = t1l + Wil; + var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); -Point.prototype._projAdd = function _projAdd(p) { - // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html - // #addition-add-2008-bbjlp - // #addition-add-2007-bl - // 10M + 1S + // t2 = sigma0 + maj + var t2l = sigma0l + majl; + var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); - // A = Z1 * Z2 - var a = this.z.redMul(p.z); - // B = A^2 - var b = a.redSqr(); - // C = X1 * X2 - var c = this.x.redMul(p.x); - // D = Y1 * Y2 - var d = this.y.redMul(p.y); - // E = d * C * D - var e = this.curve.d.redMul(c).redMul(d); - // F = B - E - var f = b.redSub(e); - // G = B + E - var g = b.redAdd(e); - // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) - var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); - var nx = a.redMul(f).redMul(tmp); - var ny; - var nz; - if (this.curve.twisted) { - // Y3 = A * G * (D - a * C) - ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); - // Z3 = F * G - nz = f.redMul(g); - } else { - // Y3 = A * G * (D - C) - ny = a.redMul(g).redMul(d.redSub(c)); - // Z3 = c * F * G - nz = this.curve._mulC(f).redMul(g); - } - return this.curve.point(nx, ny, nz); -}; + // Update working variables + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = (dl + t1l) | 0; + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = (t1l + t2l) | 0; + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; + } -Point.prototype.add = function add(p) { - if (this.isInfinity()) - return p; - if (p.isInfinity()) - return this; + // Intermediate hash value + H0l = H0.low = (H0l + al); + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); + H1l = H1.low = (H1l + bl); + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); + H2l = H2.low = (H2l + cl); + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); + H3l = H3.low = (H3l + dl); + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); + H4l = H4.low = (H4l + el); + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); + H5l = H5.low = (H5l + fl); + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); + H6l = H6.low = (H6l + gl); + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); + H7l = H7.low = (H7l + hl); + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); + }, - if (this.curve.extended) - return this._extAdd(p); - else - return this._projAdd(p); -}; + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; -Point.prototype.mul = function mul(k) { - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else - return this.curve._wnafMul(this, k); -}; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; -Point.prototype.mulAdd = function mulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); -}; + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; + data.sigBytes = dataWords.length * 4; -Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { - return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); -}; + // Hash final blocks + this._process(); -Point.prototype.normalize = function normalize() { - if (this.zOne) - return this; + // Convert hash to 32-bit word array before returning + var hash = this._hash.toX32(); - // Normalize coordinates - var zi = this.z.redInvm(); - this.x = this.x.redMul(zi); - this.y = this.y.redMul(zi); - if (this.t) - this.t = this.t.redMul(zi); - this.z = this.curve.one; - this.zOne = true; - return this; -}; + // Return final computed hash + return hash; + }, -Point.prototype.neg = function neg() { - return this.curve.point(this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg()); -}; + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); -Point.prototype.getX = function getX() { - this.normalize(); - return this.x.fromRed(); -}; + return clone; + }, -Point.prototype.getY = function getY() { - this.normalize(); - return this.y.fromRed(); -}; + blockSize: 1024/32 + }); -Point.prototype.eq = function eq(other) { - return this === other || - this.getX().cmp(other.getX()) === 0 && - this.getY().cmp(other.getY()) === 0; -}; + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA512('message'); + * var hash = CryptoJS.SHA512(wordArray); + */ + C.SHA512 = Hasher._createHelper(SHA512); -Point.prototype.eqXToP = function eqXToP(x) { - var rx = x.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(rx) === 0) - return true; + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA512(message, key); + */ + C.HmacSHA512 = Hasher._createHmacHelper(SHA512); + }()); - var xc = x.clone(); - var t = this.curve.redN.redMul(this.z); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } -}; + return CryptoJS.SHA512; -// Compatibility with BaseCurve -Point.prototype.toP = Point.prototype.normalize; -Point.prototype.mixedAdd = Point.prototype.add; +})); +},{"./core":153,"./x64-core":184}],183:[function(require,module,exports){ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { -},{"../../elliptic":201,"../curve":204,"bn.js":82,"inherits":238}],204:[function(require,module,exports){ -'use strict'; + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; -var curve = exports; + // Permuted Choice 1 constants + var PC1 = [ + 57, 49, 41, 33, 25, 17, 9, 1, + 58, 50, 42, 34, 26, 18, 10, 2, + 59, 51, 43, 35, 27, 19, 11, 3, + 60, 52, 44, 36, 63, 55, 47, 39, + 31, 23, 15, 7, 62, 54, 46, 38, + 30, 22, 14, 6, 61, 53, 45, 37, + 29, 21, 13, 5, 28, 20, 12, 4 + ]; -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); + // Permuted Choice 2 constants + var PC2 = [ + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32 + ]; -},{"./base":202,"./edwards":203,"./mont":205,"./short":206}],205:[function(require,module,exports){ -'use strict'; + // Cumulative bit shift constants + var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; -var curve = require('../curve'); -var BN = require('bn.js'); + // SBOXes and round permutation constants + var SBOX_P = [ + { + 0x0: 0x808200, + 0x10000000: 0x8000, + 0x20000000: 0x808002, + 0x30000000: 0x2, + 0x40000000: 0x200, + 0x50000000: 0x808202, + 0x60000000: 0x800202, + 0x70000000: 0x800000, + 0x80000000: 0x202, + 0x90000000: 0x800200, + 0xa0000000: 0x8200, + 0xb0000000: 0x808000, + 0xc0000000: 0x8002, + 0xd0000000: 0x800002, + 0xe0000000: 0x0, + 0xf0000000: 0x8202, + 0x8000000: 0x0, + 0x18000000: 0x808202, + 0x28000000: 0x8202, + 0x38000000: 0x8000, + 0x48000000: 0x808200, + 0x58000000: 0x200, + 0x68000000: 0x808002, + 0x78000000: 0x2, + 0x88000000: 0x800200, + 0x98000000: 0x8200, + 0xa8000000: 0x808000, + 0xb8000000: 0x800202, + 0xc8000000: 0x800002, + 0xd8000000: 0x8002, + 0xe8000000: 0x202, + 0xf8000000: 0x800000, + 0x1: 0x8000, + 0x10000001: 0x2, + 0x20000001: 0x808200, + 0x30000001: 0x800000, + 0x40000001: 0x808002, + 0x50000001: 0x8200, + 0x60000001: 0x200, + 0x70000001: 0x800202, + 0x80000001: 0x808202, + 0x90000001: 0x808000, + 0xa0000001: 0x800002, + 0xb0000001: 0x8202, + 0xc0000001: 0x202, + 0xd0000001: 0x800200, + 0xe0000001: 0x8002, + 0xf0000001: 0x0, + 0x8000001: 0x808202, + 0x18000001: 0x808000, + 0x28000001: 0x800000, + 0x38000001: 0x200, + 0x48000001: 0x8000, + 0x58000001: 0x800002, + 0x68000001: 0x2, + 0x78000001: 0x8202, + 0x88000001: 0x8002, + 0x98000001: 0x800202, + 0xa8000001: 0x202, + 0xb8000001: 0x808200, + 0xc8000001: 0x800200, + 0xd8000001: 0x0, + 0xe8000001: 0x8200, + 0xf8000001: 0x808002 + }, + { + 0x0: 0x40084010, + 0x1000000: 0x4000, + 0x2000000: 0x80000, + 0x3000000: 0x40080010, + 0x4000000: 0x40000010, + 0x5000000: 0x40084000, + 0x6000000: 0x40004000, + 0x7000000: 0x10, + 0x8000000: 0x84000, + 0x9000000: 0x40004010, + 0xa000000: 0x40000000, + 0xb000000: 0x84010, + 0xc000000: 0x80010, + 0xd000000: 0x0, + 0xe000000: 0x4010, + 0xf000000: 0x40080000, + 0x800000: 0x40004000, + 0x1800000: 0x84010, + 0x2800000: 0x10, + 0x3800000: 0x40004010, + 0x4800000: 0x40084010, + 0x5800000: 0x40000000, + 0x6800000: 0x80000, + 0x7800000: 0x40080010, + 0x8800000: 0x80010, + 0x9800000: 0x0, + 0xa800000: 0x4000, + 0xb800000: 0x40080000, + 0xc800000: 0x40000010, + 0xd800000: 0x84000, + 0xe800000: 0x40084000, + 0xf800000: 0x4010, + 0x10000000: 0x0, + 0x11000000: 0x40080010, + 0x12000000: 0x40004010, + 0x13000000: 0x40084000, + 0x14000000: 0x40080000, + 0x15000000: 0x10, + 0x16000000: 0x84010, + 0x17000000: 0x4000, + 0x18000000: 0x4010, + 0x19000000: 0x80000, + 0x1a000000: 0x80010, + 0x1b000000: 0x40000010, + 0x1c000000: 0x84000, + 0x1d000000: 0x40004000, + 0x1e000000: 0x40000000, + 0x1f000000: 0x40084010, + 0x10800000: 0x84010, + 0x11800000: 0x80000, + 0x12800000: 0x40080000, + 0x13800000: 0x4000, + 0x14800000: 0x40004000, + 0x15800000: 0x40084010, + 0x16800000: 0x10, + 0x17800000: 0x40000000, + 0x18800000: 0x40084000, + 0x19800000: 0x40000010, + 0x1a800000: 0x40004010, + 0x1b800000: 0x80010, + 0x1c800000: 0x0, + 0x1d800000: 0x4010, + 0x1e800000: 0x40080010, + 0x1f800000: 0x84000 + }, + { + 0x0: 0x104, + 0x100000: 0x0, + 0x200000: 0x4000100, + 0x300000: 0x10104, + 0x400000: 0x10004, + 0x500000: 0x4000004, + 0x600000: 0x4010104, + 0x700000: 0x4010000, + 0x800000: 0x4000000, + 0x900000: 0x4010100, + 0xa00000: 0x10100, + 0xb00000: 0x4010004, + 0xc00000: 0x4000104, + 0xd00000: 0x10000, + 0xe00000: 0x4, + 0xf00000: 0x100, + 0x80000: 0x4010100, + 0x180000: 0x4010004, + 0x280000: 0x0, + 0x380000: 0x4000100, + 0x480000: 0x4000004, + 0x580000: 0x10000, + 0x680000: 0x10004, + 0x780000: 0x104, + 0x880000: 0x4, + 0x980000: 0x100, + 0xa80000: 0x4010000, + 0xb80000: 0x10104, + 0xc80000: 0x10100, + 0xd80000: 0x4000104, + 0xe80000: 0x4010104, + 0xf80000: 0x4000000, + 0x1000000: 0x4010100, + 0x1100000: 0x10004, + 0x1200000: 0x10000, + 0x1300000: 0x4000100, + 0x1400000: 0x100, + 0x1500000: 0x4010104, + 0x1600000: 0x4000004, + 0x1700000: 0x0, + 0x1800000: 0x4000104, + 0x1900000: 0x4000000, + 0x1a00000: 0x4, + 0x1b00000: 0x10100, + 0x1c00000: 0x4010000, + 0x1d00000: 0x104, + 0x1e00000: 0x10104, + 0x1f00000: 0x4010004, + 0x1080000: 0x4000000, + 0x1180000: 0x104, + 0x1280000: 0x4010100, + 0x1380000: 0x0, + 0x1480000: 0x10004, + 0x1580000: 0x4000100, + 0x1680000: 0x100, + 0x1780000: 0x4010004, + 0x1880000: 0x10000, + 0x1980000: 0x4010104, + 0x1a80000: 0x10104, + 0x1b80000: 0x4000004, + 0x1c80000: 0x4000104, + 0x1d80000: 0x4010000, + 0x1e80000: 0x4, + 0x1f80000: 0x10100 + }, + { + 0x0: 0x80401000, + 0x10000: 0x80001040, + 0x20000: 0x401040, + 0x30000: 0x80400000, + 0x40000: 0x0, + 0x50000: 0x401000, + 0x60000: 0x80000040, + 0x70000: 0x400040, + 0x80000: 0x80000000, + 0x90000: 0x400000, + 0xa0000: 0x40, + 0xb0000: 0x80001000, + 0xc0000: 0x80400040, + 0xd0000: 0x1040, + 0xe0000: 0x1000, + 0xf0000: 0x80401040, + 0x8000: 0x80001040, + 0x18000: 0x40, + 0x28000: 0x80400040, + 0x38000: 0x80001000, + 0x48000: 0x401000, + 0x58000: 0x80401040, + 0x68000: 0x0, + 0x78000: 0x80400000, + 0x88000: 0x1000, + 0x98000: 0x80401000, + 0xa8000: 0x400000, + 0xb8000: 0x1040, + 0xc8000: 0x80000000, + 0xd8000: 0x400040, + 0xe8000: 0x401040, + 0xf8000: 0x80000040, + 0x100000: 0x400040, + 0x110000: 0x401000, + 0x120000: 0x80000040, + 0x130000: 0x0, + 0x140000: 0x1040, + 0x150000: 0x80400040, + 0x160000: 0x80401000, + 0x170000: 0x80001040, + 0x180000: 0x80401040, + 0x190000: 0x80000000, + 0x1a0000: 0x80400000, + 0x1b0000: 0x401040, + 0x1c0000: 0x80001000, + 0x1d0000: 0x400000, + 0x1e0000: 0x40, + 0x1f0000: 0x1000, + 0x108000: 0x80400000, + 0x118000: 0x80401040, + 0x128000: 0x0, + 0x138000: 0x401000, + 0x148000: 0x400040, + 0x158000: 0x80000000, + 0x168000: 0x80001040, + 0x178000: 0x40, + 0x188000: 0x80000040, + 0x198000: 0x1000, + 0x1a8000: 0x80001000, + 0x1b8000: 0x80400040, + 0x1c8000: 0x1040, + 0x1d8000: 0x80401000, + 0x1e8000: 0x400000, + 0x1f8000: 0x401040 + }, + { + 0x0: 0x80, + 0x1000: 0x1040000, + 0x2000: 0x40000, + 0x3000: 0x20000000, + 0x4000: 0x20040080, + 0x5000: 0x1000080, + 0x6000: 0x21000080, + 0x7000: 0x40080, + 0x8000: 0x1000000, + 0x9000: 0x20040000, + 0xa000: 0x20000080, + 0xb000: 0x21040080, + 0xc000: 0x21040000, + 0xd000: 0x0, + 0xe000: 0x1040080, + 0xf000: 0x21000000, + 0x800: 0x1040080, + 0x1800: 0x21000080, + 0x2800: 0x80, + 0x3800: 0x1040000, + 0x4800: 0x40000, + 0x5800: 0x20040080, + 0x6800: 0x21040000, + 0x7800: 0x20000000, + 0x8800: 0x20040000, + 0x9800: 0x0, + 0xa800: 0x21040080, + 0xb800: 0x1000080, + 0xc800: 0x20000080, + 0xd800: 0x21000000, + 0xe800: 0x1000000, + 0xf800: 0x40080, + 0x10000: 0x40000, + 0x11000: 0x80, + 0x12000: 0x20000000, + 0x13000: 0x21000080, + 0x14000: 0x1000080, + 0x15000: 0x21040000, + 0x16000: 0x20040080, + 0x17000: 0x1000000, + 0x18000: 0x21040080, + 0x19000: 0x21000000, + 0x1a000: 0x1040000, + 0x1b000: 0x20040000, + 0x1c000: 0x40080, + 0x1d000: 0x20000080, + 0x1e000: 0x0, + 0x1f000: 0x1040080, + 0x10800: 0x21000080, + 0x11800: 0x1000000, + 0x12800: 0x1040000, + 0x13800: 0x20040080, + 0x14800: 0x20000000, + 0x15800: 0x1040080, + 0x16800: 0x80, + 0x17800: 0x21040000, + 0x18800: 0x40080, + 0x19800: 0x21040080, + 0x1a800: 0x0, + 0x1b800: 0x21000000, + 0x1c800: 0x1000080, + 0x1d800: 0x40000, + 0x1e800: 0x20040000, + 0x1f800: 0x20000080 + }, + { + 0x0: 0x10000008, + 0x100: 0x2000, + 0x200: 0x10200000, + 0x300: 0x10202008, + 0x400: 0x10002000, + 0x500: 0x200000, + 0x600: 0x200008, + 0x700: 0x10000000, + 0x800: 0x0, + 0x900: 0x10002008, + 0xa00: 0x202000, + 0xb00: 0x8, + 0xc00: 0x10200008, + 0xd00: 0x202008, + 0xe00: 0x2008, + 0xf00: 0x10202000, + 0x80: 0x10200000, + 0x180: 0x10202008, + 0x280: 0x8, + 0x380: 0x200000, + 0x480: 0x202008, + 0x580: 0x10000008, + 0x680: 0x10002000, + 0x780: 0x2008, + 0x880: 0x200008, + 0x980: 0x2000, + 0xa80: 0x10002008, + 0xb80: 0x10200008, + 0xc80: 0x0, + 0xd80: 0x10202000, + 0xe80: 0x202000, + 0xf80: 0x10000000, + 0x1000: 0x10002000, + 0x1100: 0x10200008, + 0x1200: 0x10202008, + 0x1300: 0x2008, + 0x1400: 0x200000, + 0x1500: 0x10000000, + 0x1600: 0x10000008, + 0x1700: 0x202000, + 0x1800: 0x202008, + 0x1900: 0x0, + 0x1a00: 0x8, + 0x1b00: 0x10200000, + 0x1c00: 0x2000, + 0x1d00: 0x10002008, + 0x1e00: 0x10202000, + 0x1f00: 0x200008, + 0x1080: 0x8, + 0x1180: 0x202000, + 0x1280: 0x200000, + 0x1380: 0x10000008, + 0x1480: 0x10002000, + 0x1580: 0x2008, + 0x1680: 0x10202008, + 0x1780: 0x10200000, + 0x1880: 0x10202000, + 0x1980: 0x10200008, + 0x1a80: 0x2000, + 0x1b80: 0x202008, + 0x1c80: 0x200008, + 0x1d80: 0x0, + 0x1e80: 0x10000000, + 0x1f80: 0x10002008 + }, + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } + ]; + + // Masks that select the SBOX input + var SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f + ]; + + /** + * DES block cipher algorithm. + */ + var DES = C_algo.DES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Select 56 bits according to PC1 + var keyBits = []; + for (var i = 0; i < 56; i++) { + var keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; + } + + // Assemble 16 subkeys + var subKeys = this._subKeys = []; + for (var nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + var subKey = subKeys[nSubKey] = []; + + // Shortcut + var bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (var i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (var i = 1; i < 7; i++) { + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + var invSubKeys = this._invSubKeys = []; + for (var i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + }, + + decryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + }, + + _doCryptBlock: function (M, offset, subKeys) { + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (var round = 0; round < 16; round++) { + // Shortcuts + var subKey = subKeys[round]; + var lBlock = this._lBlock; + var rBlock = this._rBlock; + + // Feistel function + var f = 0; + for (var i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + var t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + M[offset] = this._lBlock; + M[offset + 1] = this._rBlock; + }, + + keySize: 64/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + // Swap bits across the left and right words + function exchangeLR(offset, mask) { + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; + } + + function exchangeRL(offset, mask) { + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + C.DES = BlockCipher._createHelper(DES); + + /** + * Triple-DES block cipher algorithm. + */ + var TripleDES = C_algo.TripleDES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Create DES instances + this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2))); + this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4))); + this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6))); + }, + + encryptBlock: function (M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + }, + + decryptBlock: function (M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + }, + + keySize: 192/32, + + ivSize: 64/32, + + blockSize: 64/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + C.TripleDES = BlockCipher._createHelper(TripleDES); + }()); + + + return CryptoJS.TripleDES; + +})); +},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],184:[function(require,module,exports){ +;(function (root, factory) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function (undefined) { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var X32WordArray = C_lib.WordArray; + + /** + * x64 namespace. + */ + var C_x64 = C.x64 = {}; + + /** + * A 64-bit word. + */ + var X64Word = C_x64.Word = Base.extend({ + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + init: function (high, low) { + this.high = high; + this.low = low; + } + + /** + * Bitwise NOTs this word. + * + * @return {X64Word} A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + // not: function () { + // var high = ~this.high; + // var low = ~this.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ANDs this word with the passed word. + * + * @param {X64Word} word The x64-Word to AND with this word. + * + * @return {X64Word} A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + // and: function (word) { + // var high = this.high & word.high; + // var low = this.low & word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to OR with this word. + * + * @return {X64Word} A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + // or: function (word) { + // var high = this.high | word.high; + // var low = this.low | word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise XORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to XOR with this word. + * + * @return {X64Word} A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + // xor: function (word) { + // var high = this.high ^ word.high; + // var low = this.low ^ word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the left. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + // shiftL: function (n) { + // if (n < 32) { + // var high = (this.high << n) | (this.low >>> (32 - n)); + // var low = this.low << n; + // } else { + // var high = this.low << (n - 32); + // var low = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the right. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + // shiftR: function (n) { + // if (n < 32) { + // var low = (this.low >>> n) | (this.high << (32 - n)); + // var high = this.high >>> n; + // } else { + // var low = this.high >>> (n - 32); + // var high = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Rotates this word n bits to the left. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + // rotL: function (n) { + // return this.shiftL(n).or(this.shiftR(64 - n)); + // }, + + /** + * Rotates this word n bits to the right. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + // rotR: function (n) { + // return this.shiftR(n).or(this.shiftL(64 - n)); + // }, + + /** + * Adds this word with the passed word. + * + * @param {X64Word} word The x64-Word to add with this word. + * + * @return {X64Word} A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + // add: function (word) { + // var low = (this.low + word.low) | 0; + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; + // var high = (this.high + word.high + carry) | 0; + + // return X64Word.create(high, low); + // } + }); + + /** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var X64WordArray = C_x64.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 8; + } + }, + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32: function () { + // Shortcuts + var x64Words = this.words; + var x64WordsLength = x64Words.length; + + // Convert + var x32Words = []; + for (var i = 0; i < x64WordsLength; i++) { + var x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + }, + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + + // Clone "words" array + var words = clone.words = this.words.slice(0); + + // Clone each X64Word object + var wordsLength = words.length; + for (var i = 0; i < wordsLength; i++) { + words[i] = words[i].clone(); + } + + return clone; + } + }); + }()); + + + return CryptoJS; + +})); +},{"./core":153}],185:[function(require,module,exports){ +(function (process){(function (){ +/** + * This is the web browser implementation of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = require('./debug'); +exports.log = log; +exports.formatArgs = formatArgs; +exports.save = save; +exports.load = load; +exports.useColors = useColors; +exports.storage = 'undefined' != typeof chrome + && 'undefined' != typeof chrome.storage + ? chrome.storage.local + : localstorage(); + +/** + * Colors. + */ + +exports.colors = [ + 'lightseagreen', + 'forestgreen', + 'goldenrod', + 'dodgerblue', + 'darkorchid', + 'crimson' +]; + +/** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + +function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { + return true; + } + + // is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); +} + +/** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + +exports.formatters.j = function(v) { + try { + return JSON.stringify(v); + } catch (err) { + return '[UnexpectedJSONParseError]: ' + err.message; + } +}; + + +/** + * Colorize log arguments if enabled. + * + * @api public + */ + +function formatArgs(args) { + var useColors = this.useColors; + + args[0] = (useColors ? '%c' : '') + + this.namespace + + (useColors ? ' %c' : ' ') + + args[0] + + (useColors ? '%c ' : ' ') + + '+' + exports.humanize(this.diff); + + if (!useColors) return; + + var c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit') + + // the final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + var index = 0; + var lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, function(match) { + if ('%%' === match) return; + index++; + if ('%c' === match) { + // we only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); +} + +/** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + +function log() { + // this hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return 'object' === typeof console + && console.log + && Function.prototype.apply.call(console.log, console, arguments); +} + +/** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + +function save(namespaces) { + try { + if (null == namespaces) { + exports.storage.removeItem('debug'); + } else { + exports.storage.debug = namespaces; + } + } catch(e) {} +} + +/** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + +function load() { + var r; + try { + r = exports.storage.debug; + } catch(e) {} + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; +} + +/** + * Enable namespaces listed in `localStorage.debug` initially. + */ + +exports.enable(load()); + +/** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + +function localstorage() { + try { + return window.localStorage; + } catch (e) {} +} + +}).call(this)}).call(this,require('_process')) +},{"./debug":186,"_process":270}],186:[function(require,module,exports){ + +/** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + * + * Expose `debug()` as the module. + */ + +exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; +exports.coerce = coerce; +exports.disable = disable; +exports.enable = enable; +exports.enabled = enabled; +exports.humanize = require('ms'); + +/** + * The currently active debug mode names, and names to skip. + */ + +exports.names = []; +exports.skips = []; + +/** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + +exports.formatters = {}; + +/** + * Previous log timestamp. + */ + +var prevTime; + +/** + * Select a color. + * @param {String} namespace + * @return {Number} + * @api private + */ + +function selectColor(namespace) { + var hash = 0, i; + + for (i in namespace) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return exports.colors[Math.abs(hash) % exports.colors.length]; +} + +/** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + +function createDebug(namespace) { + + function debug() { + // disabled? + if (!debug.enabled) return; + + var self = debug; + + // set `diff` timestamp + var curr = +new Date(); + var ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + // turn the `arguments` into a proper Array + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + args[0] = exports.coerce(args[0]); + + if ('string' !== typeof args[0]) { + // anything else let's inspect with %O + args.unshift('%O'); + } + + // apply any `formatters` transformations + var index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { + // if we encounter an escaped % then don't increase the array index + if (match === '%%') return match; + index++; + var formatter = exports.formatters[format]; + if ('function' === typeof formatter) { + var val = args[index]; + match = formatter.call(self, val); + + // now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // apply env-specific formatting (colors, etc.) + exports.formatArgs.call(self, args); + + var logFn = debug.log || exports.log || console.log.bind(console); + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.enabled = exports.enabled(namespace); + debug.useColors = exports.useColors(); + debug.color = selectColor(namespace); + + // env-specific initialization logic for debug instances + if ('function' === typeof exports.init) { + exports.init(debug); + } + + return debug; +} + +/** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + +function enable(namespaces) { + exports.save(namespaces); + + exports.names = []; + exports.skips = []; + + var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + var len = split.length; + + for (var i = 0; i < len; i++) { + if (!split[i]) continue; // ignore empty strings + namespaces = split[i].replace(/\*/g, '.*?'); + if (namespaces[0] === '-') { + exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); + } else { + exports.names.push(new RegExp('^' + namespaces + '$')); + } + } +} + +/** + * Disable debug output. + * + * @api public + */ + +function disable() { + exports.enable(''); +} + +/** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + +function enabled(name) { + var i, len; + for (i = 0, len = exports.skips.length; i < len; i++) { + if (exports.skips[i].test(name)) { + return false; + } + } + for (i = 0, len = exports.names.length; i < len; i++) { + if (exports.names[i].test(name)) { + return true; + } + } + return false; +} + +/** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + +function coerce(val) { + if (val instanceof Error) return val.stack || val.message; + return val; +} + +},{"ms":267}],187:[function(require,module,exports){ +'use strict'; + +exports.utils = require('./des/utils'); +exports.Cipher = require('./des/cipher'); +exports.DES = require('./des/des'); +exports.CBC = require('./des/cbc'); +exports.EDE = require('./des/ede'); + +},{"./des/cbc":188,"./des/cipher":189,"./des/des":190,"./des/ede":191,"./des/utils":192}],188:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var proto = {}; + +function CBCState(iv) { + assert.equal(iv.length, 8, 'Invalid IV length'); + + this.iv = new Array(8); + for (var i = 0; i < this.iv.length; i++) + this.iv[i] = iv[i]; +} + +function instantiate(Base) { + function CBC(options) { + Base.call(this, options); + this._cbcInit(); + } + inherits(CBC, Base); + + var keys = Object.keys(proto); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + CBC.prototype[key] = proto[key]; + } + + CBC.create = function create(options) { + return new CBC(options); + }; + + return CBC; +} + +exports.instantiate = instantiate; + +proto._cbcInit = function _cbcInit() { + var state = new CBCState(this.options.iv); + this._cbcState = state; +}; + +proto._update = function _update(inp, inOff, out, outOff) { + var state = this._cbcState; + var superProto = this.constructor.super_.prototype; + + var iv = state.iv; + if (this.type === 'encrypt') { + for (var i = 0; i < this.blockSize; i++) + iv[i] ^= inp[inOff + i]; + + superProto._update.call(this, iv, 0, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + iv[i] = out[outOff + i]; + } else { + superProto._update.call(this, inp, inOff, out, outOff); + + for (var i = 0; i < this.blockSize; i++) + out[outOff + i] ^= iv[i]; + + for (var i = 0; i < this.blockSize; i++) + iv[i] = inp[inOff + i]; + } +}; + +},{"inherits":258,"minimalistic-assert":265}],189:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); + +function Cipher(options) { + this.options = options; + + this.type = this.options.type; + this.blockSize = 8; + this._init(); + + this.buffer = new Array(this.blockSize); + this.bufferOff = 0; +} +module.exports = Cipher; + +Cipher.prototype._init = function _init() { + // Might be overrided +}; + +Cipher.prototype.update = function update(data) { + if (data.length === 0) + return []; + + if (this.type === 'decrypt') + return this._updateDecrypt(data); + else + return this._updateEncrypt(data); +}; + +Cipher.prototype._buffer = function _buffer(data, off) { + // Append data to buffer + var min = Math.min(this.buffer.length - this.bufferOff, data.length - off); + for (var i = 0; i < min; i++) + this.buffer[this.bufferOff + i] = data[off + i]; + this.bufferOff += min; + + // Shift next + return min; +}; + +Cipher.prototype._flushBuffer = function _flushBuffer(out, off) { + this._update(this.buffer, 0, out, off); + this.bufferOff = 0; + return this.blockSize; +}; + +Cipher.prototype._updateEncrypt = function _updateEncrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = ((this.bufferOff + data.length) / this.blockSize) | 0; + var out = new Array(count * this.blockSize); + + if (this.bufferOff !== 0) { + inputOff += this._buffer(data, inputOff); + + if (this.bufferOff === this.buffer.length) + outputOff += this._flushBuffer(out, outputOff); + } + + // Write blocks + var max = data.length - ((data.length - inputOff) % this.blockSize); + for (; inputOff < max; inputOff += this.blockSize) { + this._update(data, inputOff, out, outputOff); + outputOff += this.blockSize; + } + + // Queue rest + for (; inputOff < data.length; inputOff++, this.bufferOff++) + this.buffer[this.bufferOff] = data[inputOff]; + + return out; +}; + +Cipher.prototype._updateDecrypt = function _updateDecrypt(data) { + var inputOff = 0; + var outputOff = 0; + + var count = Math.ceil((this.bufferOff + data.length) / this.blockSize) - 1; + var out = new Array(count * this.blockSize); + + // TODO(indutny): optimize it, this is far from optimal + for (; count > 0; count--) { + inputOff += this._buffer(data, inputOff); + outputOff += this._flushBuffer(out, outputOff); + } + + // Buffer rest of the input + inputOff += this._buffer(data, inputOff); + + return out; +}; + +Cipher.prototype.final = function final(buffer) { + var first; + if (buffer) + first = this.update(buffer); + + var last; + if (this.type === 'encrypt') + last = this._finalEncrypt(); + else + last = this._finalDecrypt(); + + if (first) + return first.concat(last); + else + return last; +}; + +Cipher.prototype._pad = function _pad(buffer, off) { + if (off === 0) + return false; + + while (off < buffer.length) + buffer[off++] = 0; + + return true; +}; + +Cipher.prototype._finalEncrypt = function _finalEncrypt() { + if (!this._pad(this.buffer, this.bufferOff)) + return []; + + var out = new Array(this.blockSize); + this._update(this.buffer, 0, out, 0); + return out; +}; + +Cipher.prototype._unpad = function _unpad(buffer) { + return buffer; +}; + +Cipher.prototype._finalDecrypt = function _finalDecrypt() { + assert.equal(this.bufferOff, this.blockSize, 'Not enough data to decrypt'); + var out = new Array(this.blockSize); + this._flushBuffer(out, 0); + + return this._unpad(out); +}; + +},{"minimalistic-assert":265}],190:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var utils = require('./utils'); +var Cipher = require('./cipher'); + +function DESState() { + this.tmp = new Array(2); + this.keys = null; +} + +function DES(options) { + Cipher.call(this, options); + + var state = new DESState(); + this._desState = state; + + this.deriveKeys(state, options.key); +} +inherits(DES, Cipher); +module.exports = DES; + +DES.create = function create(options) { + return new DES(options); +}; + +var shiftTable = [ + 1, 1, 2, 2, 2, 2, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 1 +]; + +DES.prototype.deriveKeys = function deriveKeys(state, key) { + state.keys = new Array(16 * 2); + + assert.equal(key.length, this.blockSize, 'Invalid key length'); + + var kL = utils.readUInt32BE(key, 0); + var kR = utils.readUInt32BE(key, 4); + + utils.pc1(kL, kR, state.tmp, 0); + kL = state.tmp[0]; + kR = state.tmp[1]; + for (var i = 0; i < state.keys.length; i += 2) { + var shift = shiftTable[i >>> 1]; + kL = utils.r28shl(kL, shift); + kR = utils.r28shl(kR, shift); + utils.pc2(kL, kR, state.keys, i); + } +}; + +DES.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._desState; + + var l = utils.readUInt32BE(inp, inOff); + var r = utils.readUInt32BE(inp, inOff + 4); + + // Initial Permutation + utils.ip(l, r, state.tmp, 0); + l = state.tmp[0]; + r = state.tmp[1]; + + if (this.type === 'encrypt') + this._encrypt(state, l, r, state.tmp, 0); + else + this._decrypt(state, l, r, state.tmp, 0); + + l = state.tmp[0]; + r = state.tmp[1]; + + utils.writeUInt32BE(out, l, outOff); + utils.writeUInt32BE(out, r, outOff + 4); +}; + +DES.prototype._pad = function _pad(buffer, off) { + var value = buffer.length - off; + for (var i = off; i < buffer.length; i++) + buffer[i] = value; + + return true; +}; + +DES.prototype._unpad = function _unpad(buffer) { + var pad = buffer[buffer.length - 1]; + for (var i = buffer.length - pad; i < buffer.length; i++) + assert.equal(buffer[i], pad); + + return buffer.slice(0, buffer.length - pad); +}; + +DES.prototype._encrypt = function _encrypt(state, lStart, rStart, out, off) { + var l = lStart; + var r = rStart; + + // Apply f() x16 times + for (var i = 0; i < state.keys.length; i += 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(r, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = r; + r = (l ^ f) >>> 0; + l = t; + } + + // Reverse Initial Permutation + utils.rip(r, l, out, off); +}; + +DES.prototype._decrypt = function _decrypt(state, lStart, rStart, out, off) { + var l = rStart; + var r = lStart; + + // Apply f() x16 times + for (var i = state.keys.length - 2; i >= 0; i -= 2) { + var keyL = state.keys[i]; + var keyR = state.keys[i + 1]; + + // f(r, k) + utils.expand(l, state.tmp, 0); + + keyL ^= state.tmp[0]; + keyR ^= state.tmp[1]; + var s = utils.substitute(keyL, keyR); + var f = utils.permute(s); + + var t = l; + l = (r ^ f) >>> 0; + r = t; + } + + // Reverse Initial Permutation + utils.rip(l, r, out, off); +}; + +},{"./cipher":189,"./utils":192,"inherits":258,"minimalistic-assert":265}],191:[function(require,module,exports){ +'use strict'; + +var assert = require('minimalistic-assert'); +var inherits = require('inherits'); + +var Cipher = require('./cipher'); +var DES = require('./des'); + +function EDEState(type, key) { + assert.equal(key.length, 24, 'Invalid key length'); + + var k1 = key.slice(0, 8); + var k2 = key.slice(8, 16); + var k3 = key.slice(16, 24); + + if (type === 'encrypt') { + this.ciphers = [ + DES.create({ type: 'encrypt', key: k1 }), + DES.create({ type: 'decrypt', key: k2 }), + DES.create({ type: 'encrypt', key: k3 }) + ]; + } else { + this.ciphers = [ + DES.create({ type: 'decrypt', key: k3 }), + DES.create({ type: 'encrypt', key: k2 }), + DES.create({ type: 'decrypt', key: k1 }) + ]; + } +} + +function EDE(options) { + Cipher.call(this, options); + + var state = new EDEState(this.type, this.options.key); + this._edeState = state; +} +inherits(EDE, Cipher); + +module.exports = EDE; + +EDE.create = function create(options) { + return new EDE(options); +}; + +EDE.prototype._update = function _update(inp, inOff, out, outOff) { + var state = this._edeState; + + state.ciphers[0]._update(inp, inOff, out, outOff); + state.ciphers[1]._update(out, outOff, out, outOff); + state.ciphers[2]._update(out, outOff, out, outOff); +}; + +EDE.prototype._pad = DES.prototype._pad; +EDE.prototype._unpad = DES.prototype._unpad; + +},{"./cipher":189,"./des":190,"inherits":258,"minimalistic-assert":265}],192:[function(require,module,exports){ +'use strict'; + +exports.readUInt32BE = function readUInt32BE(bytes, off) { + var res = (bytes[0 + off] << 24) | + (bytes[1 + off] << 16) | + (bytes[2 + off] << 8) | + bytes[3 + off]; + return res >>> 0; +}; + +exports.writeUInt32BE = function writeUInt32BE(bytes, value, off) { + bytes[0 + off] = value >>> 24; + bytes[1 + off] = (value >>> 16) & 0xff; + bytes[2 + off] = (value >>> 8) & 0xff; + bytes[3 + off] = value & 0xff; +}; + +exports.ip = function ip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + + for (var i = 6; i >= 0; i -= 2) { + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + } + for (var j = 1; j <= 25; j += 8) { + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.rip = function rip(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + for (var i = 0; i < 4; i++) { + for (var j = 24; j >= 0; j -= 8) { + outL <<= 1; + outL |= (inR >>> (j + i)) & 1; + outL <<= 1; + outL |= (inL >>> (j + i)) & 1; + } + } + for (var i = 4; i < 8; i++) { + for (var j = 24; j >= 0; j -= 8) { + outR <<= 1; + outR |= (inR >>> (j + i)) & 1; + outR <<= 1; + outR |= (inL >>> (j + i)) & 1; + } + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.pc1 = function pc1(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + // 7, 15, 23, 31, 39, 47, 55, 63 + // 6, 14, 22, 30, 39, 47, 55, 63 + // 5, 13, 21, 29, 39, 47, 55, 63 + // 4, 12, 20, 28 + for (var i = 7; i >= 5; i--) { + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outL <<= 1; + outL |= (inR >> (j + i)) & 1; + } + + // 1, 9, 17, 25, 33, 41, 49, 57 + // 2, 10, 18, 26, 34, 42, 50, 58 + // 3, 11, 19, 27, 35, 43, 51, 59 + // 36, 44, 52, 60 + for (var i = 1; i <= 3; i++) { + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inR >> (j + i)) & 1; + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + } + for (var j = 0; j <= 24; j += 8) { + outR <<= 1; + outR |= (inL >> (j + i)) & 1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.r28shl = function r28shl(num, shift) { + return ((num << shift) & 0xfffffff) | (num >>> (28 - shift)); +}; + +var pc2table = [ + // inL => outL + 14, 11, 17, 4, 27, 23, 25, 0, + 13, 22, 7, 18, 5, 9, 16, 24, + 2, 20, 12, 21, 1, 8, 15, 26, + + // inR => outR + 15, 4, 25, 19, 9, 1, 26, 16, + 5, 11, 23, 8, 12, 7, 17, 0, + 22, 3, 10, 14, 6, 20, 27, 24 +]; + +exports.pc2 = function pc2(inL, inR, out, off) { + var outL = 0; + var outR = 0; + + var len = pc2table.length >>> 1; + for (var i = 0; i < len; i++) { + outL <<= 1; + outL |= (inL >>> pc2table[i]) & 0x1; + } + for (var i = len; i < pc2table.length; i++) { + outR <<= 1; + outR |= (inR >>> pc2table[i]) & 0x1; + } + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +exports.expand = function expand(r, out, off) { + var outL = 0; + var outR = 0; + + outL = ((r & 1) << 5) | (r >>> 27); + for (var i = 23; i >= 15; i -= 4) { + outL <<= 6; + outL |= (r >>> i) & 0x3f; + } + for (var i = 11; i >= 3; i -= 4) { + outR |= (r >>> i) & 0x3f; + outR <<= 6; + } + outR |= ((r & 0x1f) << 1) | (r >>> 31); + + out[off + 0] = outL >>> 0; + out[off + 1] = outR >>> 0; +}; + +var sTable = [ + 14, 0, 4, 15, 13, 7, 1, 4, 2, 14, 15, 2, 11, 13, 8, 1, + 3, 10, 10, 6, 6, 12, 12, 11, 5, 9, 9, 5, 0, 3, 7, 8, + 4, 15, 1, 12, 14, 8, 8, 2, 13, 4, 6, 9, 2, 1, 11, 7, + 15, 5, 12, 11, 9, 3, 7, 14, 3, 10, 10, 0, 5, 6, 0, 13, + + 15, 3, 1, 13, 8, 4, 14, 7, 6, 15, 11, 2, 3, 8, 4, 14, + 9, 12, 7, 0, 2, 1, 13, 10, 12, 6, 0, 9, 5, 11, 10, 5, + 0, 13, 14, 8, 7, 10, 11, 1, 10, 3, 4, 15, 13, 4, 1, 2, + 5, 11, 8, 6, 12, 7, 6, 12, 9, 0, 3, 5, 2, 14, 15, 9, + + 10, 13, 0, 7, 9, 0, 14, 9, 6, 3, 3, 4, 15, 6, 5, 10, + 1, 2, 13, 8, 12, 5, 7, 14, 11, 12, 4, 11, 2, 15, 8, 1, + 13, 1, 6, 10, 4, 13, 9, 0, 8, 6, 15, 9, 3, 8, 0, 7, + 11, 4, 1, 15, 2, 14, 12, 3, 5, 11, 10, 5, 14, 2, 7, 12, + + 7, 13, 13, 8, 14, 11, 3, 5, 0, 6, 6, 15, 9, 0, 10, 3, + 1, 4, 2, 7, 8, 2, 5, 12, 11, 1, 12, 10, 4, 14, 15, 9, + 10, 3, 6, 15, 9, 0, 0, 6, 12, 10, 11, 1, 7, 13, 13, 8, + 15, 9, 1, 4, 3, 5, 14, 11, 5, 12, 2, 7, 8, 2, 4, 14, + + 2, 14, 12, 11, 4, 2, 1, 12, 7, 4, 10, 7, 11, 13, 6, 1, + 8, 5, 5, 0, 3, 15, 15, 10, 13, 3, 0, 9, 14, 8, 9, 6, + 4, 11, 2, 8, 1, 12, 11, 7, 10, 1, 13, 14, 7, 2, 8, 13, + 15, 6, 9, 15, 12, 0, 5, 9, 6, 10, 3, 4, 0, 5, 14, 3, + + 12, 10, 1, 15, 10, 4, 15, 2, 9, 7, 2, 12, 6, 9, 8, 5, + 0, 6, 13, 1, 3, 13, 4, 14, 14, 0, 7, 11, 5, 3, 11, 8, + 9, 4, 14, 3, 15, 2, 5, 12, 2, 9, 8, 5, 12, 15, 3, 10, + 7, 11, 0, 14, 4, 1, 10, 7, 1, 6, 13, 0, 11, 8, 6, 13, + + 4, 13, 11, 0, 2, 11, 14, 7, 15, 4, 0, 9, 8, 1, 13, 10, + 3, 14, 12, 3, 9, 5, 7, 12, 5, 2, 10, 15, 6, 8, 1, 6, + 1, 6, 4, 11, 11, 13, 13, 8, 12, 1, 3, 4, 7, 10, 14, 7, + 10, 9, 15, 5, 6, 0, 8, 15, 0, 14, 5, 2, 9, 3, 2, 12, + + 13, 1, 2, 15, 8, 13, 4, 8, 6, 10, 15, 3, 11, 7, 1, 4, + 10, 12, 9, 5, 3, 6, 14, 11, 5, 0, 0, 14, 12, 9, 7, 2, + 7, 2, 11, 1, 4, 14, 1, 7, 9, 4, 12, 10, 14, 8, 2, 13, + 0, 15, 6, 12, 10, 9, 13, 0, 15, 3, 3, 5, 5, 6, 8, 11 +]; + +exports.substitute = function substitute(inL, inR) { + var out = 0; + for (var i = 0; i < 4; i++) { + var b = (inL >>> (18 - i * 6)) & 0x3f; + var sb = sTable[i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + for (var i = 0; i < 4; i++) { + var b = (inR >>> (18 - i * 6)) & 0x3f; + var sb = sTable[4 * 0x40 + i * 0x40 + b]; + + out <<= 4; + out |= sb; + } + return out >>> 0; +}; + +var permuteTable = [ + 16, 25, 12, 11, 3, 20, 4, 15, 31, 17, 9, 6, 27, 14, 1, 22, + 30, 24, 8, 18, 0, 5, 29, 23, 13, 19, 2, 26, 10, 21, 28, 7 +]; + +exports.permute = function permute(num) { + var out = 0; + for (var i = 0; i < permuteTable.length; i++) { + out <<= 1; + out |= (num >>> permuteTable[i]) & 0x1; + } + return out >>> 0; +}; + +exports.padSplit = function padSplit(num, size, group) { + var str = num.toString(2); + while (str.length < size) + str = '0' + str; + + var out = []; + for (var i = 0; i < size; i += group) + out.push(str.slice(i, i + group)); + return out.join(' '); +}; + +},{}],193:[function(require,module,exports){ +(function (Buffer){(function (){ +var generatePrime = require('./lib/generatePrime') +var primes = require('./lib/primes.json') + +var DH = require('./lib/dh') + +function getDiffieHellman (mod) { + var prime = new Buffer(primes[mod].prime, 'hex') + var gen = new Buffer(primes[mod].gen, 'hex') + + return new DH(prime, gen) +} + +var ENCODINGS = { + 'binary': true, 'hex': true, 'base64': true +} + +function createDiffieHellman (prime, enc, generator, genc) { + if (Buffer.isBuffer(enc) || ENCODINGS[enc] === undefined) { + return createDiffieHellman(prime, 'binary', enc, generator) + } + + enc = enc || 'binary' + genc = genc || 'binary' + generator = generator || new Buffer([2]) + + if (!Buffer.isBuffer(generator)) { + generator = new Buffer(generator, genc) + } + + if (typeof prime === 'number') { + return new DH(generatePrime(prime, generator), generator, true) + } + + if (!Buffer.isBuffer(prime)) { + prime = new Buffer(prime, enc) + } + + return new DH(prime, generator, true) +} + +exports.DiffieHellmanGroup = exports.createDiffieHellmanGroup = exports.getDiffieHellman = getDiffieHellman +exports.createDiffieHellman = exports.DiffieHellman = createDiffieHellman + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./lib/dh":194,"./lib/generatePrime":195,"./lib/primes.json":196,"buffer":110}],194:[function(require,module,exports){ +(function (Buffer){(function (){ +var BN = require('bn.js'); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var TWENTYFOUR = new BN(24); +var ELEVEN = new BN(11); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var primes = require('./generatePrime'); +var randomBytes = require('randombytes'); +module.exports = DH; + +function setPublicKey(pub, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(pub)) { + pub = new Buffer(pub, enc); + } + this._pub = new BN(pub); + return this; +} + +function setPrivateKey(priv, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(priv)) { + priv = new Buffer(priv, enc); + } + this._priv = new BN(priv); + return this; +} + +var primeCache = {}; +function checkPrime(prime, generator) { + var gen = generator.toString('hex'); + var hex = [gen, prime.toString(16)].join('_'); + if (hex in primeCache) { + return primeCache[hex]; + } + var error = 0; + + if (prime.isEven() || + !primes.simpleSieve || + !primes.fermatTest(prime) || + !millerRabin.test(prime)) { + //not a prime so +1 + error += 1; + + if (gen === '02' || gen === '05') { + // we'd be able to check the generator + // it would fail so +8 + error += 8; + } else { + //we wouldn't be able to test the generator + // so +4 + error += 4; + } + primeCache[hex] = error; + return error; + } + if (!millerRabin.test(prime.shrn(1))) { + //not a safe prime + error += 2; + } + var rem; + switch (gen) { + case '02': + if (prime.mod(TWENTYFOUR).cmp(ELEVEN)) { + // unsuidable generator + error += 8; + } + break; + case '05': + rem = prime.mod(TEN); + if (rem.cmp(THREE) && rem.cmp(SEVEN)) { + // prime mod 10 needs to equal 3 or 7 + error += 8; + } + break; + default: + error += 4; + } + primeCache[hex] = error; + return error; +} + +function DH(prime, generator, malleable) { + this.setGenerator(generator); + this.__prime = new BN(prime); + this._prime = BN.mont(this.__prime); + this._primeLen = prime.length; + this._pub = undefined; + this._priv = undefined; + this._primeCode = undefined; + if (malleable) { + this.setPublicKey = setPublicKey; + this.setPrivateKey = setPrivateKey; + } else { + this._primeCode = 8; + } +} +Object.defineProperty(DH.prototype, 'verifyError', { + enumerable: true, + get: function () { + if (typeof this._primeCode !== 'number') { + this._primeCode = checkPrime(this.__prime, this.__gen); + } + return this._primeCode; + } +}); +DH.prototype.generateKeys = function () { + if (!this._priv) { + this._priv = new BN(randomBytes(this._primeLen)); + } + this._pub = this._gen.toRed(this._prime).redPow(this._priv).fromRed(); + return this.getPublicKey(); +}; + +DH.prototype.computeSecret = function (other) { + other = new BN(other); + other = other.toRed(this._prime); + var secret = other.redPow(this._priv).fromRed(); + var out = new Buffer(secret.toArray()); + var prime = this.getPrime(); + if (out.length < prime.length) { + var front = new Buffer(prime.length - out.length); + front.fill(0); + out = Buffer.concat([front, out]); + } + return out; +}; + +DH.prototype.getPublicKey = function getPublicKey(enc) { + return formatReturnValue(this._pub, enc); +}; + +DH.prototype.getPrivateKey = function getPrivateKey(enc) { + return formatReturnValue(this._priv, enc); +}; + +DH.prototype.getPrime = function (enc) { + return formatReturnValue(this.__prime, enc); +}; + +DH.prototype.getGenerator = function (enc) { + return formatReturnValue(this._gen, enc); +}; + +DH.prototype.setGenerator = function (gen, enc) { + enc = enc || 'utf8'; + if (!Buffer.isBuffer(gen)) { + gen = new Buffer(gen, enc); + } + this.__gen = gen; + this._gen = new BN(gen); + return this; +}; + +function formatReturnValue(bn, enc) { + var buf = new Buffer(bn.toArray()); + if (!enc) { + return buf; + } else { + return buf.toString(enc); + } +} + +}).call(this)}).call(this,require("buffer").Buffer) +},{"./generatePrime":195,"bn.js":82,"buffer":110,"miller-rabin":264,"randombytes":303}],195:[function(require,module,exports){ +var randomBytes = require('randombytes'); +module.exports = findPrime; +findPrime.simpleSieve = simpleSieve; +findPrime.fermatTest = fermatTest; +var BN = require('bn.js'); +var TWENTYFOUR = new BN(24); +var MillerRabin = require('miller-rabin'); +var millerRabin = new MillerRabin(); +var ONE = new BN(1); +var TWO = new BN(2); +var FIVE = new BN(5); +var SIXTEEN = new BN(16); +var EIGHT = new BN(8); +var TEN = new BN(10); +var THREE = new BN(3); +var SEVEN = new BN(7); +var ELEVEN = new BN(11); +var FOUR = new BN(4); +var TWELVE = new BN(12); +var primes = null; + +function _getPrimes() { + if (primes !== null) + return primes; + + var limit = 0x100000; + var res = []; + res[0] = 2; + for (var i = 1, k = 3; k < limit; k += 2) { + var sqrt = Math.ceil(Math.sqrt(k)); + for (var j = 0; j < i && res[j] <= sqrt; j++) + if (k % res[j] === 0) + break; + + if (i !== j && res[j] <= sqrt) + continue; + + res[i++] = k; + } + primes = res; + return res; +} + +function simpleSieve(p) { + var primes = _getPrimes(); + + for (var i = 0; i < primes.length; i++) + if (p.modn(primes[i]) === 0) { + if (p.cmpn(primes[i]) === 0) { + return true; + } else { + return false; + } + } + + return true; +} + +function fermatTest(p) { + var red = BN.mont(p); + return TWO.toRed(red).redPow(p.subn(1)).fromRed().cmpn(1) === 0; +} + +function findPrime(bits, gen) { + if (bits < 16) { + // this is what openssl does + if (gen === 2 || gen === 5) { + return new BN([0x8c, 0x7b]); + } else { + return new BN([0x8c, 0x27]); + } + } + gen = new BN(gen); + + var num, n2; + + while (true) { + num = new BN(randomBytes(Math.ceil(bits / 8))); + while (num.bitLength() > bits) { + num.ishrn(1); + } + if (num.isEven()) { + num.iadd(ONE); + } + if (!num.testn(1)) { + num.iadd(TWO); + } + if (!gen.cmp(TWO)) { + while (num.mod(TWENTYFOUR).cmp(ELEVEN)) { + num.iadd(FOUR); + } + } else if (!gen.cmp(FIVE)) { + while (num.mod(TEN).cmp(THREE)) { + num.iadd(FOUR); + } + } + n2 = num.shrn(1); + if (simpleSieve(n2) && simpleSieve(num) && + fermatTest(n2) && fermatTest(num) && + millerRabin.test(n2) && millerRabin.test(num)) { + return num; + } + } + +} + +},{"bn.js":82,"miller-rabin":264,"randombytes":303}],196:[function(require,module,exports){ +module.exports={ + "modp1": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff" + }, + "modp2": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff" + }, + "modp5": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff" + }, + "modp14": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff" + }, + "modp15": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff" + }, + "modp16": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff" + }, + "modp17": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff" + }, + "modp18": { + "gen": "02", + "prime": "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff" + } +} +},{}],197:[function(require,module,exports){ +var assert = require('assert') +var BigInteger = require('bigi') + +var Point = require('./point') + +function Curve (p, a, b, Gx, Gy, n, h) { + this.p = p + this.a = a + this.b = b + this.G = Point.fromAffine(this, Gx, Gy) + this.n = n + this.h = h + + this.infinity = new Point(this, null, null, BigInteger.ZERO) + + // result caching + this.pOverFour = p.add(BigInteger.ONE).shiftRight(2) + + // determine size of p in bytes + this.pLength = Math.floor((this.p.bitLength() + 7) / 8) +} + +Curve.prototype.pointFromX = function (isOdd, x) { + var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p) + var beta = alpha.modPow(this.pOverFour, this.p) // XXX: not compatible with all curves + + var y = beta + if (beta.isEven() ^ !isOdd) { + y = this.p.subtract(y) // -y % p + } + + return Point.fromAffine(this, x, y) +} + +Curve.prototype.isInfinity = function (Q) { + if (Q === this.infinity) return true + + return Q.z.signum() === 0 && Q.y.signum() !== 0 +} + +Curve.prototype.isOnCurve = function (Q) { + if (this.isInfinity(Q)) return true + + var x = Q.affineX + var y = Q.affineY + var a = this.a + var b = this.b + var p = this.p + + // Check that xQ and yQ are integers in the interval [0, p - 1] + if (x.signum() < 0 || x.compareTo(p) >= 0) return false + if (y.signum() < 0 || y.compareTo(p) >= 0) return false + + // and check that y^2 = x^3 + ax + b (mod p) + var lhs = y.square().mod(p) + var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p) + return lhs.equals(rhs) +} + +/** + * Validate an elliptic curve point. + * + * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive + */ +Curve.prototype.validate = function (Q) { + // Check Q != O + assert(!this.isInfinity(Q), 'Point is at infinity') + assert(this.isOnCurve(Q), 'Point is not on the curve') + + // Check nQ = O (where Q is a scalar multiple of G) + var nQ = Q.multiply(this.n) + assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G') + + return true +} + +module.exports = Curve + +},{"./point":201,"assert":23,"bigi":32}],198:[function(require,module,exports){ +module.exports={ + "secp128r1": { + "p": "fffffffdffffffffffffffffffffffff", + "a": "fffffffdfffffffffffffffffffffffc", + "b": "e87579c11079f43dd824993c2cee5ed3", + "n": "fffffffe0000000075a30d1b9038a115", + "h": "01", + "Gx": "161ff7528b899b2d0c28607ca52c5b86", + "Gy": "cf5ac8395bafeb13c02da292dded7a83" + }, + "secp160k1": { + "p": "fffffffffffffffffffffffffffffffeffffac73", + "a": "00", + "b": "07", + "n": "0100000000000000000001b8fa16dfab9aca16b6b3", + "h": "01", + "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb", + "Gy": "938cf935318fdced6bc28286531733c3f03c4fee" + }, + "secp160r1": { + "p": "ffffffffffffffffffffffffffffffff7fffffff", + "a": "ffffffffffffffffffffffffffffffff7ffffffc", + "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45", + "n": "0100000000000000000001f4c8f927aed3ca752257", + "h": "01", + "Gx": "4a96b5688ef573284664698968c38bb913cbfc82", + "Gy": "23a628553168947d59dcc912042351377ac5fb32" + }, + "secp192k1": { + "p": "fffffffffffffffffffffffffffffffffffffffeffffee37", + "a": "00", + "b": "03", + "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d", + "h": "01", + "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d", + "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d" + }, + "secp192r1": { + "p": "fffffffffffffffffffffffffffffffeffffffffffffffff", + "a": "fffffffffffffffffffffffffffffffefffffffffffffffc", + "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", + "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831", + "h": "01", + "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012", + "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811" + }, + "secp256k1": { + "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f", + "a": "00", + "b": "07", + "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", + "h": "01", + "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8" + }, + "secp256r1": { + "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff", + "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc", + "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", + "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", + "h": "01", + "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", + "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5" + } +} + +},{}],199:[function(require,module,exports){ +var Point = require('./point') +var Curve = require('./curve') + +var getCurveByName = require('./names') + +module.exports = { + Curve: Curve, + Point: Point, + getCurveByName: getCurveByName +} + +},{"./curve":197,"./names":200,"./point":201}],200:[function(require,module,exports){ +var BigInteger = require('bigi') + +var curves = require('./curves.json') +var Curve = require('./curve') + +function getCurveByName (name) { + var curve = curves[name] + if (!curve) return null + + var p = new BigInteger(curve.p, 16) + var a = new BigInteger(curve.a, 16) + var b = new BigInteger(curve.b, 16) + var n = new BigInteger(curve.n, 16) + var h = new BigInteger(curve.h, 16) + var Gx = new BigInteger(curve.Gx, 16) + var Gy = new BigInteger(curve.Gy, 16) + + return new Curve(p, a, b, Gx, Gy, n, h) +} + +module.exports = getCurveByName + +},{"./curve":197,"./curves.json":198,"bigi":32}],201:[function(require,module,exports){ +var assert = require('assert') +var Buffer = require('safe-buffer').Buffer +var BigInteger = require('bigi') + +var THREE = BigInteger.valueOf(3) + +function Point (curve, x, y, z) { + assert.notStrictEqual(z, undefined, 'Missing Z coordinate') + + this.curve = curve + this.x = x + this.y = y + this.z = z + this._zInv = null + + this.compressed = true +} + +Object.defineProperty(Point.prototype, 'zInv', { + get: function () { + if (this._zInv === null) { + this._zInv = this.z.modInverse(this.curve.p) + } + + return this._zInv + } +}) + +Object.defineProperty(Point.prototype, 'affineX', { + get: function () { + return this.x.multiply(this.zInv).mod(this.curve.p) + } +}) + +Object.defineProperty(Point.prototype, 'affineY', { + get: function () { + return this.y.multiply(this.zInv).mod(this.curve.p) + } +}) + +Point.fromAffine = function (curve, x, y) { + return new Point(curve, x, y, BigInteger.ONE) +} + +Point.prototype.equals = function (other) { + if (other === this) return true + if (this.curve.isInfinity(this)) return this.curve.isInfinity(other) + if (this.curve.isInfinity(other)) return this.curve.isInfinity(this) + + // u = Y2 * Z1 - Y1 * Z2 + var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p) + + if (u.signum() !== 0) return false + + // v = X2 * Z1 - X1 * Z2 + var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p) + + return v.signum() === 0 +} + +Point.prototype.negate = function () { + var y = this.curve.p.subtract(this.y) + + return new Point(this.curve, this.x, y, this.z) +} + +Point.prototype.add = function (b) { + if (this.curve.isInfinity(this)) return b + if (this.curve.isInfinity(b)) return this + + var x1 = this.x + var y1 = this.y + var x2 = b.x + var y2 = b.y + + // u = Y2 * Z1 - Y1 * Z2 + var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p) + // v = X2 * Z1 - X1 * Z2 + var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p) + + if (v.signum() === 0) { + if (u.signum() === 0) { + return this.twice() // this == b, so double + } + + return this.curve.infinity // this = -b, so infinity + } + + var v2 = v.square() + var v3 = v2.multiply(v) + var x1v2 = x1.multiply(v2) + var zu2 = u.square().multiply(this.z) + + // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) + var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p) + // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 + var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p) + // z3 = v^3 * z1 * z2 + var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p) + + return new Point(this.curve, x3, y3, z3) +} + +Point.prototype.twice = function () { + if (this.curve.isInfinity(this)) return this + if (this.y.signum() === 0) return this.curve.infinity + + var x1 = this.x + var y1 = this.y + + var y1z1 = y1.multiply(this.z).mod(this.curve.p) + var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p) + var a = this.curve.a + + // w = 3 * x1^2 + a * z1^2 + var w = x1.square().multiply(THREE) + + if (a.signum() !== 0) { + w = w.add(this.z.square().multiply(a)) + } + + w = w.mod(this.curve.p) + // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) + var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p) + // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 + var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p) + // z3 = 8 * (y1 * z1)^3 + var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p) + + return new Point(this.curve, x3, y3, z3) +} + +// Simple NAF (Non-Adjacent Form) multiplication algorithm +// TODO: modularize the multiplication algorithm +Point.prototype.multiply = function (k) { + if (this.curve.isInfinity(this)) return this + if (k.signum() === 0) return this.curve.infinity + + var e = k + var h = e.multiply(THREE) + + var neg = this.negate() + var R = this + + for (var i = h.bitLength() - 2; i > 0; --i) { + var hBit = h.testBit(i) + var eBit = e.testBit(i) + + R = R.twice() + + if (hBit !== eBit) { + R = R.add(hBit ? this : neg) + } + } + + return R +} + +// Compute this*j + x*k (simultaneous multiplication) +Point.prototype.multiplyTwo = function (j, x, k) { + var i = Math.max(j.bitLength(), k.bitLength()) - 1 + var R = this.curve.infinity + var both = this.add(x) + + while (i >= 0) { + var jBit = j.testBit(i) + var kBit = k.testBit(i) + + R = R.twice() + + if (jBit) { + if (kBit) { + R = R.add(both) + } else { + R = R.add(this) + } + } else if (kBit) { + R = R.add(x) + } + --i + } + + return R +} + +Point.prototype.getEncoded = function (compressed) { + if (compressed == null) compressed = this.compressed + if (this.curve.isInfinity(this)) return Buffer.alloc(1, 0) // Infinity point encoded is simply '00' + + var x = this.affineX + var y = this.affineY + var byteLength = this.curve.pLength + var buffer + + // 0x02/0x03 | X + if (compressed) { + buffer = Buffer.allocUnsafe(1 + byteLength) + buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0) + + // 0x04 | X | Y + } else { + buffer = Buffer.allocUnsafe(1 + byteLength + byteLength) + buffer.writeUInt8(0x04, 0) + + y.toBuffer(byteLength).copy(buffer, 1 + byteLength) + } + + x.toBuffer(byteLength).copy(buffer, 1) + + return buffer +} + +Point.decodeFrom = function (curve, buffer) { + var type = buffer.readUInt8(0) + var compressed = (type !== 4) + + var byteLength = Math.floor((curve.p.bitLength() + 7) / 8) + var x = BigInteger.fromBuffer(buffer.slice(1, 1 + byteLength)) + + var Q + if (compressed) { + assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length') + assert(type === 0x02 || type === 0x03, 'Invalid sequence tag') + + var isOdd = (type === 0x03) + Q = curve.pointFromX(isOdd, x) + } else { + assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length') + + var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength)) + Q = Point.fromAffine(curve, x, y) + } + + Q.compressed = compressed + return Q +} + +Point.prototype.toString = function () { + if (this.curve.isInfinity(this)) return '(INFINITY)' + + return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')' +} + +module.exports = Point + +},{"assert":23,"bigi":32,"safe-buffer":321}],202:[function(require,module,exports){ +'use strict'; + +var elliptic = exports; + +elliptic.version = require('../package.json').version; +elliptic.utils = require('./elliptic/utils'); +elliptic.rand = require('brorand'); +elliptic.curve = require('./elliptic/curve'); +elliptic.curves = require('./elliptic/curves'); + +// Protocols +elliptic.ec = require('./elliptic/ec'); +elliptic.eddsa = require('./elliptic/eddsa'); + +},{"../package.json":217,"./elliptic/curve":205,"./elliptic/curves":208,"./elliptic/ec":209,"./elliptic/eddsa":212,"./elliptic/utils":216,"brorand":83}],203:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var utils = require('../utils'); +var getNAF = utils.getNAF; +var getJSF = utils.getJSF; +var assert = utils.assert; + +function BaseCurve(type, conf) { + this.type = type; + this.p = new BN(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); + + // Useful for many curves + this.zero = new BN(0).toRed(this.red); + this.one = new BN(1).toRed(this.red); + this.two = new BN(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new BN(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + + this._bitLength = this.n ? this.n.bitLength() : 0; + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } +} +module.exports = BaseCurve; + +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1, this._bitLength); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + var j; + var nafW; + for (j = 0; j < naf.length; j += doubles.step) { + nafW = 0; + for (var l = j + doubles.step - 1; l >= j; l--) + nafW = (nafW << 1) + naf[l]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (j = 0; j < repr.length; j++) { + nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); +}; + +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w, this._bitLength); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var l = 0; i >= 0 && naf[i] === 0; i--) + l++; + if (i >= 0) + l++; + acc = acc.dblp(l); + + if (i < 0) + break; + var z = naf[i]; + assert(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; +}; + +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + var i; + var j; + var p; + for (i = 0; i < len; i++) { + p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength); + naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b], /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3, /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (j = 0; j < len; j++) { + var z = tmp[j]; + p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); +}; + +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; + +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)); +}; + +BasePoint.prototype.encode = function encode(enc, compact) { + return utils.encode(this._encode(compact), enc); +}; + +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null, + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; +}; + +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); +}; + +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles, + }; +}; + +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res, + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +},{"../utils":216,"bn.js":82}],204:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); + +var assert = utils.assert; + +function EdwardsCurve(conf) { + // NOTE: Important as we are creating point in Base.call() + this.twisted = (conf.a | 0) !== 1; + this.mOneA = this.twisted && (conf.a | 0) === -1; + this.extended = this.mOneA; + + Base.call(this, 'edwards', conf); + + this.a = new BN(conf.a, 16).umod(this.red.m); + this.a = this.a.toRed(this.red); + this.c = new BN(conf.c, 16).toRed(this.red); + this.c2 = this.c.redSqr(); + this.d = new BN(conf.d, 16).toRed(this.red); + this.dd = this.d.redAdd(this.d); + + assert(!this.twisted || this.c.fromRed().cmpn(1) === 0); + this.oneC = (conf.c | 0) === 1; +} +inherits(EdwardsCurve, Base); +module.exports = EdwardsCurve; + +EdwardsCurve.prototype._mulA = function _mulA(num) { + if (this.mOneA) + return num.redNeg(); + else + return this.a.redMul(num); +}; + +EdwardsCurve.prototype._mulC = function _mulC(num) { + if (this.oneC) + return num; + else + return this.c.redMul(num); +}; + +// Just for compatibility with Short curve +EdwardsCurve.prototype.jpoint = function jpoint(x, y, z, t) { + return this.point(x, y, z, t); +}; + +EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var x2 = x.redSqr(); + var rhs = this.c2.redSub(this.a.redMul(x2)); + var lhs = this.one.redSub(this.c2.redMul(this.d).redMul(x2)); + + var y2 = rhs.redMul(lhs.redInvm()); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) { + y = new BN(y, 16); + if (!y.red) + y = y.toRed(this.red); + + // x^2 = (y^2 - c^2) / (c^2 d y^2 - a) + var y2 = y.redSqr(); + var lhs = y2.redSub(this.c2); + var rhs = y2.redMul(this.d).redMul(this.c2).redSub(this.a); + var x2 = lhs.redMul(rhs.redInvm()); + + if (x2.cmp(this.zero) === 0) { + if (odd) + throw new Error('invalid point'); + else + return this.point(this.zero, y); + } + + var x = x2.redSqrt(); + if (x.redSqr().redSub(x2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + if (x.fromRed().isOdd() !== odd) + x = x.redNeg(); + + return this.point(x, y); +}; + +EdwardsCurve.prototype.validate = function validate(point) { + if (point.isInfinity()) + return true; + + // Curve: A * X^2 + Y^2 = C^2 * (1 + D * X^2 * Y^2) + point.normalize(); + + var x2 = point.x.redSqr(); + var y2 = point.y.redSqr(); + var lhs = x2.redMul(this.a).redAdd(y2); + var rhs = this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2))); + + return lhs.cmp(rhs) === 0; +}; + +function Point(curve, x, y, z, t) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && y === null && z === null) { + this.x = this.curve.zero; + this.y = this.curve.one; + this.z = this.curve.one; + this.t = this.curve.zero; + this.zOne = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = z ? new BN(z, 16) : this.curve.one; + this.t = t && new BN(t, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + if (this.t && !this.t.red) + this.t = this.t.toRed(this.curve.red); + this.zOne = this.z === this.curve.one; + + // Use extended coordinates + if (this.curve.extended && !this.t) { + this.t = this.x.redMul(this.y); + if (!this.zOne) + this.t = this.t.redMul(this.z.redInvm()); + } + } +} +inherits(Point, Base.BasePoint); + +EdwardsCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; + +EdwardsCurve.prototype.point = function point(x, y, z, t) { + return new Point(this, x, y, z, t); +}; + +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1], obj[2]); +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.x.cmpn(0) === 0 && + (this.y.cmp(this.z) === 0 || + (this.zOne && this.y.cmp(this.curve.c) === 0)); +}; + +Point.prototype._extDbl = function _extDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #doubling-dbl-2008-hwcd + // 4M + 4S + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = 2 * Z1^2 + var c = this.z.redSqr(); + c = c.redIAdd(c); + // D = a * A + var d = this.curve._mulA(a); + // E = (X1 + Y1)^2 - A - B + var e = this.x.redAdd(this.y).redSqr().redISub(a).redISub(b); + // G = D + B + var g = d.redAdd(b); + // F = G - C + var f = g.redSub(c); + // H = D - B + var h = d.redSub(b); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projDbl = function _projDbl() { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #doubling-dbl-2008-bbjlp + // #doubling-dbl-2007-bl + // and others + // Generally 3M + 4S or 2M + 4S + + // B = (X1 + Y1)^2 + var b = this.x.redAdd(this.y).redSqr(); + // C = X1^2 + var c = this.x.redSqr(); + // D = Y1^2 + var d = this.y.redSqr(); + + var nx; + var ny; + var nz; + var e; + var h; + var j; + if (this.curve.twisted) { + // E = a * C + e = this.curve._mulA(c); + // F = E + D + var f = e.redAdd(d); + if (this.zOne) { + // X3 = (B - C - D) * (F - 2) + nx = b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F^2 - 2 * F + nz = f.redSqr().redSub(f).redSub(f); + } else { + // H = Z1^2 + h = this.z.redSqr(); + // J = F - 2 * H + j = f.redSub(h).redISub(h); + // X3 = (B-C-D)*J + nx = b.redSub(c).redISub(d).redMul(j); + // Y3 = F * (E - D) + ny = f.redMul(e.redSub(d)); + // Z3 = F * J + nz = f.redMul(j); + } + } else { + // E = C + D + e = c.redAdd(d); + // H = (c * Z1)^2 + h = this.curve._mulC(this.z).redSqr(); + // J = E - 2 * H + j = e.redSub(h).redSub(h); + // X3 = c * (B - E) * J + nx = this.curve._mulC(b.redISub(e)).redMul(j); + // Y3 = c * E * (C - D) + ny = this.curve._mulC(e).redMul(c.redISub(d)); + // Z3 = E * J + nz = e.redMul(j); + } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + // Double in extended coordinates + if (this.curve.extended) + return this._extDbl(); + else + return this._projDbl(); +}; + +Point.prototype._extAdd = function _extAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html + // #addition-add-2008-hwcd-3 + // 8M + + // A = (Y1 - X1) * (Y2 - X2) + var a = this.y.redSub(this.x).redMul(p.y.redSub(p.x)); + // B = (Y1 + X1) * (Y2 + X2) + var b = this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)); + // C = T1 * k * T2 + var c = this.t.redMul(this.curve.dd).redMul(p.t); + // D = Z1 * 2 * Z2 + var d = this.z.redMul(p.z.redAdd(p.z)); + // E = B - A + var e = b.redSub(a); + // F = D - C + var f = d.redSub(c); + // G = D + C + var g = d.redAdd(c); + // H = B + A + var h = b.redAdd(a); + // X3 = E * F + var nx = e.redMul(f); + // Y3 = G * H + var ny = g.redMul(h); + // T3 = E * H + var nt = e.redMul(h); + // Z3 = F * G + var nz = f.redMul(g); + return this.curve.point(nx, ny, nz, nt); +}; + +Point.prototype._projAdd = function _projAdd(p) { + // hyperelliptic.org/EFD/g1p/auto-twisted-projective.html + // #addition-add-2008-bbjlp + // #addition-add-2007-bl + // 10M + 1S + + // A = Z1 * Z2 + var a = this.z.redMul(p.z); + // B = A^2 + var b = a.redSqr(); + // C = X1 * X2 + var c = this.x.redMul(p.x); + // D = Y1 * Y2 + var d = this.y.redMul(p.y); + // E = d * C * D + var e = this.curve.d.redMul(c).redMul(d); + // F = B - E + var f = b.redSub(e); + // G = B + E + var g = b.redAdd(e); + // X3 = A * F * ((X1 + Y1) * (X2 + Y2) - C - D) + var tmp = this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d); + var nx = a.redMul(f).redMul(tmp); + var ny; + var nz; + if (this.curve.twisted) { + // Y3 = A * G * (D - a * C) + ny = a.redMul(g).redMul(d.redSub(this.curve._mulA(c))); + // Z3 = F * G + nz = f.redMul(g); + } else { + // Y3 = A * G * (D - C) + ny = a.redMul(g).redMul(d.redSub(c)); + // Z3 = c * F * G + nz = this.curve._mulC(f).redMul(g); + } + return this.curve.point(nx, ny, nz); +}; + +Point.prototype.add = function add(p) { + if (this.isInfinity()) + return p; + if (p.isInfinity()) + return this; + + if (this.curve.extended) + return this._extAdd(p); + else + return this._projAdd(p); +}; + +Point.prototype.mul = function mul(k) { + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) { + return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true); +}; + +Point.prototype.normalize = function normalize() { + if (this.zOne) + return this; + + // Normalize coordinates + var zi = this.z.redInvm(); + this.x = this.x.redMul(zi); + this.y = this.y.redMul(zi); + if (this.t) + this.t = this.t.redMul(zi); + this.z = this.curve.one; + this.zOne = true; + return this; +}; + +Point.prototype.neg = function neg() { + return this.curve.point(this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg()); +}; + +Point.prototype.getX = function getX() { + this.normalize(); + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + this.normalize(); + return this.y.fromRed(); +}; + +Point.prototype.eq = function eq(other) { + return this === other || + this.getX().cmp(other.getX()) === 0 && + this.getY().cmp(other.getY()) === 0; +}; + +Point.prototype.eqXToP = function eqXToP(x) { + var rx = x.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(this.z); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; + +// Compatibility with BaseCurve +Point.prototype.toP = Point.prototype.normalize; +Point.prototype.mixedAdd = Point.prototype.add; + +},{"../utils":216,"./base":203,"bn.js":82,"inherits":258}],205:[function(require,module,exports){ +'use strict'; + +var curve = exports; + +curve.base = require('./base'); +curve.short = require('./short'); +curve.mont = require('./mont'); +curve.edwards = require('./edwards'); + +},{"./base":203,"./edwards":204,"./mont":206,"./short":207}],206:[function(require,module,exports){ +'use strict'; + +var BN = require('bn.js'); +var inherits = require('inherits'); +var Base = require('./base'); + +var utils = require('../utils'); + +function MontCurve(conf) { + Base.call(this, 'mont', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.i4 = new BN(4).toRed(this.red).redInvm(); + this.two = new BN(2).toRed(this.red); + this.a24 = this.i4.redMul(this.a.redAdd(this.two)); +} +inherits(MontCurve, Base); +module.exports = MontCurve; + +MontCurve.prototype.validate = function validate(point) { + var x = point.normalize().x; + var x2 = x.redSqr(); + var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); + var y = rhs.redSqrt(); + + return y.redSqr().cmp(rhs) === 0; +}; + +function Point(curve, x, z) { + Base.BasePoint.call(this, curve, 'projective'); + if (x === null && z === null) { + this.x = this.curve.one; + this.z = this.curve.zero; + } else { + this.x = new BN(x, 16); + this.z = new BN(z, 16); + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + } +} +inherits(Point, Base.BasePoint); + +MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + return this.point(utils.toArray(bytes, enc), 1); +}; + +MontCurve.prototype.point = function point(x, z) { + return new Point(this, x, z); +}; + +MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { + return Point.fromJSON(this, obj); +}; + +Point.prototype.precompute = function precompute() { + // No-op +}; + +Point.prototype._encode = function _encode() { + return this.getX().toArray('be', this.curve.p.byteLength()); +}; + +Point.fromJSON = function fromJSON(curve, obj) { + return new Point(curve, obj[0], obj[1] || curve.one); +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +Point.prototype.dbl = function dbl() { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 + // 2M + 2S + 4A + + // A = X1 + Z1 + var a = this.x.redAdd(this.z); + // AA = A^2 + var aa = a.redSqr(); + // B = X1 - Z1 + var b = this.x.redSub(this.z); + // BB = B^2 + var bb = b.redSqr(); + // C = AA - BB + var c = aa.redSub(bb); + // X3 = AA * BB + var nx = aa.redMul(bb); + // Z3 = C * (BB + A24 * C) + var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); + return this.curve.point(nx, nz); +}; + +Point.prototype.add = function add() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.diffAdd = function diffAdd(p, diff) { + // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 + // 4M + 2S + 6A + + // A = X2 + Z2 + var a = this.x.redAdd(this.z); + // B = X2 - Z2 + var b = this.x.redSub(this.z); + // C = X3 + Z3 + var c = p.x.redAdd(p.z); + // D = X3 - Z3 + var d = p.x.redSub(p.z); + // DA = D * A + var da = d.redMul(a); + // CB = C * B + var cb = c.redMul(b); + // X5 = Z1 * (DA + CB)^2 + var nx = diff.z.redMul(da.redAdd(cb).redSqr()); + // Z5 = X1 * (DA - CB)^2 + var nz = diff.x.redMul(da.redISub(cb).redSqr()); + return this.curve.point(nx, nz); +}; + +Point.prototype.mul = function mul(k) { + var t = k.clone(); + var a = this; // (N / 2) * Q + Q + var b = this.curve.point(null, null); // (N / 2) * Q + var c = this; // Q + + for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) + bits.push(t.andln(1)); + + for (var i = bits.length - 1; i >= 0; i--) { + if (bits[i] === 0) { + // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q + a = a.diffAdd(b, c); + // N * Q = 2 * ((N / 2) * Q + Q)) + b = b.dbl(); + } else { + // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) + b = a.diffAdd(b, c); + // N * Q + Q = 2 * ((N / 2) * Q + Q) + a = a.dbl(); + } + } + return b; +}; + +Point.prototype.mulAdd = function mulAdd() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.jumlAdd = function jumlAdd() { + throw new Error('Not supported on Montgomery curve'); +}; + +Point.prototype.eq = function eq(other) { + return this.getX().cmp(other.getX()) === 0; +}; + +Point.prototype.normalize = function normalize() { + this.x = this.x.redMul(this.z.redInvm()); + this.z = this.curve.one; + return this; +}; + +Point.prototype.getX = function getX() { + // Normalize coordinates + this.normalize(); + + return this.x.fromRed(); +}; + +},{"../utils":216,"./base":203,"bn.js":82,"inherits":258}],207:[function(require,module,exports){ +'use strict'; + +var utils = require('../utils'); +var BN = require('bn.js'); var inherits = require('inherits'); -var Base = curve.base; +var Base = require('./base'); + +var assert = utils.assert; + +function ShortCurve(conf) { + Base.call(this, 'short', conf); + + this.a = new BN(conf.a, 16).toRed(this.red); + this.b = new BN(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits(ShortCurve, Base); +module.exports = ShortCurve; + +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new BN(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new BN(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new BN(vec.a, 16), + b: new BN(vec.b, 16), + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis, + }; +}; + +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : BN.mont(num); + var tinv = new BN(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; + +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new BN(1); + var y1 = new BN(0); + var x2 = new BN(0); + var y2 = new BN(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 }, + ]; +}; + +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; + +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new BN(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; + +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + +function Point(curve, x, y, isRed) { + Base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } +} +inherits(Point, Base.BasePoint); + +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; + +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; + +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul), + }, + }; + } + return beta; +}; + +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1), + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1), + }, + } ]; +}; + +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)), + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)), + }, + }; + return res; +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; + +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new BN(k, 16); + if (this.isInfinity()) + return this; + else if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); +}; + +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); +}; + +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate), + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate), + }, + }; + } + return res; +}; + +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; + +function JPoint(curve, x, y, z) { + Base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new BN(0); + } else { + this.x = new BN(x, 16); + this.y = new BN(y, 16); + this.z = new BN(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; + this.zOne = this.z === this.curve.one; +} +inherits(JPoint, Base.BasePoint); -function MontCurve(conf) { - Base.call(this, 'mont', conf); +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.i4 = new BN(4).toRed(this.red).redInvm(); - this.two = new BN(2).toRed(this.red); - this.a24 = this.i4.redMul(this.a.redAdd(this.two)); +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); +}; + +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; + +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + var i; + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; + +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); +}; + +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mul = function mul(k, kbase) { + k = new BN(k, kbase); + + return this.curve._wnafMul(this, k); +}; + +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; +}; + +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; + +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +},{"../utils":216,"./base":203,"bn.js":82,"inherits":258}],208:[function(require,module,exports){ +'use strict'; + +var curves = exports; + +var hash = require('hash.js'); +var curve = require('./curve'); +var utils = require('./utils'); + +var assert = utils.assert; + +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve.short(options); + else if (options.type === 'edwards') + this.curve = new curve.edwards(options); + else + this.curve = new curve.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); } -inherits(MontCurve, Base); -module.exports = MontCurve; +curves.PresetCurve = PresetCurve; -MontCurve.prototype.validate = function validate(point) { - var x = point.normalize().x; - var x2 = x.redSqr(); - var rhs = x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x); - var y = rhs.redSqrt(); +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve, + }); + return curve; + }, + }); +} + +defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811', + ], +}); + +defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34', + ], +}); - return y.redSqr().cmp(rhs) === 0; -}; +defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5', + ], +}); -function Point(curve, x, z) { - Base.BasePoint.call(this, curve, 'projective'); - if (x === null && z === null) { - this.x = this.curve.one; - this.z = this.curve.zero; - } else { - this.x = new BN(x, 16); - this.z = new BN(z, 16); - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - } -} -inherits(Point, Base.BasePoint); +defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f', + ], +}); -MontCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - return this.point(utils.toArray(bytes, enc), 1); -}; +defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650', + ], +}); -MontCurve.prototype.point = function point(x, z) { - return new Point(this, x, z); -}; +defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '9', + ], +}); -MontCurve.prototype.pointFromJSON = function pointFromJSON(obj) { - return Point.fromJSON(this, obj); -}; +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', -Point.prototype.precompute = function precompute() { - // No-op -}; + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658', + ], +}); -Point.prototype._encode = function _encode() { - return this.getX().toArray('be', this.curve.p.byteLength()); -}; +var pre; +try { + pre = require('./precomputed/secp256k1'); +} catch (e) { + pre = undefined; +} -Point.fromJSON = function fromJSON(curve, obj) { - return new Point(curve, obj[0], obj[1] || curve.one); -}; +defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash.sha256, -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3', + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15', + }, + ], -Point.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre, + ], +}); -Point.prototype.dbl = function dbl() { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#doubling-dbl-1987-m-3 - // 2M + 2S + 4A +},{"./curve":205,"./precomputed/secp256k1":215,"./utils":216,"hash.js":244}],209:[function(require,module,exports){ +'use strict'; - // A = X1 + Z1 - var a = this.x.redAdd(this.z); - // AA = A^2 - var aa = a.redSqr(); - // B = X1 - Z1 - var b = this.x.redSub(this.z); - // BB = B^2 - var bb = b.redSqr(); - // C = AA - BB - var c = aa.redSub(bb); - // X3 = AA * BB - var nx = aa.redMul(bb); - // Z3 = C * (BB + A24 * C) - var nz = c.redMul(bb.redAdd(this.curve.a24.redMul(c))); - return this.curve.point(nx, nz); -}; +var BN = require('bn.js'); +var HmacDRBG = require('hmac-drbg'); +var utils = require('../utils'); +var curves = require('../curves'); +var rand = require('brorand'); +var assert = utils.assert; -Point.prototype.add = function add() { - throw new Error('Not supported on Montgomery curve'); -}; +var KeyPair = require('./key'); +var Signature = require('./signature'); -Point.prototype.diffAdd = function diffAdd(p, diff) { - // http://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html#diffadd-dadd-1987-m-3 - // 4M + 2S + 6A +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); - // A = X2 + Z2 - var a = this.x.redAdd(this.z); - // B = X2 - Z2 - var b = this.x.redSub(this.z); - // C = X3 + Z3 - var c = p.x.redAdd(p.z); - // D = X3 - Z3 - var d = p.x.redSub(p.z); - // DA = D * A - var da = d.redMul(a); - // CB = C * B - var cb = c.redMul(b); - // X5 = Z1 * (DA + CB)^2 - var nx = diff.z.redMul(da.redAdd(cb).redSqr()); - // Z5 = X1 * (DA - CB)^2 - var nz = diff.x.redMul(da.redISub(cb).redSqr()); - return this.curve.point(nx, nz); -}; + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert(Object.prototype.hasOwnProperty.call(curves, options), + 'Unknown curve ' + options); -Point.prototype.mul = function mul(k) { - var t = k.clone(); - var a = this; // (N / 2) * Q + Q - var b = this.curve.point(null, null); // (N / 2) * Q - var c = this; // Q + options = curves[options]; + } - for (var bits = []; t.cmpn(0) !== 0; t.iushrn(1)) - bits.push(t.andln(1)); + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves.PresetCurve) + options = { curve: options }; - for (var i = bits.length - 1; i >= 0; i--) { - if (bits[i] === 0) { - // N * Q + Q = ((N / 2) * Q + Q)) + (N / 2) * Q - a = a.diffAdd(b, c); - // N * Q = 2 * ((N / 2) * Q + Q)) - b = b.dbl(); - } else { - // N * Q = ((N / 2) * Q + Q) + ((N / 2) * Q) - b = a.diffAdd(b, c); - // N * Q + Q = 2 * ((N / 2) * Q + Q) - a = a.dbl(); - } - } - return b; -}; + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; -Point.prototype.mulAdd = function mulAdd() { - throw new Error('Not supported on Montgomery curve'); -}; + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); -Point.prototype.jumlAdd = function jumlAdd() { - throw new Error('Not supported on Montgomery curve'); -}; + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +module.exports = EC; -Point.prototype.eq = function eq(other) { - return this.getX().cmp(other.getX()) === 0; +EC.prototype.keyPair = function keyPair(options) { + return new KeyPair(this, options); }; -Point.prototype.normalize = function normalize() { - this.x = this.x.redMul(this.z.redInvm()); - this.z = this.curve.one; - return this; +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return KeyPair.fromPrivate(this, priv, enc); }; -Point.prototype.getX = function getX() { - // Normalize coordinates - this.normalize(); - - return this.x.fromRed(); +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return KeyPair.fromPublic(this, pub, enc); }; -},{"../../elliptic":201,"../curve":204,"bn.js":82,"inherits":238}],206:[function(require,module,exports){ -'use strict'; - -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; - -var assert = elliptic.utils.assert; - -function ShortCurve(conf) { - Base.call(this, 'short', conf); +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || rand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray(), + }); - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new BN(2)); + for (;;) { + var priv = new BN(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); -} -inherits(ShortCurve, Base); -module.exports = ShortCurve; + priv.iaddn(1); + return this.keyFromPrivate(priv); + } +}; -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; +EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; +}; - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); - } +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; } + if (!options) + options = {}; - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16) - }; - }); - } else { - basis = this._getEndoBasis(lambda); - } + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new BN(msg, 16)); - return { - beta: beta, - lambda: lambda, - basis: basis - }; -}; + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); -ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); + // Instantiate Hmac_DRBG + var drbg = new HmacDRBG({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + }); - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; -}; + // Number of bytes to generate + var ns1 = this.n.sub(new BN(1)); -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + for (var iter = 0; ; iter++) { + var k = options.k ? + options.k(iter) : + new BN(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; } - prevR = r; - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; + return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); } - a2 = r.neg(); - b2 = x; +}; - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } +EC.prototype.verify = function verify(msg, signature, key, enc) { + msg = this._truncateToN(new BN(msg, 16)); + key = this.keyFromPublic(key, enc); + signature = new Signature(signature, 'hex'); - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } + // Perform primitive values validation + var r = signature.r; + var s = signature.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 } - ]; -}; + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + var p; -ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; + if (!this.curve._maxwellTrick) { + p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); + return p.getX().umod(this.n).cmp(r) === 0; + } - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; -}; + p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; -ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); +}; - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); +EC.prototype.recoverPubKey = function(msg, signature, j, enc) { + assert((3 & j) === j, 'The recovery param is more than two bits'); + signature = new Signature(signature, enc); - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); + var n = this.n; + var e = new BN(msg); + var r = signature.r; + var s = signature.s; - return this.point(x, y); -}; + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); -ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); - var x = point.x; - var y = point.y; + var rInv = signature.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); }; -ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); +EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { + signature = new Signature(signature, enc); + if (signature.recoveryParam !== null) + return signature.recoveryParam; - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature, i); + } catch (e) { + continue; } - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; + if (Qprime.eq(Q)) + return i; } - return res; + throw new Error('Unable to find valid recovery factor'); }; -function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } -} -inherits(Point, Base.BasePoint); +},{"../curves":208,"../utils":216,"./key":210,"./signature":211,"bn.js":82,"brorand":83,"hmac-drbg":256}],210:[function(require,module,exports){ +'use strict'; -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); -}; +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); -}; +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; -Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +module.exports = KeyPair; - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul) - } - }; - } - return beta; + return new KeyPair(ec, { + pub: pub, + pubEnc: enc, + }); }; -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - } ]; + return new KeyPair(ec, { + priv: priv, + privEnc: enc, + }); }; -Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)) - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)) - } - }; - return res; + return { result: true, reason: null }; }; -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); }; -Point.prototype.isInfinity = function isInfinity() { - return this.inf; +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; }; -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new BN(key, enc || 16); - // P + O = P - if (p.inf) - return this; + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; - // P + P = 2P - if (this.eq(p)) - return this.dbl(); +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); +// ECDH +KeyPair.prototype.derive = function derive(pub) { + if(!pub.validate()) { + assert(pub.validate(), 'public point not validated'); + } + return pub.mul(this.priv).getX(); +}; - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); }; -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; +KeyPair.prototype.inspect = function inspect() { + return ''; +}; - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); +},{"../utils":216,"bn.js":82}],211:[function(require,module,exports){ +'use strict'; - var a = this.curve.a; +var BN = require('bn.js'); - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); +var utils = require('../utils'); +var assert = utils.assert; - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; +function Signature(options, enc) { + if (options instanceof Signature) + return options; -Point.prototype.getX = function getX() { - return this.x.fromRed(); -}; + if (this._importDER(options, enc)) + return; -Point.prototype.getY = function getY() { - return this.y.fromRed(); -}; + assert(options.r && options.s, 'Signature without r or s'); + this.r = new BN(options.r, 16); + this.s = new BN(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +module.exports = Signature; -Point.prototype.mul = function mul(k) { - k = new BN(k, 16); +function Position() { + this.place = 0; +} - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); -}; +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; -Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); -}; + // Indefinite length or overflow + if (octetLen === 0 || octetLen > 4) { + return false; + } -Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); -}; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + val >>>= 0; + } -Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); -}; + // Leading zeroes + if (val <= 0x7f) { + return false; + } -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; + p.place = off; + return val; +} - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate) - } - }; +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; } - return res; -}; + if (i === 0) { + return buf; + } + return buf.slice(i); +} -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if (len === false) { + return false; + } + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + if (rlen === false) { + return false; + } + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (slen === false) { + return false; + } + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0) { + if (r[1] & 0x80) { + r = r.slice(1); + } else { + // Leading zeroes + return false; + } + } + if (s[0] === 0) { + if (s[1] & 0x80) { + s = s.slice(1); + } else { + // Leading zeroes + return false; + } + } - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; + this.r = new BN(r); + this.s = new BN(s); + this.recoveryParam = null; + + return true; }; -function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); } -inherits(JPoint, Base.BasePoint); -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils.encode(res, enc); }; -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); - - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); +},{"../utils":216,"bn.js":82}],212:[function(require,module,exports){ +'use strict'; - return this.curve.point(ax, ay); -}; +var hash = require('hash.js'); +var curves = require('../curves'); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var KeyPair = require('./key'); +var Signature = require('./signature'); -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; +function EDDSA(curve) { + assert(curve === 'ed25519', 'only tested with ed25519 so far'); -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; + if (!(this instanceof EDDSA)) + return new EDDSA(curve); - // P + O = P - if (p.isInfinity()) - return this; + curve = curves[curve].curve; + this.curve = curve; + this.g = curve.g; + this.g.precompute(curve.n.bitLength() + 1); - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); + this.pointClass = curve.point().constructor; + this.encodingLength = Math.ceil(curve.n.bitLength() / 8); + this.hash = hash.sha512; +} - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } +module.exports = EDDSA; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +/** +* @param {Array|String} message - message bytes +* @param {Array|String|KeyPair} secret - secret bytes or a keypair +* @returns {Signature} - signature +*/ +EDDSA.prototype.sign = function sign(message, secret) { + message = parseBytes(message); + var key = this.keyFromSecret(secret); + var r = this.hashInt(key.messagePrefix(), message); + var R = this.g.mul(r); + var Rencoded = this.encodePoint(R); + var s_ = this.hashInt(Rencoded, key.pubBytes(), message) + .mul(key.priv()); + var S = r.add(s_).umod(this.curve.n); + return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); +}; - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); +/** +* @param {Array} message - message bytes +* @param {Array|String|Signature} sig - sig bytes +* @param {Array|String|Point|KeyPair} pub - public key +* @returns {Boolean} - true if public key matches sig of message +*/ +EDDSA.prototype.verify = function verify(message, sig, pub) { + message = parseBytes(message); + sig = this.makeSignature(sig); + var key = this.keyFromPublic(pub); + var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); + var SG = this.g.mul(sig.S()); + var RplusAh = sig.R().add(key.pub().mul(h)); + return RplusAh.eq(SG); +}; - return this.curve.jpoint(nx, ny, nz); +EDDSA.prototype.hashInt = function hashInt() { + var hash = this.hash(); + for (var i = 0; i < arguments.length; i++) + hash.update(arguments[i]); + return utils.intFromLE(hash.digest()).umod(this.curve.n); }; -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); +EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { + return KeyPair.fromPublic(this, pub); +}; - // P + O = P - if (p.isInfinity()) - return this; +EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { + return KeyPair.fromSecret(this, secret); +}; - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); +EDDSA.prototype.makeSignature = function makeSignature(sig) { + if (sig instanceof Signature) + return sig; + return new Signature(this, sig); +}; - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } +/** +* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 +* +* EDDSA defines methods for encoding and decoding points and integers. These are +* helper convenience methods, that pass along to utility functions implied +* parameters. +* +*/ +EDDSA.prototype.encodePoint = function encodePoint(point) { + var enc = point.getY().toArray('le', this.encodingLength); + enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; + return enc; +}; - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); +EDDSA.prototype.decodePoint = function decodePoint(bytes) { + bytes = utils.parseBytes(bytes); - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); + var lastIx = bytes.length - 1; + var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); + var xIsOdd = (bytes[lastIx] & 0x80) !== 0; - return this.curve.jpoint(nx, ny, nz); + var y = utils.intFromLE(normed); + return this.curve.pointFromY(y, xIsOdd); }; -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); - - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (var i = 0; i < pow; i++) - r = r.dbl(); - return r; - } +EDDSA.prototype.encodeInt = function encodeInt(num) { + return num.toArray('le', this.encodingLength); +}; - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; +EDDSA.prototype.decodeInt = function decodeInt(bytes) { + return utils.intFromLE(bytes); +}; - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +EDDSA.prototype.isPoint = function isPoint(val) { + return val instanceof this.pointClass; +}; - // Reuse results - var jyd = jy.redAdd(jy); - for (var i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); +},{"../curves":208,"../utils":216,"./key":213,"./signature":214,"hash.js":244}],213:[function(require,module,exports){ +'use strict'; - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); +var utils = require('../utils'); +var assert = utils.assert; +var parseBytes = utils.parseBytes; +var cachedProperty = utils.cachedProperty; - jx = nx; - jz = nz; - jyd = dny; - } +/** +* @param {EDDSA} eddsa - instance +* @param {Object} params - public/private key parameters +* +* @param {Array} [params.secret] - secret seed bytes +* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) +* @param {Array} [params.pub] - public key point encoded as bytes +* +*/ +function KeyPair(eddsa, params) { + this.eddsa = eddsa; + this._secret = parseBytes(params.secret); + if (eddsa.isPoint(params.pub)) + this._pub = params.pub; + else + this._pubBytes = parseBytes(params.pub); +} - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +KeyPair.fromPublic = function fromPublic(eddsa, pub) { + if (pub instanceof KeyPair) + return pub; + return new KeyPair(eddsa, { pub: pub }); }; -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; +KeyPair.fromSecret = function fromSecret(eddsa, secret) { + if (secret instanceof KeyPair) + return secret; + return new KeyPair(eddsa, { secret: secret }); +}; - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); +KeyPair.prototype.secret = function secret() { + return this._secret; }; -JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A +cachedProperty(KeyPair, 'pubBytes', function pubBytes() { + return this.eddsa.encodePoint(this.pub()); +}); - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); +cachedProperty(KeyPair, 'pub', function pub() { + if (this._pubBytes) + return this.eddsa.decodePoint(this._pubBytes); + return this.eddsa.g.mul(this.priv()); +}); - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); +cachedProperty(KeyPair, 'privBytes', function privBytes() { + var eddsa = this.eddsa; + var hash = this.hash(); + var lastIx = eddsa.encodingLength - 1; - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A + var a = hash.slice(0, eddsa.encodingLength); + a[0] &= 248; + a[lastIx] &= 127; + a[lastIx] |= 64; - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); + return a; +}); - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); +cachedProperty(KeyPair, 'priv', function priv() { + return this.eddsa.decodeInt(this.privBytes()); +}); - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } +cachedProperty(KeyPair, 'hash', function hash() { + return this.eddsa.hash().update(this.secret()).digest(); +}); - return this.curve.jpoint(nx, ny, nz); -}; +cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { + return this.hash().slice(this.eddsa.encodingLength); +}); -JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A +KeyPair.prototype.sign = function sign(message) { + assert(this._secret, 'KeyPair can only verify'); + return this.eddsa.sign(message, this); +}; - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S +KeyPair.prototype.verify = function verify(message, sig) { + return this.eddsa.verify(message, sig, this); +}; - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } +KeyPair.prototype.getSecret = function getSecret(enc) { + assert(this._secret, 'KeyPair is public only'); + return utils.encode(this.secret(), enc); +}; - return this.curve.jpoint(nx, ny, nz); +KeyPair.prototype.getPublic = function getPublic(enc) { + return utils.encode(this.pubBytes(), enc); }; -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; +module.exports = KeyPair; - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); +},{"../utils":216}],214:[function(require,module,exports){ +'use strict'; - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); +var BN = require('bn.js'); +var utils = require('../utils'); +var assert = utils.assert; +var cachedProperty = utils.cachedProperty; +var parseBytes = utils.parseBytes; - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); +/** +* @param {EDDSA} eddsa - eddsa instance +* @param {Array|Object} sig - +* @param {Array|Point} [sig.R] - R point as Point or bytes +* @param {Array|bn} [sig.S] - S scalar as bn or bytes +* @param {Array} [sig.Rencoded] - R point encoded +* @param {Array} [sig.Sencoded] - S scalar encoded +*/ +function Signature(eddsa, sig) { + this.eddsa = eddsa; - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); + if (typeof sig !== 'object') + sig = parseBytes(sig); - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); + if (Array.isArray(sig)) { + sig = { + R: sig.slice(0, eddsa.encodingLength), + S: sig.slice(eddsa.encodingLength), + }; + } - return this.curve.jpoint(nx, ny, nz); -}; + assert(sig.R && sig.S, 'Signature without R or S'); -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); + if (eddsa.isPoint(sig.R)) + this._R = sig.R; + if (sig.S instanceof BN) + this._S = sig.S; - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... + this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; + this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; +} - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); +cachedProperty(Signature, 'S', function S() { + return this.eddsa.decodeInt(this.Sencoded()); +}); - return this.curve.jpoint(nx, ny, nz); +cachedProperty(Signature, 'R', function R() { + return this.eddsa.decodePoint(this.Rencoded()); +}); + +cachedProperty(Signature, 'Rencoded', function Rencoded() { + return this.eddsa.encodePoint(this.R()); +}); + +cachedProperty(Signature, 'Sencoded', function Sencoded() { + return this.eddsa.encodeInt(this.S()); +}); + +Signature.prototype.toBytes = function toBytes() { + return this.Rencoded().concat(this.Sencoded()); }; -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); +Signature.prototype.toHex = function toHex() { + return utils.encode(this.toBytes(), 'hex').toUpperCase(); +}; - return this.curve._wnafMul(this, k); +module.exports = Signature; + +},{"../utils":216,"bn.js":82}],215:[function(require,module,exports){ +module.exports = { + doubles: { + step: 4, + points: [ + [ + 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', + 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821', + ], + [ + '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', + '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf', + ], + [ + '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', + 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695', + ], + [ + '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', + '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9', + ], + [ + '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', + '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36', + ], + [ + '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', + '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f', + ], + [ + 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', + '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999', + ], + [ + '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', + 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09', + ], + [ + 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', + '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d', + ], + [ + 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', + 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088', + ], + [ + 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', + '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d', + ], + [ + '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', + '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8', + ], + [ + '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', + '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a', + ], + [ + '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', + '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453', + ], + [ + '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', + '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160', + ], + [ + '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', + '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0', + ], + [ + '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', + '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6', + ], + [ + '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', + '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589', + ], + [ + '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', + 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17', + ], + [ + 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', + '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda', + ], + [ + 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', + '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd', + ], + [ + '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', + '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2', + ], + [ + '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', + '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6', + ], + [ + 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', + '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f', + ], + [ + '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', + 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01', + ], + [ + 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', + '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3', + ], + [ + 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', + 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f', + ], + [ + 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', + '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7', + ], + [ + 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', + 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78', + ], + [ + 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', + '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1', + ], + [ + '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', + 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150', + ], + [ + '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', + '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82', + ], + [ + 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', + '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc', + ], + [ + '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', + 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b', + ], + [ + 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', + '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51', + ], + [ + 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', + '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45', + ], + [ + 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', + 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120', + ], + [ + '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', + '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84', + ], + [ + '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', + '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d', + ], + [ + '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', + 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d', + ], + [ + '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', + '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8', + ], + [ + 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', + '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8', + ], + [ + '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', + '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac', + ], + [ + '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', + 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f', + ], + [ + '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', + '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962', + ], + [ + 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', + '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907', + ], + [ + '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', + 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec', + ], + [ + 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', + 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d', + ], + [ + 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', + '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414', + ], + [ + '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', + 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd', + ], + [ + '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', + 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0', + ], + [ + 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', + '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811', + ], + [ + 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', + '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1', + ], + [ + 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', + '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c', + ], + [ + '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', + 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73', + ], + [ + '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', + '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd', + ], + [ + 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', + 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405', + ], + [ + '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', + 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589', + ], + [ + '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', + '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e', + ], + [ + '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', + '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27', + ], + [ + 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', + 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1', + ], + [ + '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', + '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482', + ], + [ + '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', + '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945', + ], + [ + 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', + '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573', + ], + [ + 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', + 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82', + ], + ], + }, + naf: { + wnd: 7, + points: [ + [ + 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', + '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672', + ], + [ + '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', + 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6', + ], + [ + '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', + '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da', + ], + [ + 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', + 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37', + ], + [ + '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', + 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b', + ], + [ + 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', + 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81', + ], + [ + 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', + '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58', + ], + [ + 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', + '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77', + ], + [ + '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', + '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a', + ], + [ + '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', + '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c', + ], + [ + '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', + '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67', + ], + [ + '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', + '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402', + ], + [ + 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', + 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55', + ], + [ + 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', + '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482', + ], + [ + '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', + 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82', + ], + [ + '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', + 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396', + ], + [ + '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', + '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49', + ], + [ + '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', + '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf', + ], + [ + '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', + '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a', + ], + [ + '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', + 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7', + ], + [ + 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', + 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933', + ], + [ + '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', + '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a', + ], + [ + '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', + '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6', + ], + [ + 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', + 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37', + ], + [ + '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', + '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e', + ], + [ + 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', + 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6', + ], + [ + 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', + 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476', + ], + [ + '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', + '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40', + ], + [ + '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', + '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61', + ], + [ + '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', + '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683', + ], + [ + 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', + '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5', + ], + [ + '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', + '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b', + ], + [ + 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', + '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417', + ], + [ + '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', + 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868', + ], + [ + '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', + 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a', + ], + [ + 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', + 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6', + ], + [ + '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', + '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996', + ], + [ + '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', + 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e', + ], + [ + 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', + 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d', + ], + [ + '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', + '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2', + ], + [ + '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', + 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e', + ], + [ + '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', + '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437', + ], + [ + '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', + 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311', + ], + [ + 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', + '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4', + ], + [ + '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', + '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575', + ], + [ + '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', + 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d', + ], + [ + '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', + 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d', + ], + [ + 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', + 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629', + ], + [ + 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', + 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06', + ], + [ + '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', + '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374', + ], + [ + '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', + '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee', + ], + [ + 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', + '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1', + ], + [ + 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', + 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b', + ], + [ + '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', + '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661', + ], + [ + '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', + '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6', + ], + [ + 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', + '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e', + ], + [ + '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', + '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d', + ], + [ + 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', + 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc', + ], + [ + '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', + 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4', + ], + [ + '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', + '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c', + ], + [ + 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', + '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b', + ], + [ + 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', + '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913', + ], + [ + '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', + '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154', + ], + [ + '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', + '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865', + ], + [ + '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', + 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc', + ], + [ + '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', + 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224', + ], + [ + '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', + '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e', + ], + [ + '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', + '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6', + ], + [ + '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', + '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511', + ], + [ + '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', + 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b', + ], + [ + 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', + 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2', + ], + [ + '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', + 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c', + ], + [ + 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', + '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3', + ], + [ + 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', + '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d', + ], + [ + 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', + '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700', + ], + [ + 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', + '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4', + ], + [ + '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', + 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196', + ], + [ + '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', + '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4', + ], + [ + '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', + 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257', + ], + [ + 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', + 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13', + ], + [ + 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', + '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096', + ], + [ + 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', + 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38', + ], + [ + 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', + '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f', + ], + [ + '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', + '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448', + ], + [ + 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', + '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a', + ], + [ + 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', + '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4', + ], + [ + '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', + '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437', + ], + [ + '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', + 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7', + ], + [ + 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', + '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d', + ], + [ + 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', + '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a', + ], + [ + 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', + '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54', + ], + [ + '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', + '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77', + ], + [ + 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', + 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517', + ], + [ + '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', + 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10', + ], + [ + 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', + 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125', + ], + [ + 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', + '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e', + ], + [ + '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', + 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1', + ], + [ + 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', + '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2', + ], + [ + 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', + '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423', + ], + [ + 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', + '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8', + ], + [ + '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', + 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758', + ], + [ + '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', + 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375', + ], + [ + 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', + '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d', + ], + [ + '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', + 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec', + ], + [ + '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', + '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0', + ], + [ + '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', + 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c', + ], + [ + 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', + 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4', + ], + [ + '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', + 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f', + ], + [ + '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', + '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649', + ], + [ + '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', + 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826', + ], + [ + '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', + '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5', + ], + [ + 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', + 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87', + ], + [ + '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', + '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b', + ], + [ + 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', + '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc', + ], + [ + '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', + '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c', + ], + [ + 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', + 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f', + ], + [ + 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', + '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a', + ], + [ + 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', + 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46', + ], + [ + '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', + 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f', + ], + [ + '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', + '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03', + ], + [ + '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', + 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08', + ], + [ + '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', + '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8', + ], + [ + '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', + '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373', + ], + [ + '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', + 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3', + ], + [ + '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', + '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8', + ], + [ + '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', + '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1', + ], + [ + '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', + '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9', + ], + ], + }, }; -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); +},{}],216:[function(require,module,exports){ +'use strict'; - if (this === p) - return true; +var utils = exports; +var BN = require('bn.js'); +var minAssert = require('minimalistic-assert'); +var minUtils = require('minimalistic-crypto-utils'); - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; +utils.assert = minAssert; +utils.toArray = minUtils.toArray; +utils.zero2 = minUtils.zero2; +utils.toHex = minUtils.toHex; +utils.encode = minUtils.encode; - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; -}; +// Represent num in a w-NAF form +function getNAF(num, w, bits) { + var naf = new Array(Math.max(num.bitLength(), bits) + 1); + naf.fill(0); -JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; + var ws = 1 << (w + 1); + var k = num.clone(); - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; + for (var i = 0; i < naf.length; i++) { + var z; + var mod = k.andln(ws - 1); + if (k.isOdd()) { + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; + naf[i] = z; + k.iushrn(1); } -}; - -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; -},{"../../elliptic":201,"../curve":204,"bn.js":82,"inherits":238}],207:[function(require,module,exports){ -'use strict'; + return naf; +} +utils.getNAF = getNAF; -var curves = exports; +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [], + ]; -var hash = require('hash.js'); -var elliptic = require('../elliptic'); + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + var m8; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); -var assert = elliptic.utils.assert; + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); -function PresetCurve(options) { - if (options.type === 'short') - this.curve = new elliptic.curve.short(options); - else if (options.type === 'edwards') - this.curve = new elliptic.curve.edwards(options); - else - this.curve = new elliptic.curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); + return jsf; } -curves.PresetCurve = PresetCurve; +utils.getJSF = getJSF; -function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve - }); - return curve; - } - }); +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; } +utils.cachedProperty = cachedProperty; -defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' - ] -}); - -defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' - ] -}); - -defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' - ] -}); - -defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' - ] -}); - -defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650' - ] -}); - -defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '1', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9' - ] -}); - -defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658' - ] -}); +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; +function intFromLE(bytes) { + return new BN(bytes, 'hex', 'le'); } +utils.intFromLE = intFromLE; -defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3' - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15' - } +},{"bn.js":82,"minimalistic-assert":265,"minimalistic-crypto-utils":266}],217:[function(require,module,exports){ +module.exports={ + "_args": [ + [ + "elliptic@6.5.4", + "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs" + ] + ], + "_from": "elliptic@6.5.4", + "_id": "elliptic@6.5.4", + "_inBundle": false, + "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "_location": "/elliptic", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "elliptic@6.5.4", + "name": "elliptic", + "escapedName": "elliptic", + "rawSpec": "6.5.4", + "saveSpec": null, + "fetchSpec": "6.5.4" + }, + "_requiredBy": [ + "/create-ecdh", + "/crypto-browserify/browserify-sign", + "/secp256k1" + ], + "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "_spec": "6.5.4", + "_where": "/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs", + "author": { + "name": "Fedor Indutny", + "email": "fedor@indutny.com" + }, + "bugs": { + "url": "https://github.com/indutny/elliptic/issues" + }, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "description": "EC cryptography", + "devDependencies": { + "brfs": "^2.0.2", + "coveralls": "^3.1.0", + "eslint": "^7.6.0", + "grunt": "^1.2.1", + "grunt-browserify": "^5.3.0", + "grunt-cli": "^1.3.2", + "grunt-contrib-connect": "^3.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^5.0.0", + "grunt-mocha-istanbul": "^5.0.2", + "grunt-saucelabs": "^9.0.1", + "istanbul": "^0.4.5", + "mocha": "^8.0.1" + }, + "files": [ + "lib" + ], + "homepage": "https://github.com/indutny/elliptic", + "keywords": [ + "EC", + "Elliptic", + "curve", + "Cryptography" ], + "license": "MIT", + "main": "lib/elliptic.js", + "name": "elliptic", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/indutny/elliptic.git" + }, + "scripts": { + "lint": "eslint lib test", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run unit", + "unit": "istanbul test _mocha --reporter=spec test/index.js", + "version": "grunt dist && git add dist/" + }, + "version": "6.5.4" +} - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre - ] -}); +},{}],218:[function(require,module,exports){ +var Buffer = require('safe-buffer').Buffer +var MD5 = require('md5.js') -},{"../elliptic":201,"./precomputed/secp256k1":214,"hash.js":223}],208:[function(require,module,exports){ -'use strict'; +/* eslint-disable camelcase */ +function EVP_BytesToKey (password, salt, keyBits, ivLen) { + if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') + if (salt) { + if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') + if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + } -var BN = require('bn.js'); -var HmacDRBG = require('hmac-drbg'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; + var keyLen = keyBits / 8 + var key = Buffer.alloc(keyLen) + var iv = Buffer.alloc(ivLen || 0) + var tmp = Buffer.alloc(0) -var KeyPair = require('./key'); -var Signature = require('./signature'); + while (keyLen > 0 || ivLen > 0) { + var hash = new MD5() + hash.update(tmp) + hash.update(password) + if (salt) hash.update(salt) + tmp = hash.digest() -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); + var used = 0 - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); + if (keyLen > 0) { + var keyStart = key.length - keyLen + used = Math.min(keyLen, tmp.length) + tmp.copy(key, keyStart, 0, used) + keyLen -= used + } - options = elliptic.curves[options]; + if (used < tmp.length && ivLen > 0) { + var ivStart = iv.length - ivLen + var length = Math.min(ivLen, tmp.length - used) + tmp.copy(iv, ivStart, used, used + length) + ivLen -= length + } } - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof elliptic.curves.PresetCurve) - options = { curve: options }; - - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; - - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); - - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; + tmp.fill(0) + return { key: key, iv: iv } } -module.exports = EC; -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; +module.exports = EVP_BytesToKey -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); -}; +},{"md5.js":262,"safe-buffer":321}],219:[function(require,module,exports){ -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); -}; +},{}],220:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - pers: options.pers, - persEnc: options.persEnc || 'utf8', - entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), - entropyEnc: options.entropy && options.entropyEnc || 'utf8', - nonce: this.n.toArray() - }); +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - do { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; - priv.iaddn(1); - return this.keyFromPrivate(priv); - } while (true); -}; +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; -EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; }; -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); + if (!this._events) + this._events = {}; - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); + handler = this._events[type]; - // Instantiate Hmac_DRBG - var drbg = new HmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc || 'utf8' - }); + if (isUndefined(handler)) + return false; - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } - for (var iter = 0; true; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; + return true; +}; - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; +EventEmitter.prototype.addListener = function(type, listener) { + var m; - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; + if (!this._events) + this._events = {}; - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; } - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } } + + return this; }; -EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); +EventEmitter.prototype.on = EventEmitter.prototype.addListener; - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); + var fired = false; - if (!this.curve._maxwellTrick) { - var p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + function g() { + this.removeListener(type, g); - return p.getX().umod(this.n).cmp(r) === 0; + if (!fired) { + fired = true; + listener.apply(this, arguments); + } } - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - var p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; + g.listener = listener; + this.on(type, g); - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); + return this; }; -EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); + if (!this._events || !this._events[type]) + return this; - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); + list = this._events[type]; + length = list.length; + position = -1; - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; + if (position < 0) + return this; - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); } - if (Qprime.eq(Q)) - return i; + if (this._events.removeListener) + this.emit('removeListener', type, listener); } - throw new Error('Unable to find valid recovery factor'); -}; - -},{"../../elliptic":201,"./key":209,"./signature":210,"bn.js":82,"hmac-drbg":235}],209:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); -} -module.exports = KeyPair; - -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc - }); -}; -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - - return new KeyPair(ec, { - priv: priv, - privEnc: enc - }); + return this; }; -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; + if (!this._events) + return this; - return { result: true, reason: null }; -}; + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; } - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); + listeners = this._events[type]; - if (!enc) - return this.pub; + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; - return this.pub.encode(enc, compact); + return this; }; -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; else - return this.priv; + ret = this._events[type].slice(); + return ret; }; -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); -}; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; -KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - // Montgomery points only have an `x` coordinate. - // Weierstrass/Edwards points on the other hand have both `x` and - // `y` coordinates. - if (this.ec.curve.type === 'mont') { - assert(key.x, 'Need x coordinate'); - } else if (this.ec.curve.type === 'short' || - this.ec.curve.type === 'edwards') { - assert(key.x && key.y, 'Need both x and y coordinate'); - } - this.pub = this.ec.curve.point(key.x, key.y); - return; + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; } - this.pub = this.ec.curve.decodePoint(key, enc); + return 0; }; -// ECDH -KeyPair.prototype.derive = function derive(pub) { - return pub.mul(this.priv).getX(); +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); }; -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; +function isFunction(arg) { + return typeof arg === 'function'; +} -KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); -}; +function isNumber(arg) { + return typeof arg === 'number'; +} -KeyPair.prototype.inspect = function inspect() { - return ''; -}; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} -},{"../../elliptic":201,"bn.js":82}],210:[function(require,module,exports){ -'use strict'; +function isUndefined(arg) { + return arg === void 0; +} -var BN = require('bn.js'); +},{}],221:[function(require,module,exports){ +(function (global){(function (){ +/*! https://mths.be/punycode v1.4.1 by @mathias */ +;(function(root) { -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; + /** Detect free variables */ + var freeExports = typeof exports == 'object' && exports && + !exports.nodeType && exports; + var freeModule = typeof module == 'object' && module && + !module.nodeType && module; + var freeGlobal = typeof global == 'object' && global; + if ( + freeGlobal.global === freeGlobal || + freeGlobal.window === freeGlobal || + freeGlobal.self === freeGlobal + ) { + root = freeGlobal; + } -function Signature(options, enc) { - if (options instanceof Signature) - return options; + /** + * The `punycode` object. + * @name punycode + * @type Object + */ + var punycode, - if (this._importDER(options, enc)) - return; + /** Highest positive signed 32-bit float value */ + maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + base = 36, + tMin = 1, + tMax = 26, + skew = 38, + damp = 700, + initialBias = 72, + initialN = 128, // 0x80 + delimiter = '-', // '\x2D' - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; -} -module.exports = Signature; + /** Regular expressions */ + regexPunycode = /^xn--/, + regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars + regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators -function Position() { - this.place = 0; -} + /** Error messages */ + errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }, -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - } - p.place = off; - return val; -} + /** Convenience shortcuts */ + baseMinusTMin = base - tMin, + floor = Math.floor, + stringFromCharCode = String.fromCharCode, -function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); -} + /** Temporary variable */ + key; -Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0 && (r[1] & 0x80)) { - r = r.slice(1); - } - if (s[0] === 0 && (s[1] & 0x80)) { - s = s.slice(1); - } + /*--------------------------------------------------------------------------*/ - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error(type) { + throw new RangeError(errors[type]); + } - return true; -}; + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var length = array.length; + var result = []; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } -function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); -} + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = [], + counter = 0, + length = string.length, + value, + extra; + while (counter < length) { + value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // high surrogate, and there is a next character + extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { // low surrogate + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // unmatched surrogate; only append this code unit, in case the next + // code unit is the high surrogate of a surrogate pair + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + function ucs2encode(array) { + return map(array, function(value) { + var output = ''; + if (value > 0xFFFF) { + value -= 0x10000; + output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); + value = 0xDC00 | value & 0x3FF; + } + output += stringFromCharCode(value); + return output; + }).join(''); + } - r = rmPadding(r); - s = rmPadding(s); + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + function basicToDigit(codePoint) { + if (codePoint - 48 < 10) { + return codePoint - 22; + } + if (codePoint - 65 < 26) { + return codePoint - 65; + } + if (codePoint - 97 < 26) { + return codePoint - 97; + } + return base; + } - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); -}; + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + } -},{"../../elliptic":201,"bn.js":82}],211:[function(require,module,exports){ -'use strict'; + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + } -var hash = require('hash.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var KeyPair = require('./key'); -var Signature = require('./signature'); + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + function decode(input) { + // Don't use UCS-2 + var output = [], + inputLength = input.length, + out, + i = 0, + n = initialN, + bias = initialBias, + basic, + j, + index, + oldi, + w, + k, + digit, + t, + /** Cached calculation results */ + baseMinusT; -function EDDSA(curve) { - assert(curve === 'ed25519', 'only tested with ed25519 so far'); + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. - if (!(this instanceof EDDSA)) - return new EDDSA(curve); + basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } - var curve = elliptic.curves[curve].curve; - this.curve = curve; - this.g = curve.g; - this.g.precompute(curve.n.bitLength() + 1); + for (j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error('not-basic'); + } + output.push(input.charCodeAt(j)); + } - this.pointClass = curve.point().constructor; - this.encodingLength = Math.ceil(curve.n.bitLength() / 8); - this.hash = hash.sha512; -} + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. -module.exports = EDDSA; + for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { -/** -* @param {Array|String} message - message bytes -* @param {Array|String|KeyPair} secret - secret bytes or a keypair -* @returns {Signature} - signature -*/ -EDDSA.prototype.sign = function sign(message, secret) { - message = parseBytes(message); - var key = this.keyFromSecret(secret); - var r = this.hashInt(key.messagePrefix(), message); - var R = this.g.mul(r); - var Rencoded = this.encodePoint(R); - var s_ = this.hashInt(Rencoded, key.pubBytes(), message) - .mul(key.priv()); - var S = r.add(s_).umod(this.curve.n); - return this.makeSignature({ R: R, S: S, Rencoded: Rencoded }); -}; + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + for (oldi = i, w = 1, k = base; /* no condition */; k += base) { -/** -* @param {Array} message - message bytes -* @param {Array|String|Signature} sig - sig bytes -* @param {Array|String|Point|KeyPair} pub - public key -* @returns {Boolean} - true if public key matches sig of message -*/ -EDDSA.prototype.verify = function verify(message, sig, pub) { - message = parseBytes(message); - sig = this.makeSignature(sig); - var key = this.keyFromPublic(pub); - var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message); - var SG = this.g.mul(sig.S()); - var RplusAh = sig.R().add(key.pub().mul(h)); - return RplusAh.eq(SG); -}; + if (index >= inputLength) { + error('invalid-input'); + } -EDDSA.prototype.hashInt = function hashInt() { - var hash = this.hash(); - for (var i = 0; i < arguments.length; i++) - hash.update(arguments[i]); - return utils.intFromLE(hash.digest()).umod(this.curve.n); -}; + digit = basicToDigit(input.charCodeAt(index++)); -EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) { - return KeyPair.fromPublic(this, pub); -}; + if (digit >= base || digit > floor((maxInt - i) / w)) { + error('overflow'); + } -EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) { - return KeyPair.fromSecret(this, secret); -}; + i += digit * w; + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); -EDDSA.prototype.makeSignature = function makeSignature(sig) { - if (sig instanceof Signature) - return sig; - return new Signature(this, sig); -}; + if (digit < t) { + break; + } -/** -* * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2 -* -* EDDSA defines methods for encoding and decoding points and integers. These are -* helper convenience methods, that pass along to utility functions implied -* parameters. -* -*/ -EDDSA.prototype.encodePoint = function encodePoint(point) { - var enc = point.getY().toArray('le', this.encodingLength); - enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0; - return enc; -}; + baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error('overflow'); + } -EDDSA.prototype.decodePoint = function decodePoint(bytes) { - bytes = utils.parseBytes(bytes); + w *= baseMinusT; - var lastIx = bytes.length - 1; - var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80); - var xIsOdd = (bytes[lastIx] & 0x80) !== 0; + } - var y = utils.intFromLE(normed); - return this.curve.pointFromY(y, xIsOdd); -}; + out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); -EDDSA.prototype.encodeInt = function encodeInt(num) { - return num.toArray('le', this.encodingLength); -}; + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error('overflow'); + } -EDDSA.prototype.decodeInt = function decodeInt(bytes) { - return utils.intFromLE(bytes); -}; + n += floor(i / out); + i %= out; -EDDSA.prototype.isPoint = function isPoint(val) { - return val instanceof this.pointClass; -}; + // Insert `n` at position `i` of the output + output.splice(i++, 0, n); -},{"../../elliptic":201,"./key":212,"./signature":213,"hash.js":223}],212:[function(require,module,exports){ -'use strict'; + } -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var parseBytes = utils.parseBytes; -var cachedProperty = utils.cachedProperty; + return ucs2encode(output); + } -/** -* @param {EDDSA} eddsa - instance -* @param {Object} params - public/private key parameters -* -* @param {Array} [params.secret] - secret seed bytes -* @param {Point} [params.pub] - public key point (aka `A` in eddsa terms) -* @param {Array} [params.pub] - public key point encoded as bytes -* -*/ -function KeyPair(eddsa, params) { - this.eddsa = eddsa; - this._secret = parseBytes(params.secret); - if (eddsa.isPoint(params.pub)) - this._pub = params.pub; - else - this._pubBytes = parseBytes(params.pub); -} + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + function encode(input) { + var n, + delta, + handledCPCount, + basicLength, + bias, + j, + m, + q, + k, + t, + currentValue, + output = [], + /** `inputLength` will hold the number of code points in `input`. */ + inputLength, + /** Cached calculation results */ + handledCPCountPlusOne, + baseMinusT, + qMinusT; -KeyPair.fromPublic = function fromPublic(eddsa, pub) { - if (pub instanceof KeyPair) - return pub; - return new KeyPair(eddsa, { pub: pub }); -}; + // Convert the input in UCS-2 to Unicode + input = ucs2decode(input); -KeyPair.fromSecret = function fromSecret(eddsa, secret) { - if (secret instanceof KeyPair) - return secret; - return new KeyPair(eddsa, { secret: secret }); -}; + // Cache the length + inputLength = input.length; -KeyPair.prototype.secret = function secret() { - return this._secret; -}; + // Initialize the state + n = initialN; + delta = 0; + bias = initialBias; -cachedProperty(KeyPair, 'pubBytes', function pubBytes() { - return this.eddsa.encodePoint(this.pub()); -}); + // Handle the basic code points + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue < 0x80) { + output.push(stringFromCharCode(currentValue)); + } + } -cachedProperty(KeyPair, 'pub', function pub() { - if (this._pubBytes) - return this.eddsa.decodePoint(this._pubBytes); - return this.eddsa.g.mul(this.priv()); -}); + handledCPCount = basicLength = output.length; -cachedProperty(KeyPair, 'privBytes', function privBytes() { - var eddsa = this.eddsa; - var hash = this.hash(); - var lastIx = eddsa.encodingLength - 1; + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. - var a = hash.slice(0, eddsa.encodingLength); - a[0] &= 248; - a[lastIx] &= 127; - a[lastIx] |= 64; + // Finish the basic string - if it is not empty - with a delimiter + if (basicLength) { + output.push(delimiter); + } - return a; -}); + // Main encoding loop: + while (handledCPCount < inputLength) { -cachedProperty(KeyPair, 'priv', function priv() { - return this.eddsa.decodeInt(this.privBytes()); -}); + // All non-basic code points < n have been handled already. Find the next + // larger one: + for (m = maxInt, j = 0; j < inputLength; ++j) { + currentValue = input[j]; + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } -cachedProperty(KeyPair, 'hash', function hash() { - return this.eddsa.hash().update(this.secret()).digest(); -}); + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow + handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error('overflow'); + } -cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() { - return this.hash().slice(this.eddsa.encodingLength); -}); + delta += (m - n) * handledCPCountPlusOne; + n = m; -KeyPair.prototype.sign = function sign(message) { - assert(this._secret, 'KeyPair can only verify'); - return this.eddsa.sign(message, this); -}; + for (j = 0; j < inputLength; ++j) { + currentValue = input[j]; -KeyPair.prototype.verify = function verify(message, sig) { - return this.eddsa.verify(message, sig, this); -}; + if (currentValue < n && ++delta > maxInt) { + error('overflow'); + } -KeyPair.prototype.getSecret = function getSecret(enc) { - assert(this._secret, 'KeyPair is public only'); - return utils.encode(this.secret(), enc); -}; + if (currentValue == n) { + // Represent delta as a generalized variable-length integer + for (q = delta, k = base; /* no condition */; k += base) { + t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); + if (q < t) { + break; + } + qMinusT = q - t; + baseMinusT = base - t; + output.push( + stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) + ); + q = floor(qMinusT / baseMinusT); + } -KeyPair.prototype.getPublic = function getPublic(enc) { - return utils.encode(this.pubBytes(), enc); -}; + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } -module.exports = KeyPair; + ++delta; + ++n; -},{"../../elliptic":201}],213:[function(require,module,exports){ -'use strict'; + } + return output.join(''); + } -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; -var cachedProperty = utils.cachedProperty; -var parseBytes = utils.parseBytes; + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + function toUnicode(input) { + return mapDomain(input, function(string) { + return regexPunycode.test(string) + ? decode(string.slice(4).toLowerCase()) + : string; + }); + } -/** -* @param {EDDSA} eddsa - eddsa instance -* @param {Array|Object} sig - -* @param {Array|Point} [sig.R] - R point as Point or bytes -* @param {Array|bn} [sig.S] - S scalar as bn or bytes -* @param {Array} [sig.Rencoded] - R point encoded -* @param {Array} [sig.Sencoded] - S scalar encoded -*/ -function Signature(eddsa, sig) { - this.eddsa = eddsa; + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + function toASCII(input) { + return mapDomain(input, function(string) { + return regexNonASCII.test(string) + ? 'xn--' + encode(string) + : string; + }); + } - if (typeof sig !== 'object') - sig = parseBytes(sig); + /*--------------------------------------------------------------------------*/ - if (Array.isArray(sig)) { - sig = { - R: sig.slice(0, eddsa.encodingLength), - S: sig.slice(eddsa.encodingLength) - }; - } + /** Define the public API */ + punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '1.4.1', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; - assert(sig.R && sig.S, 'Signature without R or S'); + /** Expose `punycode` */ + // Some AMD build optimizers, like r.js, check for specific condition patterns + // like the following: + if ( + typeof define == 'function' && + typeof define.amd == 'object' && + define.amd + ) { + define('punycode', function() { + return punycode; + }); + } else if (freeExports && freeModule) { + if (module.exports == freeExports) { + // in Node.js, io.js, or RingoJS v0.8.0+ + freeModule.exports = punycode; + } else { + // in Narwhal or RingoJS v0.7.0- + for (key in punycode) { + punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); + } + } + } else { + // in Rhino or a web browser + root.punycode = punycode; + } - if (eddsa.isPoint(sig.R)) - this._R = sig.R; - if (sig.S instanceof BN) - this._S = sig.S; +}(this)); - this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded; - this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded; -} +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],222:[function(require,module,exports){ +module.exports = require('./lib/_stream_duplex.js'); -cachedProperty(Signature, 'S', function S() { - return this.eddsa.decodeInt(this.Sencoded()); -}); +},{"./lib/_stream_duplex.js":223}],223:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -cachedProperty(Signature, 'R', function R() { - return this.eddsa.decodePoint(this.Rencoded()); -}); +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. -cachedProperty(Signature, 'Rencoded', function Rencoded() { - return this.eddsa.encodePoint(this.R()); -}); +'use strict'; -cachedProperty(Signature, 'Sencoded', function Sencoded() { - return this.eddsa.encodeInt(this.S()); -}); +/**/ -Signature.prototype.toBytes = function toBytes() { - return this.Rencoded().concat(this.Sencoded()); -}; +var pna = require('process-nextick-args'); +/**/ -Signature.prototype.toHex = function toHex() { - return utils.encode(this.toBytes(), 'hex').toUpperCase(); +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; }; +/**/ -module.exports = Signature; +module.exports = Duplex; -},{"../../elliptic":201,"bn.js":82}],214:[function(require,module,exports){ -module.exports = { - doubles: { - step: 4, - points: [ - [ - 'e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a', - 'f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821' - ], - [ - '8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508', - '11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf' - ], - [ - '175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739', - 'd3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695' - ], - [ - '363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640', - '4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9' - ], - [ - '8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c', - '4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36' - ], - [ - '723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda', - '96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f' - ], - [ - 'eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa', - '5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999' - ], - [ - '100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0', - 'cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09' - ], - [ - 'e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d', - '9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d' - ], - [ - 'feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d', - 'e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088' - ], - [ - 'da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1', - '9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d' - ], - [ - '53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0', - '5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8' - ], - [ - '8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047', - '10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a' - ], - [ - '385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862', - '283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453' - ], - [ - '6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7', - '7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160' - ], - [ - '3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd', - '56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0' - ], - [ - '85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83', - '7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6' - ], - [ - '948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a', - '53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589' - ], - [ - '6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8', - 'bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17' - ], - [ - 'e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d', - '4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda' - ], - [ - 'e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725', - '7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd' - ], - [ - '213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754', - '4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2' - ], - [ - '4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c', - '17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6' - ], - [ - 'fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6', - '6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f' - ], - [ - '76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39', - 'c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01' - ], - [ - 'c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891', - '893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3' - ], - [ - 'd895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b', - 'febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f' - ], - [ - 'b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03', - '2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7' - ], - [ - 'e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d', - 'eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78' - ], - [ - 'a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070', - '7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1' - ], - [ - '90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4', - 'e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150' - ], - [ - '8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da', - '662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82' - ], - [ - 'e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11', - '1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc' - ], - [ - '8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e', - 'efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b' - ], - [ - 'e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41', - '2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51' - ], - [ - 'b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef', - '67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45' - ], - [ - 'd68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8', - 'db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120' - ], - [ - '324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d', - '648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84' - ], - [ - '4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96', - '35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d' - ], - [ - '9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd', - 'ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d' - ], - [ - '6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5', - '9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8' - ], - [ - 'a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266', - '40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8' - ], - [ - '7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71', - '34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac' - ], - [ - '928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac', - 'c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f' - ], - [ - '85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751', - '1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962' - ], - [ - 'ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e', - '493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907' - ], - [ - '827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241', - 'c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec' - ], - [ - 'eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3', - 'be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d' - ], - [ - 'e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f', - '4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414' - ], - [ - '1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19', - 'aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd' - ], - [ - '146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be', - 'b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0' - ], - [ - 'fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9', - '6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811' - ], - [ - 'da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2', - '8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1' - ], - [ - 'a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13', - '7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c' - ], - [ - '174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c', - 'ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73' - ], - [ - '959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba', - '2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd' - ], - [ - 'd2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151', - 'e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405' - ], - [ - '64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073', - 'd99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589' - ], - [ - '8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458', - '38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e' - ], - [ - '13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b', - '69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27' - ], - [ - 'bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366', - 'd3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1' - ], - [ - '8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa', - '40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482' - ], - [ - '8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0', - '620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945' - ], - [ - 'dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787', - '7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573' - ], - [ - 'f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e', - 'ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82' - ] - ] +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +{ + // avoid scope creep, the keys array can then be collected + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + pna.nextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; }, - naf: { - wnd: 7, - points: [ - [ - 'f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9', - '388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672' - ], - [ - '2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4', - 'd8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6' - ], - [ - '5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc', - '6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da' - ], - [ - 'acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe', - 'cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37' - ], - [ - '774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb', - 'd984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b' - ], - [ - 'f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8', - 'ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81' - ], - [ - 'd7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e', - '581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58' - ], - [ - 'defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34', - '4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77' - ], - [ - '2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c', - '85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a' - ], - [ - '352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5', - '321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c' - ], - [ - '2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f', - '2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67' - ], - [ - '9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714', - '73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402' - ], - [ - 'daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729', - 'a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55' - ], - [ - 'c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db', - '2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482' - ], - [ - '6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4', - 'e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82' - ], - [ - '1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5', - 'b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396' - ], - [ - '605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479', - '2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49' - ], - [ - '62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d', - '80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf' - ], - [ - '80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f', - '1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a' - ], - [ - '7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb', - 'd0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7' - ], - [ - 'd528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9', - 'eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933' - ], - [ - '49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963', - '758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a' - ], - [ - '77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74', - '958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6' - ], - [ - 'f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530', - 'e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37' - ], - [ - '463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b', - '5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e' - ], - [ - 'f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247', - 'cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6' - ], - [ - 'caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1', - 'cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476' - ], - [ - '2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120', - '4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40' - ], - [ - '7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435', - '91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61' - ], - [ - '754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18', - '673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683' - ], - [ - 'e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8', - '59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5' - ], - [ - '186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb', - '3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b' - ], - [ - 'df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f', - '55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417' - ], - [ - '5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143', - 'efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868' - ], - [ - '290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba', - 'e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a' - ], - [ - 'af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45', - 'f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6' - ], - [ - '766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a', - '744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996' - ], - [ - '59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e', - 'c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e' - ], - [ - 'f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8', - 'e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d' - ], - [ - '7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c', - '30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2' - ], - [ - '948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519', - 'e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e' - ], - [ - '7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab', - '100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437' - ], - [ - '3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca', - 'ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311' - ], - [ - 'd3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf', - '8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4' - ], - [ - '1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610', - '68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575' - ], - [ - '733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4', - 'f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d' - ], - [ - '15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c', - 'd56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d' - ], - [ - 'a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940', - 'edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629' - ], - [ - 'e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980', - 'a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06' - ], - [ - '311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3', - '66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374' - ], - [ - '34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf', - '9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee' - ], - [ - 'f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63', - '4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1' - ], - [ - 'd7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448', - 'fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b' - ], - [ - '32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf', - '5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661' - ], - [ - '7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5', - '8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6' - ], - [ - 'ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6', - '8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e' - ], - [ - '16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5', - '5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d' - ], - [ - 'eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99', - 'f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc' - ], - [ - '78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51', - 'f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4' - ], - [ - '494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5', - '42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c' - ], - [ - 'a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5', - '204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b' - ], - [ - 'c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997', - '4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913' - ], - [ - '841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881', - '73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154' - ], - [ - '5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5', - '39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865' - ], - [ - '36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66', - 'd2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc' - ], - [ - '336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726', - 'ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224' - ], - [ - '8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede', - '6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e' - ], - [ - '1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94', - '60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6' - ], - [ - '85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31', - '3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511' - ], - [ - '29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51', - 'b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b' - ], - [ - 'a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252', - 'ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2' - ], - [ - '4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5', - 'cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c' - ], - [ - 'd24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b', - '6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3' - ], - [ - 'ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4', - '322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d' - ], - [ - 'af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f', - '6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700' - ], - [ - 'e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889', - '2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4' - ], - [ - '591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246', - 'b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196' - ], - [ - '11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984', - '998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4' - ], - [ - '3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a', - 'b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257' - ], - [ - 'cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030', - 'bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13' - ], - [ - 'c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197', - '6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096' - ], - [ - 'c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593', - 'c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38' - ], - [ - 'a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef', - '21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f' - ], - [ - '347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38', - '60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448' - ], - [ - 'da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a', - '49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a' - ], - [ - 'c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111', - '5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4' - ], - [ - '4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502', - '7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437' - ], - [ - '3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea', - 'be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7' - ], - [ - 'cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26', - '8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d' - ], - [ - 'b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986', - '39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a' - ], - [ - 'd4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e', - '62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54' - ], - [ - '48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4', - '25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77' - ], - [ - 'dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda', - 'ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517' - ], - [ - '6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859', - 'cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10' - ], - [ - 'e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f', - 'f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125' - ], - [ - 'eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c', - '6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e' - ], - [ - '13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942', - 'fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1' - ], - [ - 'ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a', - '1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2' - ], - [ - 'b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80', - '5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423' - ], - [ - 'ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d', - '438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8' - ], - [ - '8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1', - 'cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758' - ], - [ - '52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63', - 'c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375' - ], - [ - 'e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352', - '6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d' - ], - [ - '7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193', - 'ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec' - ], - [ - '5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00', - '9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0' - ], - [ - '32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58', - 'ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c' - ], - [ - 'e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7', - 'd3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4' - ], - [ - '8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8', - 'c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f' - ], - [ - '4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e', - '67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649' - ], - [ - '3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d', - 'cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826' - ], - [ - '674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b', - '299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5' - ], - [ - 'd32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f', - 'f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87' - ], - [ - '30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6', - '462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b' - ], - [ - 'be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297', - '62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc' - ], - [ - '93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a', - '7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c' - ], - [ - 'b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c', - 'ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f' - ], - [ - 'd5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52', - '4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a' - ], - [ - 'd3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb', - 'bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46' - ], - [ - '463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065', - 'bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f' - ], - [ - '7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917', - '603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03' - ], - [ - '74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9', - 'cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08' - ], - [ - '30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3', - '553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8' - ], - [ - '9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57', - '712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373' - ], - [ - '176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66', - 'ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3' - ], - [ - '75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8', - '9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8' - ], - [ - '809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721', - '9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1' - ], - [ - '1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180', - '4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9' - ] - ] + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + pna.nextTick(cb, err); +}; +},{"./_stream_readable":225,"./_stream_writable":227,"core-util-is":116,"inherits":258,"process-nextick-args":231}],224:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":226,"core-util-is":116,"inherits":258}],225:[function(require,module,exports){ +(function (process,global){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Readable; + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = require('events').EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = require('./internal/streams/BufferList'); +var destroyImpl = require('./internal/streams/destroy'); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + pna.nextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + pna.nextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + pna.nextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._readableState.highWaterMark; + } +}); + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + pna.nextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./_stream_duplex":223,"./internal/streams/BufferList":228,"./internal/streams/destroy":229,"./internal/streams/stream":230,"_process":270,"core-util-is":116,"events":220,"inherits":258,"isarray":260,"process-nextick-args":231,"safe-buffer":237,"string_decoder/":232,"util":219}],226:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} +},{"./_stream_duplex":223,"core-util-is":116,"inherits":258}],227:[function(require,module,exports){ +(function (process,global,setImmediate){(function (){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = Object.create(require('core-util-is')); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream = require('./internal/streams/stream'); +/**/ + +/**/ + +var Buffer = require('safe-buffer').Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = require('./internal/streams/destroy'); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + pna.nextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + pna.nextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } + + return ret; }; -},{}],215:[function(require,module,exports){ -'use strict'; +Writable.prototype.cork = function () { + var state = this._writableState; -var utils = exports; -var BN = require('bn.js'); -var minAssert = require('minimalistic-assert'); -var minUtils = require('minimalistic-crypto-utils'); + state.corked++; +}; -utils.assert = minAssert; -utils.toArray = minUtils.toArray; -utils.zero2 = minUtils.zero2; -utils.toHex = minUtils.toHex; -utils.encode = minUtils.encode; +Writable.prototype.uncork = function () { + var state = this._writableState; -// Represent num in a w-NAF form -function getNAF(num, w) { - var naf = []; - var ws = 1 << (w + 1); - var k = num.clone(); - while (k.cmpn(1) >= 0) { - var z; - if (k.isOdd()) { - var mod = k.andln(ws - 1); - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} + +Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function () { + return this._writableState.highWaterMark; + } +}); + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; } else { - z = 0; + state.bufferedRequest = state.lastBufferedRequest; } - naf.push(z); + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; - // Optimization, shift by word if possible - var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; - for (var i = 1; i < shift; i++) - naf.push(0); - k.iushrn(shift); + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + pna.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + pna.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); } +} - return naf; +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; } -utils.getNAF = getNAF; -// Represent k1, k2 in a Joint Sparse Form -function getJSF(k1, k2) { - var jsf = [ - [], - [] - ]; +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + onwriteStateUpdate(state); - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ } else { - var m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; + afterWrite(stream, state, finished, cb); } - jsf[0].push(u1); + } +} - var u2; - if ((m24 & 1) === 0) { - u2 = 0; +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; } else { - var m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; + state.corkedRequestsFree = new CorkedRequest(state); } - jsf[1].push(u2); + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; } - return jsf; + state.bufferedRequest = entry; + state.bufferProcessing = false; } -utils.getJSF = getJSF; -function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + pna.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) +},{"./_stream_duplex":223,"./internal/streams/destroy":229,"./internal/streams/stream":230,"_process":270,"core-util-is":116,"inherits":258,"process-nextick-args":231,"safe-buffer":237,"timers":348,"util-deprecate":356}],228:[function(require,module,exports){ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = require('safe-buffer').Buffer; +var util = require('util'); + +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} + +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; }; } -utils.cachedProperty = cachedProperty; +},{"safe-buffer":237,"util":219}],229:[function(require,module,exports){ +'use strict'; + +/**/ + +var pna = require('process-nextick-args'); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); + } + return this; + } -function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; -} -utils.parseBytes = parseBytes; + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks -function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); -} -utils.intFromLE = intFromLE; + if (this._readableState) { + this._readableState.destroyed = true; + } + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } -},{"bn.js":82,"minimalistic-assert":245,"minimalistic-crypto-utils":246}],216:[function(require,module,exports){ -module.exports={ - "_from": "elliptic@^6.2.3", - "_id": "elliptic@6.4.1", - "_inBundle": false, - "_integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", - "_location": "/elliptic", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "elliptic@^6.2.3", - "name": "elliptic", - "escapedName": "elliptic", - "rawSpec": "^6.2.3", - "saveSpec": null, - "fetchSpec": "^6.2.3" - }, - "_requiredBy": [ - "/create-ecdh", - "/crypto-browserify/browserify-sign", - "/secp256k1" - ], - "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "_shasum": "c2d0b7776911b86722c632c3c06c60f2f819939a", - "_spec": "elliptic@^6.2.3", - "_where": "/work/blocktrail-sdk-nodejs/node_modules/secp256k1", - "author": { - "name": "Fedor Indutny", - "email": "fedor@indutny.com" - }, - "bugs": { - "url": "https://github.com/indutny/elliptic/issues" - }, - "bundleDependencies": false, - "dependencies": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" - }, - "deprecated": false, - "description": "EC cryptography", - "devDependencies": { - "brfs": "^1.4.3", - "coveralls": "^2.11.3", - "grunt": "^0.4.5", - "grunt-browserify": "^5.0.0", - "grunt-cli": "^1.2.0", - "grunt-contrib-connect": "^1.0.0", - "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-uglify": "^1.0.1", - "grunt-mocha-istanbul": "^3.0.1", - "grunt-saucelabs": "^8.6.2", - "istanbul": "^0.4.2", - "jscs": "^2.9.0", - "jshint": "^2.6.0", - "mocha": "^2.1.0" - }, - "files": [ - "lib" - ], - "homepage": "https://github.com/indutny/elliptic", - "keywords": [ - "EC", - "Elliptic", - "curve", - "Cryptography" - ], - "license": "MIT", - "main": "lib/elliptic.js", - "name": "elliptic", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/indutny/elliptic.git" - }, - "scripts": { - "jscs": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "jshint": "jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js", - "lint": "npm run jscs && npm run jshint", - "test": "npm run lint && npm run unit", - "unit": "istanbul test _mocha --reporter=spec test/index.js", - "version": "grunt dist && git add dist/" - }, - "version": "6.4.1" + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); + + return this; } -},{}],217:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var MD5 = require('md5.js') +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } -/* eslint-disable camelcase */ -function EVP_BytesToKey (password, salt, keyBits, ivLen) { - if (!Buffer.isBuffer(password)) password = Buffer.from(password, 'binary') - if (salt) { - if (!Buffer.isBuffer(salt)) salt = Buffer.from(salt, 'binary') - if (salt.length !== 8) throw new RangeError('salt should be Buffer with 8 byte length') + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; } +} - var keyLen = keyBits / 8 - var key = Buffer.alloc(keyLen) - var iv = Buffer.alloc(ivLen || 0) - var tmp = Buffer.alloc(0) +function emitErrorNT(self, err) { + self.emit('error', err); +} - while (keyLen > 0 || ivLen > 0) { - var hash = new MD5() - hash.update(tmp) - hash.update(password) - if (salt) hash.update(salt) - tmp = hash.digest() +module.exports = { + destroy: destroy, + undestroy: undestroy +}; +},{"process-nextick-args":231}],230:[function(require,module,exports){ +module.exports = require('events').EventEmitter; - var used = 0 +},{"events":220}],231:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; - if (keyLen > 0) { - var keyStart = key.length - keyLen - used = Math.min(keyLen, tmp.length) - tmp.copy(key, keyStart, 0, used) - keyLen -= used - } +if (typeof process === 'undefined' || + !process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process +} - if (used < tmp.length && ivLen > 0) { - var ivStart = iv.length - ivLen - var length = Math.min(ivLen, tmp.length - used) - tmp.copy(iv, ivStart, used, used + length) - ivLen -= length +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); } - - tmp.fill(0) - return { key: key, iv: iv } } -module.exports = EVP_BytesToKey -},{"md5.js":242,"safe-buffer":298}],218:[function(require,module,exports){ +}).call(this)}).call(this,require('_process')) +},{"_process":270}],232:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -41336,826 +48326,493 @@ module.exports = EVP_BytesToKey // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; +'use strict'; -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; +/**/ - if (!this._events) - this._events = {}; +var Buffer = require('safe-buffer').Buffer; +/**/ - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; } +}; - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); } - - return true; }; -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} - return this; +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; }; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; +StringDecoder.prototype.end = utf8End; - function g() { - this.removeListener(type, g); +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; - if (!fired) { - fired = true; - listener.apply(this, arguments); - } +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); } - - g.listener = listener; - this.on(type, g); - - return this; + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; }; -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. If an invalid byte is detected, -2 is returned. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; +} - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); + return nb; } + return 0; +} - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; } +} - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); } - delete this._events[type]; - - return this; -}; + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; +// For UTF-8, a replacement character is added when ending on a partial +// character. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; +} - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; } - return 0; -}; - -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; - -function isFunction(arg) { - return typeof arg === 'function'; + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); } -function isNumber(arg) { - return typeof arg === 'number'; +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; } -function isObject(arg) { - return typeof arg === 'object' && arg !== null; +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); } -function isUndefined(arg) { - return arg === void 0; +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; } -},{}],219:[function(require,module,exports){ -(function (global){ -/*! https://mths.be/punycode v1.4.1 by @mathias */ -;(function(root) { - - /** Detect free variables */ - var freeExports = typeof exports == 'object' && exports && - !exports.nodeType && exports; - var freeModule = typeof module == 'object' && module && - !module.nodeType && module; - var freeGlobal = typeof global == 'object' && global; - if ( - freeGlobal.global === freeGlobal || - freeGlobal.window === freeGlobal || - freeGlobal.self === freeGlobal - ) { - root = freeGlobal; - } - - /** - * The `punycode` object. - * @name punycode - * @type Object - */ - var punycode, - - /** Highest positive signed 32-bit float value */ - maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 - - /** Bootstring parameters */ - base = 36, - tMin = 1, - tMax = 26, - skew = 38, - damp = 700, - initialBias = 72, - initialN = 128, // 0x80 - delimiter = '-', // '\x2D' - - /** Regular expressions */ - regexPunycode = /^xn--/, - regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars - regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators - - /** Error messages */ - errors = { - 'overflow': 'Overflow: input needs wider integers to process', - 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', - 'invalid-input': 'Invalid input' - }, - - /** Convenience shortcuts */ - baseMinusTMin = base - tMin, - floor = Math.floor, - stringFromCharCode = String.fromCharCode, - - /** Temporary variable */ - key; - - /*--------------------------------------------------------------------------*/ - - /** - * A generic error utility function. - * @private - * @param {String} type The error type. - * @returns {Error} Throws a `RangeError` with the applicable error message. - */ - function error(type) { - throw new RangeError(errors[type]); - } - - /** - * A generic `Array#map` utility function. - * @private - * @param {Array} array The array to iterate over. - * @param {Function} callback The function that gets called for every array - * item. - * @returns {Array} A new array of values returned by the callback function. - */ - function map(array, fn) { - var length = array.length; - var result = []; - while (length--) { - result[length] = fn(array[length]); - } - return result; - } - - /** - * A simple `Array#map`-like wrapper to work with domain name strings or email - * addresses. - * @private - * @param {String} domain The domain name or email address. - * @param {Function} callback The function that gets called for every - * character. - * @returns {Array} A new string of characters returned by the callback - * function. - */ - function mapDomain(string, fn) { - var parts = string.split('@'); - var result = ''; - if (parts.length > 1) { - // In email addresses, only the domain name should be punycoded. Leave - // the local part (i.e. everything up to `@`) intact. - result = parts[0] + '@'; - string = parts[1]; - } - // Avoid `split(regex)` for IE8 compatibility. See #17. - string = string.replace(regexSeparators, '\x2E'); - var labels = string.split('.'); - var encoded = map(labels, fn).join('.'); - return result + encoded; - } - - /** - * Creates an array containing the numeric code points of each Unicode - * character in the string. While JavaScript uses UCS-2 internally, - * this function will convert a pair of surrogate halves (each of which - * UCS-2 exposes as separate characters) into a single code point, - * matching UTF-16. - * @see `punycode.ucs2.encode` - * @see - * @memberOf punycode.ucs2 - * @name decode - * @param {String} string The Unicode input string (UCS-2). - * @returns {Array} The new array of code points. - */ - function ucs2decode(string) { - var output = [], - counter = 0, - length = string.length, - value, - extra; - while (counter < length) { - value = string.charCodeAt(counter++); - if (value >= 0xD800 && value <= 0xDBFF && counter < length) { - // high surrogate, and there is a next character - extra = string.charCodeAt(counter++); - if ((extra & 0xFC00) == 0xDC00) { // low surrogate - output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); - } else { - // unmatched surrogate; only append this code unit, in case the next - // code unit is the high surrogate of a surrogate pair - output.push(value); - counter--; - } - } else { - output.push(value); - } - } - return output; - } - - /** - * Creates a string based on an array of numeric code points. - * @see `punycode.ucs2.decode` - * @memberOf punycode.ucs2 - * @name encode - * @param {Array} codePoints The array of numeric code points. - * @returns {String} The new Unicode string (UCS-2). - */ - function ucs2encode(array) { - return map(array, function(value) { - var output = ''; - if (value > 0xFFFF) { - value -= 0x10000; - output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); - value = 0xDC00 | value & 0x3FF; - } - output += stringFromCharCode(value); - return output; - }).join(''); - } - - /** - * Converts a basic code point into a digit/integer. - * @see `digitToBasic()` - * @private - * @param {Number} codePoint The basic numeric code point value. - * @returns {Number} The numeric value of a basic code point (for use in - * representing integers) in the range `0` to `base - 1`, or `base` if - * the code point does not represent a value. - */ - function basicToDigit(codePoint) { - if (codePoint - 48 < 10) { - return codePoint - 22; - } - if (codePoint - 65 < 26) { - return codePoint - 65; - } - if (codePoint - 97 < 26) { - return codePoint - 97; - } - return base; - } - - /** - * Converts a digit/integer into a basic code point. - * @see `basicToDigit()` - * @private - * @param {Number} digit The numeric value of a basic code point. - * @returns {Number} The basic code point whose value (when used for - * representing integers) is `digit`, which needs to be in the range - * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is - * used; else, the lowercase form is used. The behavior is undefined - * if `flag` is non-zero and `digit` has no uppercase form. - */ - function digitToBasic(digit, flag) { - // 0..25 map to ASCII a..z or A..Z - // 26..35 map to ASCII 0..9 - return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); - } - - /** - * Bias adaptation function as per section 3.4 of RFC 3492. - * https://tools.ietf.org/html/rfc3492#section-3.4 - * @private - */ - function adapt(delta, numPoints, firstTime) { - var k = 0; - delta = firstTime ? floor(delta / damp) : delta >> 1; - delta += floor(delta / numPoints); - for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { - delta = floor(delta / baseMinusTMin); - } - return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); - } - - /** - * Converts a Punycode string of ASCII-only symbols to a string of Unicode - * symbols. - * @memberOf punycode - * @param {String} input The Punycode string of ASCII-only symbols. - * @returns {String} The resulting string of Unicode symbols. - */ - function decode(input) { - // Don't use UCS-2 - var output = [], - inputLength = input.length, - out, - i = 0, - n = initialN, - bias = initialBias, - basic, - j, - index, - oldi, - w, - k, - digit, - t, - /** Cached calculation results */ - baseMinusT; - - // Handle the basic code points: let `basic` be the number of input code - // points before the last delimiter, or `0` if there is none, then copy - // the first basic code points to the output. +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} - basic = input.lastIndexOf(delimiter); - if (basic < 0) { - basic = 0; - } +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} +},{"safe-buffer":237}],233:[function(require,module,exports){ +module.exports = require('./readable').PassThrough - for (j = 0; j < basic; ++j) { - // if it's not a basic code point - if (input.charCodeAt(j) >= 0x80) { - error('not-basic'); - } - output.push(input.charCodeAt(j)); - } +},{"./readable":234}],234:[function(require,module,exports){ +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); - // Main decoding loop: start just after the last delimiter if any basic code - // points were copied; start at the beginning otherwise. +},{"./lib/_stream_duplex.js":223,"./lib/_stream_passthrough.js":224,"./lib/_stream_readable.js":225,"./lib/_stream_transform.js":226,"./lib/_stream_writable.js":227}],235:[function(require,module,exports){ +module.exports = require('./readable').Transform - for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { +},{"./readable":234}],236:[function(require,module,exports){ +module.exports = require('./lib/_stream_writable.js'); - // `index` is the index of the next character to be consumed. - // Decode a generalized variable-length integer into `delta`, - // which gets added to `i`. The overflow checking is easier - // if we increase `i` as we go, then subtract off its starting - // value at the end to obtain `delta`. - for (oldi = i, w = 1, k = base; /* no condition */; k += base) { +},{"./lib/_stream_writable.js":227}],237:[function(require,module,exports){ +/* eslint-disable node/no-deprecated-api */ +var buffer = require('buffer') +var Buffer = buffer.Buffer - if (index >= inputLength) { - error('invalid-input'); - } +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} - digit = basicToDigit(input.charCodeAt(index++)); +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} - if (digit >= base || digit > floor((maxInt - i) / w)) { - error('overflow'); - } +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) - i += digit * w; - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} - if (digit < t) { - break; - } +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} - baseMinusT = base - t; - if (w > floor(maxInt / baseMinusT)) { - error('overflow'); - } +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} - w *= baseMinusT; +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} - } +},{"buffer":110}],238:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - out = output.length + 1; - bias = adapt(i - oldi, out, oldi == 0); +module.exports = Stream; - // `i` was supposed to wrap around from `out` to `0`, - // incrementing `n` each time, so we'll fix that now: - if (floor(i / out) > maxInt - n) { - error('overflow'); - } +var EE = require('events').EventEmitter; +var inherits = require('inherits'); - n += floor(i / out); - i %= out; +inherits(Stream, EE); +Stream.Readable = require('readable-stream/readable.js'); +Stream.Writable = require('readable-stream/writable.js'); +Stream.Duplex = require('readable-stream/duplex.js'); +Stream.Transform = require('readable-stream/transform.js'); +Stream.PassThrough = require('readable-stream/passthrough.js'); - // Insert `n` at position `i` of the output - output.splice(i++, 0, n); +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; - } - return ucs2encode(output); - } - /** - * Converts a string of Unicode symbols (e.g. a domain name label) to a - * Punycode string of ASCII-only symbols. - * @memberOf punycode - * @param {String} input The string of Unicode symbols. - * @returns {String} The resulting Punycode string of ASCII-only symbols. - */ - function encode(input) { - var n, - delta, - handledCPCount, - basicLength, - bias, - j, - m, - q, - k, - t, - currentValue, - output = [], - /** `inputLength` will hold the number of code points in `input`. */ - inputLength, - /** Cached calculation results */ - handledCPCountPlusOne, - baseMinusT, - qMinusT; +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. - // Convert the input in UCS-2 to Unicode - input = ucs2decode(input); +function Stream() { + EE.call(this); +} - // Cache the length - inputLength = input.length; +Stream.prototype.pipe = function(dest, options) { + var source = this; - // Initialize the state - n = initialN; - delta = 0; - bias = initialBias; + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } - // Handle the basic code points - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue < 0x80) { - output.push(stringFromCharCode(currentValue)); - } - } + source.on('data', ondata); - handledCPCount = basicLength = output.length; + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } - // `handledCPCount` is the number of code points that have been handled; - // `basicLength` is the number of basic code points. + dest.on('drain', ondrain); - // Finish the basic string - if it is not empty - with a delimiter - if (basicLength) { - output.push(delimiter); - } + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } - // Main encoding loop: - while (handledCPCount < inputLength) { + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; - // All non-basic code points < n have been handled already. Find the next - // larger one: - for (m = maxInt, j = 0; j < inputLength; ++j) { - currentValue = input[j]; - if (currentValue >= n && currentValue < m) { - m = currentValue; - } - } + dest.end(); + } - // Increase `delta` enough to advance the decoder's state to , - // but guard against overflow - handledCPCountPlusOne = handledCPCount + 1; - if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - error('overflow'); - } - delta += (m - n) * handledCPCountPlusOne; - n = m; + function onclose() { + if (didOnEnd) return; + didOnEnd = true; - for (j = 0; j < inputLength; ++j) { - currentValue = input[j]; + if (typeof dest.destroy === 'function') dest.destroy(); + } - if (currentValue < n && ++delta > maxInt) { - error('overflow'); - } + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } - if (currentValue == n) { - // Represent delta as a generalized variable-length integer - for (q = delta, k = base; /* no condition */; k += base) { - t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); - if (q < t) { - break; - } - qMinusT = q - t; - baseMinusT = base - t; - output.push( - stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) - ); - q = floor(qMinusT / baseMinusT); - } + source.on('error', onerror); + dest.on('error', onerror); - output.push(stringFromCharCode(digitToBasic(q, 0))); - bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); - delta = 0; - ++handledCPCount; - } - } + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); - ++delta; - ++n; + source.removeListener('end', onend); + source.removeListener('close', onclose); - } - return output.join(''); - } + source.removeListener('error', onerror); + dest.removeListener('error', onerror); - /** - * Converts a Punycode string representing a domain name or an email address - * to Unicode. Only the Punycoded parts of the input will be converted, i.e. - * it doesn't matter if you call it on a string that has already been - * converted to Unicode. - * @memberOf punycode - * @param {String} input The Punycoded domain name or email address to - * convert to Unicode. - * @returns {String} The Unicode representation of the given Punycode - * string. - */ - function toUnicode(input) { - return mapDomain(input, function(string) { - return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) - : string; - }); - } + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); - /** - * Converts a Unicode string representing a domain name or an email address to - * Punycode. Only the non-ASCII parts of the domain name will be converted, - * i.e. it doesn't matter if you call it with a domain that's already in - * ASCII. - * @memberOf punycode - * @param {String} input The domain name or email address to convert, as a - * Unicode string. - * @returns {String} The Punycode representation of the given domain name or - * email address. - */ - function toASCII(input) { - return mapDomain(input, function(string) { - return regexNonASCII.test(string) - ? 'xn--' + encode(string) - : string; - }); - } + dest.removeListener('close', cleanup); + } - /*--------------------------------------------------------------------------*/ + source.on('end', cleanup); + source.on('close', cleanup); - /** Define the public API */ - punycode = { - /** - * A string representing the current Punycode.js version number. - * @memberOf punycode - * @type String - */ - 'version': '1.4.1', - /** - * An object of methods to convert from JavaScript's internal character - * representation (UCS-2) to Unicode code points, and back. - * @see - * @memberOf punycode - * @type Object - */ - 'ucs2': { - 'decode': ucs2decode, - 'encode': ucs2encode - }, - 'decode': decode, - 'encode': encode, - 'toASCII': toASCII, - 'toUnicode': toUnicode - }; + dest.on('close', cleanup); - /** Expose `punycode` */ - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define('punycode', function() { - return punycode; - }); - } else if (freeExports && freeModule) { - if (module.exports == freeExports) { - // in Node.js, io.js, or RingoJS v0.8.0+ - freeModule.exports = punycode; - } else { - // in Narwhal or RingoJS v0.7.0- - for (key in punycode) { - punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]); - } - } - } else { - // in Rhino or a web browser - root.punycode = punycode; - } + dest.emit('pipe', source); -}(this)); + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],220:[function(require,module,exports){ +},{"events":220,"inherits":258,"readable-stream/duplex.js":222,"readable-stream/passthrough.js":233,"readable-stream/readable.js":234,"readable-stream/transform.js":235,"readable-stream/writable.js":236}],239:[function(require,module,exports){ 'use strict'; var Buffer = require('safe-buffer').Buffer; @@ -42428,150 +49085,16 @@ function simpleWrite(buf) { function simpleEnd(buf) { return buf && buf.length ? this.write(buf) : ''; } -},{"safe-buffer":298}],221:[function(require,module,exports){ -var indexOf = require('indexof'); - -var Object_keys = function (obj) { - if (Object.keys) return Object.keys(obj) - else { - var res = []; - for (var key in obj) res.push(key) - return res; - } -}; - -var forEach = function (xs, fn) { - if (xs.forEach) return xs.forEach(fn) - else for (var i = 0; i < xs.length; i++) { - fn(xs[i], i, xs); - } -}; - -var defineProp = (function() { - try { - Object.defineProperty({}, '_', {}); - return function(obj, name, value) { - Object.defineProperty(obj, name, { - writable: true, - enumerable: false, - configurable: true, - value: value - }) - }; - } catch(e) { - return function(obj, name, value) { - obj[name] = value; - }; - } -}()); - -var globals = ['Array', 'Boolean', 'Date', 'Error', 'EvalError', 'Function', -'Infinity', 'JSON', 'Math', 'NaN', 'Number', 'Object', 'RangeError', -'ReferenceError', 'RegExp', 'String', 'SyntaxError', 'TypeError', 'URIError', -'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'escape', -'eval', 'isFinite', 'isNaN', 'parseFloat', 'parseInt', 'undefined', 'unescape']; - -function Context() {} -Context.prototype = {}; - -var Script = exports.Script = function NodeScript (code) { - if (!(this instanceof Script)) return new Script(code); - this.code = code; -}; - -Script.prototype.runInContext = function (context) { - if (!(context instanceof Context)) { - throw new TypeError("needs a 'context' argument."); - } - - var iframe = document.createElement('iframe'); - if (!iframe.style) iframe.style = {}; - iframe.style.display = 'none'; - - document.body.appendChild(iframe); - - var win = iframe.contentWindow; - var wEval = win.eval, wExecScript = win.execScript; - - if (!wEval && wExecScript) { - // win.eval() magically appears when this is called in IE: - wExecScript.call(win, 'null'); - wEval = win.eval; - } - - forEach(Object_keys(context), function (key) { - win[key] = context[key]; - }); - forEach(globals, function (key) { - if (context[key]) { - win[key] = context[key]; - } - }); - - var winKeys = Object_keys(win); - - var res = wEval.call(win, this.code); - - forEach(Object_keys(win), function (key) { - // Avoid copying circular objects like `top` and `window` by only - // updating existing context properties or new properties in the `win` - // that was only introduced after the eval. - if (key in context || indexOf(winKeys, key) === -1) { - context[key] = win[key]; - } - }); - - forEach(globals, function (key) { - if (!(key in context)) { - defineProp(context, key, win[key]); - } - }); - - document.body.removeChild(iframe); - - return res; -}; - -Script.prototype.runInThisContext = function () { - return eval(this.code); // maybe... -}; - -Script.prototype.runInNewContext = function (context) { - var ctx = Script.createContext(context); - var res = this.runInContext(ctx); - - forEach(Object_keys(ctx), function (key) { - context[key] = ctx[key]; - }); - - return res; -}; - -forEach(Object_keys(Script.prototype), function (name) { - exports[name] = Script[name] = function (code) { - var s = Script(code); - return s[name].apply(s, [].slice.call(arguments, 1)); - }; -}); - -exports.createScript = function (code) { - return exports.Script(code); -}; - -exports.createContext = Script.createContext = function (context) { - var copy = new Context(); - if(typeof context === 'object') { - forEach(Object_keys(context), function (key) { - copy[key] = context[key]; - }); - } - return copy; -}; - -},{"indexof":237}],222:[function(require,module,exports){ +},{"safe-buffer":237}],240:[function(require,module,exports){ +arguments[4][24][0].apply(exports,arguments) +},{"dup":24}],241:[function(require,module,exports){ +arguments[4][25][0].apply(exports,arguments) +},{"dup":25}],242:[function(require,module,exports){ +arguments[4][26][0].apply(exports,arguments) +},{"./support/isBuffer":241,"_process":270,"dup":26,"inherits":240}],243:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer -var Transform = require('stream').Transform +var Transform = require('readable-stream').Transform var inherits = require('inherits') function throwIfNotStringOrBuffer (val, prefix) { @@ -42665,7 +49188,7 @@ HashBase.prototype._digest = function () { module.exports = HashBase -},{"inherits":238,"safe-buffer":298,"stream":314}],223:[function(require,module,exports){ +},{"inherits":258,"readable-stream":319,"safe-buffer":321}],244:[function(require,module,exports){ var hash = exports; hash.utils = require('./hash/utils'); @@ -42682,7 +49205,7 @@ hash.sha384 = hash.sha.sha384; hash.sha512 = hash.sha.sha512; hash.ripemd160 = hash.ripemd.ripemd160; -},{"./hash/common":224,"./hash/hmac":225,"./hash/ripemd":226,"./hash/sha":227,"./hash/utils":234}],224:[function(require,module,exports){ +},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -42776,7 +49299,7 @@ BlockHash.prototype._pad = function pad() { return res; }; -},{"./utils":234,"minimalistic-assert":245}],225:[function(require,module,exports){ +},{"./utils":255,"minimalistic-assert":265}],246:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -42825,7 +49348,7 @@ Hmac.prototype.digest = function digest(enc) { return this.outer.digest(enc); }; -},{"./utils":234,"minimalistic-assert":245}],226:[function(require,module,exports){ +},{"./utils":255,"minimalistic-assert":265}],247:[function(require,module,exports){ 'use strict'; var utils = require('./utils'); @@ -42973,7 +49496,7 @@ var sh = [ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]; -},{"./common":224,"./utils":234}],227:[function(require,module,exports){ +},{"./common":245,"./utils":255}],248:[function(require,module,exports){ 'use strict'; exports.sha1 = require('./sha/1'); @@ -42982,7 +49505,7 @@ exports.sha256 = require('./sha/256'); exports.sha384 = require('./sha/384'); exports.sha512 = require('./sha/512'); -},{"./sha/1":228,"./sha/224":229,"./sha/256":230,"./sha/384":231,"./sha/512":232}],228:[function(require,module,exports){ +},{"./sha/1":249,"./sha/224":250,"./sha/256":251,"./sha/384":252,"./sha/512":253}],249:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43058,7 +49581,7 @@ SHA1.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":224,"../utils":234,"./common":233}],229:[function(require,module,exports){ +},{"../common":245,"../utils":255,"./common":254}],250:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43090,7 +49613,7 @@ SHA224.prototype._digest = function digest(enc) { }; -},{"../utils":234,"./256":230}],230:[function(require,module,exports){ +},{"../utils":255,"./256":251}],251:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43197,7 +49720,7 @@ SHA256.prototype._digest = function digest(enc) { return utils.split32(this.h, 'big'); }; -},{"../common":224,"../utils":234,"./common":233,"minimalistic-assert":245}],231:[function(require,module,exports){ +},{"../common":245,"../utils":255,"./common":254,"minimalistic-assert":265}],252:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43234,7 +49757,7 @@ SHA384.prototype._digest = function digest(enc) { return utils.split32(this.h.slice(0, 12), 'big'); }; -},{"../utils":234,"./512":232}],232:[function(require,module,exports){ +},{"../utils":255,"./512":253}],253:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43566,7 +50089,7 @@ function g1_512_lo(xh, xl) { return r; } -},{"../common":224,"../utils":234,"minimalistic-assert":245}],233:[function(require,module,exports){ +},{"../common":245,"../utils":255,"minimalistic-assert":265}],254:[function(require,module,exports){ 'use strict'; var utils = require('../utils'); @@ -43617,7 +50140,7 @@ function g1_256(x) { } exports.g1_256 = g1_256; -},{"../utils":234}],234:[function(require,module,exports){ +},{"../utils":255}],255:[function(require,module,exports){ 'use strict'; var assert = require('minimalistic-assert'); @@ -43897,7 +50420,7 @@ function shr64_lo(ah, al, num) { } exports.shr64_lo = shr64_lo; -},{"inherits":238,"minimalistic-assert":245}],235:[function(require,module,exports){ +},{"inherits":258,"minimalistic-assert":265}],256:[function(require,module,exports){ 'use strict'; var hash = require('hash.js'); @@ -44012,7 +50535,8 @@ HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { return utils.encode(res, enc); }; -},{"hash.js":223,"minimalistic-assert":245,"minimalistic-crypto-utils":246}],236:[function(require,module,exports){ +},{"hash.js":244,"minimalistic-assert":265,"minimalistic-crypto-utils":266}],257:[function(require,module,exports){ +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = (nBytes * 8) - mLen - 1 @@ -44098,20 +50622,36 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],237:[function(require,module,exports){ - -var indexOf = [].indexOf; - -module.exports = function(arr, obj){ - if (indexOf) return arr.indexOf(obj); - for (var i = 0; i < arr.length; ++i) { - if (arr[i] === obj) return i; +},{}],258:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } - return -1; -}; -},{}],238:[function(require,module,exports){ -arguments[4][24][0].apply(exports,arguments) -},{"dup":24}],239:[function(require,module,exports){ +} + +},{}],259:[function(require,module,exports){ /*! * Determine if an object is a Buffer * @@ -44134,19 +50674,19 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) } -},{}],240:[function(require,module,exports){ +},{}],260:[function(require,module,exports){ var toString = {}.toString; module.exports = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; -},{}],241:[function(require,module,exports){ -(function (global){ +},{}],261:[function(require,module,exports){ +(function (global){(function (){ /** * @license * Lodash - * Copyright JS Foundation and other contributors + * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -44157,14 +50697,15 @@ module.exports = Array.isArray || function (arr) { var undefined; /** Used as the semantic version number. */ - var VERSION = '4.17.11'; + var VERSION = '4.17.21'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; /** Error message constants. */ var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', - FUNC_ERROR_TEXT = 'Expected a function'; + FUNC_ERROR_TEXT = 'Expected a function', + INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; /** Used to stand-in for `undefined` hash values. */ var HASH_UNDEFINED = '__lodash_hash_undefined__'; @@ -44297,10 +50838,11 @@ module.exports = Array.isArray || function (arr) { var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g, - reTrimStart = /^\s+/, - reTrimEnd = /\s+$/; + /** Used to match leading whitespace. */ + var reTrimStart = /^\s+/; + + /** Used to match a single whitespace character. */ + var reWhitespace = /\s/; /** Used to match wrap detail comments. */ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, @@ -44310,6 +50852,18 @@ module.exports = Array.isArray || function (arr) { /** Used to match words composed of alphanumeric characters. */ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + /** + * Used to validate the `validate` option in `_.template` variable. + * + * Forbids characters which could potentially change the meaning of the function argument definition: + * - "()," (modification of function parameters) + * - "=" (default value) + * - "[]{}" (destructuring of function parameters) + * - "/" (beginning of a comment) + * - whitespace + */ + var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; + /** Used to match backslashes in property paths. */ var reEscapeChar = /\\(\\)?/g; @@ -45138,6 +51692,19 @@ module.exports = Array.isArray || function (arr) { }); } + /** + * The base implementation of `_.trim`. + * + * @private + * @param {string} string The string to trim. + * @returns {string} Returns the trimmed string. + */ + function baseTrim(string) { + return string + ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') + : string; + } + /** * The base implementation of `_.unary` without support for storing metadata. * @@ -45471,6 +52038,21 @@ module.exports = Array.isArray || function (arr) { : asciiToArray(string); } + /** + * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace + * character of `string`. + * + * @private + * @param {string} string The string to inspect. + * @returns {number} Returns the index of the last non-whitespace character. + */ + function trimmedEndIndex(string) { + var index = string.length; + + while (index-- && reWhitespace.test(string.charAt(index))) {} + return index; + } + /** * Used by `_.unescape` to convert HTML entities to characters. * @@ -46816,16 +53398,10 @@ module.exports = Array.isArray || function (arr) { value.forEach(function(subValue) { result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); }); - - return result; - } - - if (isMap(value)) { + } else if (isMap(value)) { value.forEach(function(subValue, key) { result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); }); - - return result; } var keysFunc = isFull @@ -47749,8 +54325,8 @@ module.exports = Array.isArray || function (arr) { return; } baseFor(source, function(srcValue, key) { + stack || (stack = new Stack); if (isObject(srcValue)) { - stack || (stack = new Stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { @@ -47870,8 +54446,21 @@ module.exports = Array.isArray || function (arr) { * @returns {Array} Returns the new sorted array. */ function baseOrderBy(collection, iteratees, orders) { + if (iteratees.length) { + iteratees = arrayMap(iteratees, function(iteratee) { + if (isArray(iteratee)) { + return function(value) { + return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); + } + } + return iteratee; + }); + } else { + iteratees = [identity]; + } + var index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); + iteratees = arrayMap(iteratees, baseUnary(getIteratee())); var result = baseMap(collection, function(value, key, collection) { var criteria = arrayMap(iteratees, function(iteratee) { @@ -48128,6 +54717,10 @@ module.exports = Array.isArray || function (arr) { var key = toKey(path[index]), newValue = value; + if (key === '__proto__' || key === 'constructor' || key === 'prototype') { + return object; + } + if (index != lastIndex) { var objValue = nested[key]; newValue = customizer ? customizer(objValue, key, nested) : undefined; @@ -48280,11 +54873,14 @@ module.exports = Array.isArray || function (arr) { * into `array`. */ function baseSortedIndexBy(array, value, iteratee, retHighest) { - value = iteratee(value); - var low = 0, - high = array == null ? 0 : array.length, - valIsNaN = value !== value, + high = array == null ? 0 : array.length; + if (high === 0) { + return 0; + } + + value = iteratee(value); + var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol(value), valIsUndefined = value === undefined; @@ -49567,7 +56163,7 @@ module.exports = Array.isArray || function (arr) { return function(number, precision) { number = toNumber(number); precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); - if (precision) { + if (precision && nativeIsFinite(number)) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details. var pair = (toString(number) + 'e').split('e'), @@ -49769,10 +56365,11 @@ module.exports = Array.isArray || function (arr) { if (arrLength != othLength && !(isPartial && othLength > arrLength)) { return false; } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var arrStacked = stack.get(array); + var othStacked = stack.get(other); + if (arrStacked && othStacked) { + return arrStacked == other && othStacked == array; } var index = -1, result = true, @@ -49934,10 +56531,11 @@ module.exports = Array.isArray || function (arr) { return false; } } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; + // Check that cyclic values are equal. + var objStacked = stack.get(object); + var othStacked = stack.get(other); + if (objStacked && othStacked) { + return objStacked == other && othStacked == object; } var result = true; stack.set(object, other); @@ -50750,7 +57348,7 @@ module.exports = Array.isArray || function (arr) { } /** - * Gets the value at `key`, unless `key` is "__proto__". + * Gets the value at `key`, unless `key` is "__proto__" or "constructor". * * @private * @param {Object} object The object to query. @@ -50758,6 +57356,10 @@ module.exports = Array.isArray || function (arr) { * @returns {*} Returns the property value. */ function safeGet(object, key) { + if (key === 'constructor' && typeof object[key] === 'function') { + return; + } + if (key == '__proto__') { return; } @@ -53314,6 +59916,10 @@ module.exports = Array.isArray || function (arr) { * // The `_.property` iteratee shorthand. * _.filter(users, 'active'); * // => objects for ['barney'] + * + * // Combining several predicates using `_.overEvery` or `_.overSome`. + * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); + * // => objects for ['fred', 'barney'] */ function filter(collection, predicate) { var func = isArray(collection) ? arrayFilter : baseFilter; @@ -54063,15 +60669,15 @@ module.exports = Array.isArray || function (arr) { * var users = [ * { 'user': 'fred', 'age': 48 }, * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 }, + * { 'user': 'fred', 'age': 30 }, * { 'user': 'barney', 'age': 34 } * ]; * * _.sortBy(users, [function(o) { return o.user; }]); - * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] + * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] * * _.sortBy(users, ['user', 'age']); - * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] + * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] */ var sortBy = baseRest(function(collection, iteratees) { if (collection == null) { @@ -54558,6 +61164,7 @@ module.exports = Array.isArray || function (arr) { } if (maxing) { // Handle invocations in a tight loop. + clearTimeout(timerId); timerId = setTimeout(timerExpired, wait); return invokeFunc(lastCallTime); } @@ -56614,7 +63221,7 @@ module.exports = Array.isArray || function (arr) { if (typeof value != 'string') { return value === 0 ? value : +value; } - value = value.replace(reTrim, ''); + value = baseTrim(value); var isBinary = reIsBinary.test(value); return (isBinary || reIsOctal.test(value)) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) @@ -58944,9 +65551,12 @@ module.exports = Array.isArray || function (arr) { , 'g'); // Use a sourceURL for easier debugging. + // The sourceURL gets injected into the source that's eval-ed, so be careful + // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in + // and escape the comment, thus injecting code that gets evaled. var sourceURL = '//# sourceURL=' + - ('sourceURL' in options - ? options.sourceURL + (hasOwnProperty.call(options, 'sourceURL') + ? (options.sourceURL + '').replace(/\s/g, ' ') : ('lodash.templateSources[' + (++templateCounter) + ']') ) + '\n'; @@ -58979,10 +65589,16 @@ module.exports = Array.isArray || function (arr) { // If `variable` is not specified wrap a with-statement around the generated // code to add the data object to the top of the scope chain. - var variable = options.variable; + var variable = hasOwnProperty.call(options, 'variable') && options.variable; if (!variable) { source = 'with (obj) {\n' + source + '\n}\n'; } + // Throw an error if a forbidden character was found in `variable`, to prevent + // potential command injection attacks. + else if (reForbiddenIdentifierChars.test(variable)) { + throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); + } + // Cleanup code by stripping empty strings. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) .replace(reEmptyStringMiddle, '$1') @@ -59096,7 +65712,7 @@ module.exports = Array.isArray || function (arr) { function trim(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); + return baseTrim(string); } if (!string || !(chars = baseToString(chars))) { return string; @@ -59131,7 +65747,7 @@ module.exports = Array.isArray || function (arr) { function trimEnd(string, chars, guard) { string = toString(string); if (string && (guard || chars === undefined)) { - return string.replace(reTrimEnd, ''); + return string.slice(0, trimmedEndIndex(string) + 1); } if (!string || !(chars = baseToString(chars))) { return string; @@ -59685,6 +66301,9 @@ module.exports = Array.isArray || function (arr) { * values against any array or object value, respectively. See `_.isEqual` * for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.0.0 @@ -59700,6 +66319,10 @@ module.exports = Array.isArray || function (arr) { * * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); * // => [{ 'a': 4, 'b': 5, 'c': 6 }] + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matches(source) { return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); @@ -59714,6 +66337,9 @@ module.exports = Array.isArray || function (arr) { * `srcValue` values against any array or object value, respectively. See * `_.isEqual` for a list of supported value comparisons. * + * **Note:** Multiple values can be checked by combining several matchers + * using `_.overSome` + * * @static * @memberOf _ * @since 3.2.0 @@ -59730,6 +66356,10 @@ module.exports = Array.isArray || function (arr) { * * _.find(objects, _.matchesProperty('a', 4)); * // => { 'a': 4, 'b': 5, 'c': 6 } + * + * // Checking for several possible values + * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); + * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] */ function matchesProperty(path, srcValue) { return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); @@ -59953,6 +66583,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **all** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -59979,6 +66613,10 @@ module.exports = Array.isArray || function (arr) { * Creates a function that checks if **any** of the `predicates` return * truthy when invoked with the arguments it receives. * + * Following shorthands are possible for providing predicates. + * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. + * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. + * * @static * @memberOf _ * @since 4.0.0 @@ -59998,6 +66636,9 @@ module.exports = Array.isArray || function (arr) { * * func(NaN); * // => false + * + * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) + * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) */ var overSome = createOver(arraySome); @@ -61184,10 +67825,11 @@ module.exports = Array.isArray || function (arr) { baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName]; if (lodashFunc) { - var key = (lodashFunc.name + ''), - names = realNames[key] || (realNames[key] = []); - - names.push({ 'name': methodName, 'func': lodashFunc }); + var key = lodashFunc.name + ''; + if (!hasOwnProperty.call(realNames, key)) { + realNames[key] = []; + } + realNames[key].push({ 'name': methodName, 'func': lodashFunc }); } }); @@ -61251,8 +67893,8 @@ module.exports = Array.isArray || function (arr) { } }.call(this)); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],242:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],262:[function(require,module,exports){ 'use strict' var inherits = require('inherits') var HashBase = require('hash-base') @@ -61400,8 +68042,8 @@ function fnI (a, b, c, d, m, k, s) { module.exports = MD5 -},{"hash-base":222,"inherits":238,"safe-buffer":298}],243:[function(require,module,exports){ -(function (Buffer){ +},{"hash-base":243,"inherits":258,"safe-buffer":321}],263:[function(require,module,exports){ +(function (Buffer){(function (){ // constant-space merkle root calculation algorithm module.exports = function fastRoot (values, digestFn) { if (!Array.isArray(values)) throw TypeError('Expected values Array') @@ -61427,8 +68069,8 @@ module.exports = function fastRoot (values, digestFn) { return results[0] } -}).call(this,require("buffer").Buffer) -},{"buffer":111}],244:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":110}],264:[function(require,module,exports){ var bn = require('bn.js'); var brorand = require('brorand'); @@ -61545,7 +68187,7 @@ MillerRabin.prototype.getDivisor = function getDivisor(n, k) { return false; }; -},{"bn.js":82,"brorand":83}],245:[function(require,module,exports){ +},{"bn.js":82,"brorand":83}],265:[function(require,module,exports){ module.exports = assert; function assert(val, msg) { @@ -61558,7 +68200,7 @@ assert.equal = function assertEqual(l, r, msg) { throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); }; -},{}],246:[function(require,module,exports){ +},{}],266:[function(require,module,exports){ 'use strict'; var utils = exports; @@ -61618,7 +68260,7 @@ utils.encode = function encode(arr, enc) { return arr; }; -},{}],247:[function(require,module,exports){ +},{}],267:[function(require,module,exports){ /** * Helpers. */ @@ -61772,8 +68414,100 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } -},{}],248:[function(require,module,exports){ -(function (Buffer){ +},{}],268:[function(require,module,exports){ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + +},{}],269:[function(require,module,exports){ +(function (Buffer){(function (){ var createHmac = require('create-hmac') var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs @@ -61855,56 +68589,8 @@ function pbkdf2Sync (password, salt, iterations, keylen, digest) { return DK } -}).call(this,require("buffer").Buffer) -},{"buffer":111,"create-hmac":121}],249:[function(require,module,exports){ -(function (process){ -'use strict'; - -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - -}).call(this,require('_process')) -},{"_process":250}],250:[function(require,module,exports){ +}).call(this)}).call(this,require("buffer").Buffer) +},{"buffer":110,"create-hmac":120}],270:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -62090,7 +68776,7 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],251:[function(require,module,exports){ +},{}],271:[function(require,module,exports){ exports.publicEncrypt = require('./publicEncrypt') exports.privateDecrypt = require('./privateDecrypt') @@ -62102,7 +68788,7 @@ exports.publicDecrypt = function publicDecrypt (key, buf) { return exports.privateDecrypt(key, buf, true) } -},{"./privateDecrypt":273,"./publicEncrypt":274}],252:[function(require,module,exports){ +},{"./privateDecrypt":294,"./publicEncrypt":295}],272:[function(require,module,exports){ var createHash = require('create-hash') var Buffer = require('safe-buffer').Buffer @@ -62123,47 +68809,49 @@ function i2ops (c) { return out } -},{"create-hash":119,"safe-buffer":298}],253:[function(require,module,exports){ +},{"create-hash":118,"safe-buffer":321}],273:[function(require,module,exports){ +arguments[4][123][0].apply(exports,arguments) +},{"./asn1/api":274,"./asn1/base":276,"./asn1/constants":280,"./asn1/decoders":282,"./asn1/encoders":285,"bn.js":82,"dup":123}],274:[function(require,module,exports){ arguments[4][124][0].apply(exports,arguments) -},{"./asn1/api":254,"./asn1/base":256,"./asn1/constants":260,"./asn1/decoders":262,"./asn1/encoders":265,"bn.js":82,"dup":124}],254:[function(require,module,exports){ +},{"./decoders":282,"./encoders":285,"dup":124,"inherits":258}],275:[function(require,module,exports){ arguments[4][125][0].apply(exports,arguments) -},{"../asn1":253,"dup":125,"inherits":238,"vm":221}],255:[function(require,module,exports){ +},{"../base/reporter":278,"dup":125,"inherits":258,"safer-buffer":322}],276:[function(require,module,exports){ arguments[4][126][0].apply(exports,arguments) -},{"../base":256,"buffer":111,"dup":126,"inherits":238}],256:[function(require,module,exports){ +},{"./buffer":275,"./node":277,"./reporter":278,"dup":126}],277:[function(require,module,exports){ arguments[4][127][0].apply(exports,arguments) -},{"./buffer":255,"./node":257,"./reporter":258,"dup":127}],257:[function(require,module,exports){ +},{"../base/buffer":275,"../base/reporter":278,"dup":127,"minimalistic-assert":265}],278:[function(require,module,exports){ arguments[4][128][0].apply(exports,arguments) -},{"../base":256,"dup":128,"minimalistic-assert":245}],258:[function(require,module,exports){ +},{"dup":128,"inherits":258}],279:[function(require,module,exports){ arguments[4][129][0].apply(exports,arguments) -},{"dup":129,"inherits":238}],259:[function(require,module,exports){ +},{"dup":129}],280:[function(require,module,exports){ arguments[4][130][0].apply(exports,arguments) -},{"../constants":260,"dup":130}],260:[function(require,module,exports){ +},{"./der":279,"dup":130}],281:[function(require,module,exports){ arguments[4][131][0].apply(exports,arguments) -},{"./der":259,"dup":131}],261:[function(require,module,exports){ +},{"../base/buffer":275,"../base/node":277,"../constants/der":279,"bn.js":82,"dup":131,"inherits":258}],282:[function(require,module,exports){ arguments[4][132][0].apply(exports,arguments) -},{"../../asn1":253,"dup":132,"inherits":238}],262:[function(require,module,exports){ +},{"./der":281,"./pem":283,"dup":132}],283:[function(require,module,exports){ arguments[4][133][0].apply(exports,arguments) -},{"./der":261,"./pem":263,"dup":133}],263:[function(require,module,exports){ +},{"./der":281,"dup":133,"inherits":258,"safer-buffer":322}],284:[function(require,module,exports){ arguments[4][134][0].apply(exports,arguments) -},{"./der":261,"buffer":111,"dup":134,"inherits":238}],264:[function(require,module,exports){ +},{"../base/node":277,"../constants/der":279,"dup":134,"inherits":258,"safer-buffer":322}],285:[function(require,module,exports){ arguments[4][135][0].apply(exports,arguments) -},{"../../asn1":253,"buffer":111,"dup":135,"inherits":238}],265:[function(require,module,exports){ +},{"./der":284,"./pem":286,"dup":135}],286:[function(require,module,exports){ arguments[4][136][0].apply(exports,arguments) -},{"./der":264,"./pem":266,"dup":136}],266:[function(require,module,exports){ -arguments[4][137][0].apply(exports,arguments) -},{"./der":264,"dup":137,"inherits":238}],267:[function(require,module,exports){ +},{"./der":284,"dup":136,"inherits":258}],287:[function(require,module,exports){ +arguments[4][139][0].apply(exports,arguments) +},{"bn.js":288,"buffer":110,"dup":139,"randombytes":303}],288:[function(require,module,exports){ arguments[4][138][0].apply(exports,arguments) -},{"bn.js":82,"buffer":111,"dup":138,"randombytes":282}],268:[function(require,module,exports){ -arguments[4][145][0].apply(exports,arguments) -},{"dup":145}],269:[function(require,module,exports){ +},{"buffer":219,"dup":138}],289:[function(require,module,exports){ arguments[4][146][0].apply(exports,arguments) -},{"./certificate":270,"asn1.js":253,"dup":146}],270:[function(require,module,exports){ +},{"dup":146}],290:[function(require,module,exports){ arguments[4][147][0].apply(exports,arguments) -},{"asn1.js":253,"dup":147}],271:[function(require,module,exports){ +},{"./certificate":291,"asn1.js":273,"dup":147}],291:[function(require,module,exports){ arguments[4][148][0].apply(exports,arguments) -},{"browserify-aes":87,"buffer":111,"dup":148,"evp_bytestokey":217}],272:[function(require,module,exports){ +},{"asn1.js":273,"dup":148}],292:[function(require,module,exports){ arguments[4][149][0].apply(exports,arguments) -},{"./aesid.json":268,"./asn1":269,"./fixProc":271,"browserify-aes":87,"buffer":111,"dup":149,"pbkdf2":248}],273:[function(require,module,exports){ +},{"browserify-aes":86,"dup":149,"evp_bytestokey":218,"safe-buffer":321}],293:[function(require,module,exports){ +arguments[4][150][0].apply(exports,arguments) +},{"./aesid.json":289,"./asn1":290,"./fixProc":292,"browserify-aes":86,"dup":150,"pbkdf2":269,"safe-buffer":321}],294:[function(require,module,exports){ var parseKeys = require('parse-asn1') var mgf = require('./mgf') var xor = require('./xor') @@ -62270,7 +68958,7 @@ function compare (a, b) { return dif } -},{"./mgf":252,"./withPublic":275,"./xor":276,"bn.js":82,"browserify-rsa":267,"create-hash":119,"parse-asn1":272,"safe-buffer":298}],274:[function(require,module,exports){ +},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,"safe-buffer":321}],295:[function(require,module,exports){ var parseKeys = require('parse-asn1') var randomBytes = require('randombytes') var createHash = require('create-hash') @@ -62360,7 +69048,7 @@ function nonZero (len) { return out } -},{"./mgf":252,"./withPublic":275,"./xor":276,"bn.js":82,"browserify-rsa":267,"create-hash":119,"parse-asn1":272,"randombytes":282,"safe-buffer":298}],275:[function(require,module,exports){ +},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,"randombytes":303,"safe-buffer":321}],296:[function(require,module,exports){ var BN = require('bn.js') var Buffer = require('safe-buffer').Buffer @@ -62374,7 +69062,7 @@ function withPublic (paddedMsg, key) { module.exports = withPublic -},{"bn.js":82,"safe-buffer":298}],276:[function(require,module,exports){ +},{"bn.js":82,"safe-buffer":321}],297:[function(require,module,exports){ module.exports = function xor (a, b) { var len = a.length var i = -1 @@ -62384,7 +69072,7 @@ module.exports = function xor (a, b) { return a } -},{}],277:[function(require,module,exports){ +},{}],298:[function(require,module,exports){ var OPS = require('bitcoin-ops') function encodingLength (i) { @@ -62463,8 +69151,8 @@ module.exports = { decode: decode } -},{"bitcoin-ops":39}],278:[function(require,module,exports){ -(function (process,setImmediate){ +},{"bitcoin-ops":39}],299:[function(require,module,exports){ +(function (process,setImmediate){(function (){ // vim:ts=4:sts=4:sw=4: /*! * @@ -64370,8 +71058,8 @@ return Q; }); -}).call(this,require('_process'),require("timers").setImmediate) -},{"_process":250,"timers":325}],279:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),require("timers").setImmediate) +},{"_process":270,"timers":348}],300:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -64457,7 +71145,7 @@ var isArray = Array.isArray || function (xs) { return Object.prototype.toString.call(xs) === '[object Array]'; }; -},{}],280:[function(require,module,exports){ +},{}],301:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -64544,16 +71232,24 @@ var objectKeys = Object.keys || function (obj) { return res; }; -},{}],281:[function(require,module,exports){ +},{}],302:[function(require,module,exports){ 'use strict'; exports.decode = exports.parse = require('./decode'); exports.encode = exports.stringify = require('./encode'); -},{"./decode":279,"./encode":280}],282:[function(require,module,exports){ -(function (process,global){ +},{"./decode":300,"./encode":301}],303:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' +// limit of Crypto.getRandomValues() +// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues +var MAX_BYTES = 65536 + +// Node supports requesting up to this number of bytes +// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48 +var MAX_UINT32 = 4294967295 + function oldBrowser () { throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11') } @@ -64569,19 +71265,23 @@ if (crypto && crypto.getRandomValues) { function randomBytes (size, cb) { // phantomjs needs to throw - if (size > 65536) throw new Error('requested too many random bytes') - // in case browserify isn't using the Uint8Array version - var rawBytes = new global.Uint8Array(size) + if (size > MAX_UINT32) throw new RangeError('requested too many random bytes') + + var bytes = Buffer.allocUnsafe(size) - // This will not work in older browsers. - // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues if (size > 0) { // getRandomValues fails on IE if size == 0 - crypto.getRandomValues(rawBytes) + if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues + // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues + for (var generated = 0; generated < size; generated += MAX_BYTES) { + // buffer.slice automatically checks if the end is past the end of + // the buffer so we don't have to here + crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES)) + } + } else { + crypto.getRandomValues(bytes) + } } - // XXX: phantomjs doesn't like a buffer being passed here - var bytes = Buffer.from(rawBytes.buffer) - if (typeof cb === 'function') { return process.nextTick(function () { cb(null, bytes) @@ -64591,9 +71291,9 @@ function randomBytes (size, cb) { return bytes } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":250,"safe-buffer":298}],283:[function(require,module,exports){ -(function (process,global){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":270,"safe-buffer":321}],304:[function(require,module,exports){ +(function (process,global){(function (){ 'use strict' function oldBrowser () { @@ -64703,11 +71403,138 @@ function randomFillSync (buf, offset, size) { return actualFill(buf, offset, size) } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":250,"randombytes":282,"safe-buffer":298}],284:[function(require,module,exports){ -module.exports = require('./lib/_stream_duplex.js'); +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":270,"randombytes":303,"safe-buffer":321}],305:[function(require,module,exports){ +'use strict'; + +function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + +var codes = {}; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inheritsLoose(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + return _Base.call(this, getMessage(arg1, arg2, arg3)) || this; + } + + return NodeError; + }(Base); + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"'; +}, TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } -},{"./lib/_stream_duplex.js":285}],285:[function(require,module,exports){ + msg += ". Received type ".concat(typeof actual); + return msg; +}, TypeError); +createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); +createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented'; +}); +createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); +createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; +}); +createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); +createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); +createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); +createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg; +}, TypeError); +createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); +module.exports.codes = codes; + +},{}],306:[function(require,module,exports){ +(function (process){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -64728,43 +71555,37 @@ module.exports = require('./lib/_stream_duplex.js'); // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a duplex stream is just a stream that is both readable and writable. // Since JS doesn't have multiple prototypal inheritance, this class // prototypally inherits from Readable, and then parasitically from // Writable. - 'use strict'; - /**/ -var pna = require('process-nextick-args'); -/**/ - -/**/ var objectKeys = Object.keys || function (obj) { var keys = []; + for (var key in obj) { keys.push(key); - }return keys; + } + + return keys; }; /**/ -module.exports = Duplex; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +module.exports = Duplex; var Readable = require('./_stream_readable'); + var Writable = require('./_stream_writable'); -util.inherits(Duplex, Readable); +require('inherits')(Duplex, Readable); { - // avoid scope creep, the keys array can then be collected + // Allow the keys array to be GC'ed. var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { var method = keys[v]; if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; @@ -64773,18 +71594,19 @@ util.inherits(Duplex, Readable); function Duplex(options) { if (!(this instanceof Duplex)) return new Duplex(options); - Readable.call(this, options); Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; - - if (options && options.writable === false) this.writable = false; - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; - this.once('end', onend); + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } } Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { @@ -64792,20 +71614,35 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } }); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer -// the no-half-open enforcer function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; - - // no more data can be written. + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. // But allow more writes to happen in this tick. - pna.nextTick(onEndNT, this); + + process.nextTick(onEndNT, this); } function onEndNT(self) { @@ -64813,33 +71650,32 @@ function onEndNT(self) { } Object.defineProperty(Duplex.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined || this._writableState === undefined) { return false; } + return this._readableState.destroyed && this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (this._readableState === undefined || this._writableState === undefined) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; this._writableState.destroyed = value; } }); - -Duplex.prototype._destroy = function (err, cb) { - this.push(null); - this.end(); - - pna.nextTick(cb, err); -}; -},{"./_stream_readable":287,"./_stream_writable":289,"core-util-is":117,"inherits":238,"process-nextick-args":249}],286:[function(require,module,exports){ +}).call(this)}).call(this,require('_process')) +},{"./_stream_readable":308,"./_stream_writable":310,"_process":270,"inherits":258}],307:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -64860,35 +71696,27 @@ Duplex.prototype._destroy = function (err, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a passthrough stream. // basically just the most minimal sort of Transform stream. // Every written chunk gets output as-is. - 'use strict'; module.exports = PassThrough; var Transform = require('./_stream_transform'); -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ - -util.inherits(PassThrough, Transform); +require('inherits')(PassThrough, Transform); function PassThrough(options) { if (!(this instanceof PassThrough)) return new PassThrough(options); - Transform.call(this, options); } PassThrough.prototype._transform = function (chunk, encoding, cb) { cb(null, chunk); }; -},{"./_stream_transform":288,"core-util-is":117,"inherits":238}],287:[function(require,module,exports){ -(function (process,global){ +},{"./_stream_transform":309,"inherits":258}],308:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -64909,118 +71737,110 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Readable; - /**/ -var isArray = require('isarray'); -/**/ -/**/ var Duplex; /**/ Readable.ReadableState = ReadableState; - /**/ + var EE = require('events').EventEmitter; -var EElistenerCount = function (emitter, type) { +var EElistenerCount = function EElistenerCount(emitter, type) { return emitter.listeners(type).length; }; /**/ /**/ + + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } - -/**/ - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ + var debugUtil = require('util'); -var debug = void 0; + +var debug; + if (debugUtil && debugUtil.debuglog) { debug = debugUtil.debuglog('stream'); } else { - debug = function () {}; + debug = function debug() {}; } /**/ -var BufferList = require('./internal/streams/BufferList'); + +var BufferList = require('./internal/streams/buffer_list'); + var destroyImpl = require('./internal/streams/destroy'); + +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; + +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance. + + var StringDecoder; +var createReadableStreamAsyncIterator; +var from; -util.inherits(Readable, Stream); +require('inherits')(Readable, Stream); +var errorOrDestroy = destroyImpl.errorOrDestroy; var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; function prependListener(emitter, event, fn) { // Sadly this is not cacheable as some libraries bundle their own // event emitter implementation with them. - if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); - - // This is a hack to make sure that our error handler is attached before any + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); // This is a hack to make sure that our error handler is attached before any // userland ones. NEVER DO THIS. This is here only because this code needs // to continue to work with older versions of Node.js that do not include // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; } -function ReadableState(options, stream) { +function ReadableState(options, stream, isDuplex) { Duplex = Duplex || require('./_stream_duplex'); - - options = options || {}; - - // Duplex streams are both readable and writable, but share + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different // values for the readable and the writable sides of the duplex stream. // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; - // object stream flag. Used to make read(n) ignore n and to + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag. Used to make read(n) ignore n and to // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; - - if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; - // the point at which it stops calling _read() to fill the buffer + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; // the point at which it stops calling _read() to fill the buffer // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var readableHwm = options.readableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); - - // A linked list is used to store data chunks instead of an array because the + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); // A linked list is used to store data chunks instead of an array because the // linked list can remove elements from the beginning faster than // array.shift() + this.buffer = new BufferList(); this.length = 0; this.pipes = null; @@ -65028,37 +71848,36 @@ function ReadableState(options, stream) { this.flowing = null; this.ended = false; this.endEmitted = false; - this.reading = false; - - // a flag to be able to tell if the event 'readable'/'data' is emitted + this.reading = false; // a flag to be able to tell if the event 'readable'/'data' is emitted // immediately, or on a later tick. We set this to true at first, because // any actions that shouldn't happen until "later" should generally also // not happen before the first read call. - this.sync = true; - // whenever we return null, then we set a flag to say + this.sync = true; // whenever we return null, then we set a flag to say // that we're awaiting a 'readable' event emission. + this.needReadable = false; this.emittedReadable = false; this.readableListening = false; this.resumeScheduled = false; + this.paused = true; // Should close be emitted on destroy. Defaults to true. - // has it been destroyed - this.destroyed = false; + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish') - // Crypto is kind of old and crusty. Historically, its default string + this.autoDestroy = !!options.autoDestroy; // has it been destroyed + + this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; + this.defaultEncoding = options.defaultEncoding || 'utf8'; // the number of writers that are awaiting a drain event in .pipe()s - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + this.awaitDrain = 0; // if true, a maybeReadMore has been scheduled + this.readingMore = false; this.decoder = null; this.encoding = null; + if (options.encoding) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; this.decoder = new StringDecoder(options.encoding); @@ -65068,17 +71887,16 @@ function ReadableState(options, stream) { function Readable(options) { Duplex = Duplex || require('./_stream_duplex'); + if (!(this instanceof Readable)) return new Readable(options); // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 - if (!(this instanceof Readable)) return new Readable(options); - - this._readableState = new ReadableState(options, this); + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); // legacy - // legacy this.readable = true; if (options) { if (typeof options.read === 'function') this._read = options.read; - if (typeof options.destroy === 'function') this._destroy = options.destroy; } @@ -65086,36 +71904,40 @@ function Readable(options) { } Object.defineProperty(Readable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._readableState === undefined) { return false; } + return this._readableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._readableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._readableState.destroyed = value; } }); - Readable.prototype.destroy = destroyImpl.destroy; Readable.prototype._undestroy = destroyImpl.undestroy; + Readable.prototype._destroy = function (err, cb) { - this.push(null); cb(err); -}; - -// Manually shove something into the read() buffer. +}; // Manually shove something into the read() buffer. // This returns true if the highWaterMark has not been hit yet, // similar to how Writable.write() returns true if you should // write() some more. + + Readable.prototype.push = function (chunk, encoding) { var state = this._readableState; var skipChunkCheck; @@ -65123,10 +71945,12 @@ Readable.prototype.push = function (chunk, encoding) { if (!state.objectMode) { if (typeof chunk === 'string') { encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { chunk = Buffer.from(chunk, encoding); encoding = ''; } + skipChunkCheck = true; } } else { @@ -65134,34 +71958,40 @@ Readable.prototype.push = function (chunk, encoding) { } return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); -}; +}; // Unshift should *always* be something directly out of read() + -// Unshift should *always* be something directly out of read() Readable.prototype.unshift = function (chunk) { return readableAddChunk(this, chunk, null, true, false); }; function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); var state = stream._readableState; + if (chunk === null) { state.reading = false; onEofChunk(stream, state); } else { var er; if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { - stream.emit('error', er); + errorOrDestroy(stream, er); } else if (state.objectMode || chunk && chunk.length > 0) { if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { chunk = _uint8ArrayToBuffer(chunk); } if (addToFront) { - if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); } else if (state.ended) { - stream.emit('error', new Error('stream.push() after EOF')); + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; } else { state.reading = false; + if (state.decoder && !encoding) { chunk = state.decoder.write(chunk); if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); @@ -65171,61 +72001,73 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { } } else if (!addToFront) { state.reading = false; + maybeReadMore(stream, state); } - } + } // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. - return needMoreData(state); + + return !state.ended && (state.length < state.highWaterMark || state.length === 0); } function addChunk(stream, state, chunk, addToFront) { if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; stream.emit('data', chunk); - stream.read(0); } else { // update the buffer info. state.length += state.objectMode ? 1 : chunk.length; if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); - if (state.needReadable) emitReadable(stream); } + maybeReadMore(stream, state); } function chunkInvalid(state, chunk) { var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); } - return er; -} -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); + return er; } Readable.prototype.isPaused = function () { return this._readableState.flowing === false; -}; +}; // backwards compatibility. + -// backwards compatibility. Readable.prototype.setEncoding = function (enc) { if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8 + + this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers: + + var p = this._readableState.buffer.head; + var content = ''; + + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + + this._readableState.buffer.clear(); + + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; return this; -}; +}; // Don't raise the hwm > 1GB + + +var MAX_HWM = 0x40000000; -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; function computeNewHighWaterMark(n) { if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. n = MAX_HWM; } else { // Get the next highest power of 2 to prevent increasing hwm excessively in @@ -65238,56 +72080,55 @@ function computeNewHighWaterMark(n) { n |= n >>> 16; n++; } - return n; -} -// This function is designed to be inlinable, so please take care when making + return n; +} // This function is designed to be inlinable, so please take care when making // changes to the function body. + + function howMuchToRead(n, state) { if (n <= 0 || state.length === 0 && state.ended) return 0; if (state.objectMode) return 1; + if (n !== n) { // Only flow one buffer at a time if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; - } - // If we're asking for more than the current hwm, then raise the hwm. + } // If we're asking for more than the current hwm, then raise the hwm. + + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); - if (n <= state.length) return n; - // Don't have enough + if (n <= state.length) return n; // Don't have enough + if (!state.ended) { state.needReadable = true; return 0; } + return state.length; -} +} // you can override either this method, or the async _read(n) below. + -// you can override either this method, or the async _read(n) below. Readable.prototype.read = function (n) { debug('read', n); n = parseInt(n, 10); var state = this._readableState; var nOrig = n; - - if (n !== 0) state.emittedReadable = false; - - // if we're doing read(0) to trigger a readable event, but we + if (n !== 0) state.emittedReadable = false; // if we're doing read(0) to trigger a readable event, but we // already have a bunch of data in the buffer, then just trigger // the 'readable' event and move on. - if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { debug('read: emitReadable', state.length, state.ended); if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); return null; } - n = howMuchToRead(n, state); + n = howMuchToRead(n, state); // if we've ended, and we're now clear, then finish it up. - // if we've ended, and we're now clear, then finish it up. if (n === 0 && state.ended) { if (state.length === 0) endReadable(this); return null; - } - - // All the actual chunk generation logic needs to be + } // All the actual chunk generation logic needs to be // *below* the call to _read. The reason is that in certain // synthetic stream cases, such as passthrough streams, _read // may be a completely synchronous operation which may change @@ -65308,33 +72149,34 @@ Readable.prototype.read = function (n) { // 'readable' etc. // // 3. Actually pull the requested chunks out of the buffer and return. - // if we need a readable event, then we need to do some reading. + + var doRead = state.needReadable; - debug('need readable', doRead); + debug('need readable', doRead); // if we currently have less than the highWaterMark, then also read some - // if we currently have less than the highWaterMark, then also read some if (state.length === 0 || state.length - n < state.highWaterMark) { doRead = true; debug('length less than watermark', doRead); - } - - // however, if we've ended, then there's no point, and if we're already + } // however, if we've ended, then there's no point, and if we're already // reading, then it's unnecessary. + + if (state.ended || state.reading) { doRead = false; debug('reading or ended', doRead); } else if (doRead) { debug('do read'); state.reading = true; - state.sync = true; - // if the length is currently zero, then we *need* a readable event. - if (state.length === 0) state.needReadable = true; - // call internal read method + state.sync = true; // if the length is currently zero, then we *need* a readable event. + + if (state.length === 0) state.needReadable = true; // call internal read method + this._read(state.highWaterMark); - state.sync = false; - // If _read pushed data synchronously, then `reading` will be false, + + state.sync = false; // If _read pushed data synchronously, then `reading` will be false, // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); } @@ -65342,91 +72184,144 @@ Readable.prototype.read = function (n) { if (n > 0) ret = fromList(n, state);else ret = null; if (ret === null) { - state.needReadable = true; + state.needReadable = state.length <= state.highWaterMark; n = 0; } else { state.length -= n; + state.awaitDrain = 0; } if (state.length === 0) { // If we have nothing in the buffer, then we want to know // as soon as we *do* get something into the buffer. - if (!state.ended) state.needReadable = true; + if (!state.ended) state.needReadable = true; // If we tried to read() past the EOF, then emit end on the next tick. - // If we tried to read() past the EOF, then emit end on the next tick. if (nOrig !== n && state.ended) endReadable(this); } if (ret !== null) this.emit('data', ret); - return ret; }; function onEofChunk(stream, state) { + debug('onEofChunk'); if (state.ended) return; + if (state.decoder) { var chunk = state.decoder.end(); + if (chunk && chunk.length) { state.buffer.push(chunk); state.length += state.objectMode ? 1 : chunk.length; } } + state.ended = true; - // emit 'readable' now to make sure it gets picked up. - emitReadable(stream); -} + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; -// Don't emit readable right away in sync mode, because this can trigger + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } +} // Don't emit readable right away in sync mode, because this can trigger // another read() call => stack overflow. This way, it might trigger // a nextTick recursion warning, but that's not so bad. + + function emitReadable(stream) { var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); state.needReadable = false; + if (!state.emittedReadable) { debug('emitReadable', state.flowing); state.emittedReadable = true; - if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream); + process.nextTick(emitReadable_, stream); } } function emitReadable_(stream) { - debug('emit readable'); - stream.emit('readable'); - flow(stream); -} + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); -// at this point, the user has presumably seen the 'readable' event, + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + + + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); +} // at this point, the user has presumably seen the 'readable' event, // and called read() to consume some data. that may have triggered // in turn another _read(n) call, in which case reading = true if // it's in progress. // However, if we're not ended, or reading, and the length < hwm, // then go ahead and try to read some more preemptively. + + function maybeReadMore(stream, state) { if (!state.readingMore) { state.readingMore = true; - pna.nextTick(maybeReadMore_, stream, state); + process.nextTick(maybeReadMore_, stream, state); } } function maybeReadMore_(stream, state) { - var len = state.length; - while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; debug('maybeReadMore read 0'); stream.read(0); - if (len === state.length) - // didn't get any data, stop spinning. - break;else len = state.length; + if (len === state.length) // didn't get any data, stop spinning. + break; } - state.readingMore = false; -} -// abstract method. to be overridden in specific implementation classes. + state.readingMore = false; +} // abstract method. to be overridden in specific implementation classes. // call cb(er, data) where data is <= n in length. // for virtual (non-string, non-buffer) streams, "length" is somewhat // arbitrary, and perhaps not very meaningful. + + Readable.prototype._read = function (n) { - this.emit('error', new Error('_read() is not implemented')); + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); }; Readable.prototype.pipe = function (dest, pipeOpts) { @@ -65437,24 +72332,26 @@ Readable.prototype.pipe = function (dest, pipeOpts) { case 0: state.pipes = dest; break; + case 1: state.pipes = [state.pipes, dest]; break; + default: state.pipes.push(dest); break; } + state.pipesCount += 1; debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); - var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; - var endFn = doEnd ? onend : unpipe; - if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn); - + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { debug('onunpipe'); + if (readable === src) { if (unpipeInfo && unpipeInfo.hasUnpiped === false) { unpipeInfo.hasUnpiped = true; @@ -65466,19 +72363,19 @@ Readable.prototype.pipe = function (dest, pipeOpts) { function onend() { debug('onend'); dest.end(); - } - - // when the dest drains, it reduces the awaitDrain counter + } // when the dest drains, it reduces the awaitDrain counter // on the source. This would be more elegant with a .once() // handler in flow(), but adding and removing repeatedly is // too slow. + + var ondrain = pipeOnDrain(src); dest.on('drain', ondrain); - var cleanedUp = false; + function cleanup() { - debug('cleanup'); - // cleanup event handlers once the pipe is broken + debug('cleanup'); // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); dest.removeListener('finish', onfinish); dest.removeListener('drain', ondrain); @@ -65487,75 +72384,71 @@ Readable.prototype.pipe = function (dest, pipeOpts) { src.removeListener('end', onend); src.removeListener('end', unpipe); src.removeListener('data', ondata); - - cleanedUp = true; - - // if the reader is waiting for a drain event from this + cleanedUp = true; // if the reader is waiting for a drain event from this // specific writer, then it would cause it to never start // flowing again. // So, if this is awaiting a drain, then we just call it now. // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); } - // If the user pushes more data while we're writing to dest then we'll end up - // in ondata again. However, we only want to increase awaitDrain once because - // dest will only emit one 'drain' event for the multiple writes. - // => Introduce a guard on increasing awaitDrain. - var increasedAwaitDrain = false; src.on('data', ondata); + function ondata(chunk) { debug('ondata'); - increasedAwaitDrain = false; var ret = dest.write(chunk); - if (false === ret && !increasedAwaitDrain) { + debug('dest.write', ret); + + if (ret === false) { // If the user unpiped during `dest.write()`, it is possible // to get stuck in a permanently paused state if that write // also returned false. // => Check whether `dest` is still a piping destination. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { - debug('false write response, pause', src._readableState.awaitDrain); - src._readableState.awaitDrain++; - increasedAwaitDrain = true; + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; } + src.pause(); } - } - - // if the dest has an error, then stop piping into it. + } // if the dest has an error, then stop piping into it. // however, don't suppress the throwing behavior for this. + + function onerror(er) { debug('onerror', er); unpipe(); dest.removeListener('error', onerror); - if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); - } + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } // Make sure our error handler is attached before userland ones. - // Make sure our error handler is attached before userland ones. - prependListener(dest, 'error', onerror); - // Both close and finish should trigger unpipe, but only once. + prependListener(dest, 'error', onerror); // Both close and finish should trigger unpipe, but only once. + function onclose() { dest.removeListener('finish', onfinish); unpipe(); } + dest.once('close', onclose); + function onfinish() { debug('onfinish'); dest.removeListener('close', onclose); unpipe(); } + dest.once('finish', onfinish); function unpipe() { debug('unpipe'); src.unpipe(dest); - } + } // tell the dest that it's being piped to - // tell the dest that it's being piped to - dest.emit('pipe', src); - // start the flow if it hasn't been started already. + dest.emit('pipe', src); // start the flow if it hasn't been started already. + if (!state.flowing) { debug('pipe resume'); src.resume(); @@ -65565,10 +72458,11 @@ Readable.prototype.pipe = function (dest, pipeOpts) { }; function pipeOnDrain(src) { - return function () { + return function pipeOnDrainFunctionResult() { var state = src._readableState; debug('pipeOnDrain', state.awaitDrain); if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { state.flowing = true; flow(src); @@ -65578,27 +72472,24 @@ function pipeOnDrain(src) { Readable.prototype.unpipe = function (dest) { var state = this._readableState; - var unpipeInfo = { hasUnpiped: false }; + var unpipeInfo = { + hasUnpiped: false + }; // if we're not piping anywhere, then do nothing. - // if we're not piping anywhere, then do nothing. - if (state.pipesCount === 0) return this; + if (state.pipesCount === 0) return this; // just one destination. most common case. - // just one destination. most common case. if (state.pipesCount === 1) { // passed in one, but it's not the right one. if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; // got a match. - if (!dest) dest = state.pipes; - - // got a match. state.pipes = null; state.pipesCount = 0; state.flowing = false; if (dest) dest.emit('unpipe', this, unpipeInfo); return this; - } + } // slow case. multiple pipe destinations. - // slow case. multiple pipe destinations. if (!dest) { // remove all. @@ -65609,80 +72500,139 @@ Readable.prototype.unpipe = function (dest) { state.flowing = false; for (var i = 0; i < len; i++) { - dests[i].emit('unpipe', this, unpipeInfo); - }return this; - } + dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + } + + return this; + } // try to find the right one. + - // try to find the right one. var index = indexOf(state.pipes, dest); if (index === -1) return this; - state.pipes.splice(index, 1); state.pipesCount -= 1; if (state.pipesCount === 1) state.pipes = state.pipes[0]; - dest.emit('unpipe', this, unpipeInfo); - return this; -}; - -// set up data events if they are asked for +}; // set up data events if they are asked for // Ensure readable listeners eventually get something + + Readable.prototype.on = function (ev, fn) { var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; if (ev === 'data') { - // Start flowing on next tick if stream isn't explicitly paused - if (this._readableState.flowing !== false) this.resume(); + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; // Try start flowing on next tick if stream isn't explicitly paused + + if (state.flowing !== false) this.resume(); } else if (ev === 'readable') { - var state = this._readableState; if (!state.endEmitted && !state.readableListening) { state.readableListening = state.needReadable = true; + state.flowing = false; state.emittedReadable = false; - if (!state.reading) { - pna.nextTick(nReadingNextTick, this); - } else if (state.length) { + debug('on readable', state.length, state.reading); + + if (state.length) { emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); } } } return res; }; + Readable.prototype.addListener = Readable.prototype.on; +Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + + return res; +}; + +function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } +} + function nReadingNextTick(self) { debug('readable nexttick read 0'); self.read(0); -} - -// pause() and resume() are remnants of the legacy readable stream API +} // pause() and resume() are remnants of the legacy readable stream API // If the user uses them, then switch into old mode. + + Readable.prototype.resume = function () { var state = this._readableState; + if (!state.flowing) { - debug('resume'); - state.flowing = true; + debug('resume'); // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + + state.flowing = !state.readableListening; resume(this, state); } + + state.paused = false; return this; }; function resume(stream, state) { if (!state.resumeScheduled) { state.resumeScheduled = true; - pna.nextTick(resume_, stream, state); + process.nextTick(resume_, stream, state); } } function resume_(stream, state) { + debug('resume', state.reading); + if (!state.reading) { - debug('resume read 0'); stream.read(0); } state.resumeScheduled = false; - state.awaitDrain = 0; stream.emit('resume'); flow(stream); if (state.flowing && !state.reading) stream.read(0); @@ -65690,31 +72640,37 @@ function resume_(stream, state) { Readable.prototype.pause = function () { debug('call pause flowing=%j', this._readableState.flowing); - if (false !== this._readableState.flowing) { + + if (this._readableState.flowing !== false) { debug('pause'); this._readableState.flowing = false; this.emit('pause'); } + + this._readableState.paused = true; return this; }; function flow(stream) { var state = stream._readableState; debug('flow', state.flowing); - while (state.flowing && stream.read() !== null) {} -} -// wrap an old-style stream as the async data source. + while (state.flowing && stream.read() !== null) { + ; + } +} // wrap an old-style stream as the async data source. // This is *not* part of the readable stream interface. // It is an ugly unfortunate mess of history. + + Readable.prototype.wrap = function (stream) { var _this = this; var state = this._readableState; var paused = false; - stream.on('end', function () { debug('wrapped end'); + if (state.decoder && !state.ended) { var chunk = state.decoder.end(); if (chunk && chunk.length) _this.push(chunk); @@ -65722,42 +72678,41 @@ Readable.prototype.wrap = function (stream) { _this.push(null); }); - stream.on('data', function (chunk) { debug('wrapped data'); - if (state.decoder) chunk = state.decoder.write(chunk); + if (state.decoder) chunk = state.decoder.write(chunk); // don't skip over falsy values in objectMode - // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; var ret = _this.push(chunk); + if (!ret) { paused = true; stream.pause(); } - }); - - // proxy all the other methods. + }); // proxy all the other methods. // important when wrapping filters and duplexes. + for (var i in stream) { if (this[i] === undefined && typeof stream[i] === 'function') { - this[i] = function (method) { - return function () { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { return stream[method].apply(stream, arguments); }; }(i); } - } + } // proxy certain important events. + - // proxy certain important events. for (var n = 0; n < kProxyEvents.length; n++) { stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); - } - - // when we try to consume some more bytes, simply unpause the + } // when we try to consume some more bytes, simply unpause the // underlying stream. + + this._read = function (n) { debug('wrapped _read', n); + if (paused) { paused = false; stream.resume(); @@ -65767,149 +72722,127 @@ Readable.prototype.wrap = function (stream) { return this; }; +if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = require('./internal/streams/async_iterator'); + } + + return createReadableStreamAsyncIterator(this); + }; +} + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { // making it explicit this property is not enumerable // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._readableState.highWaterMark; } }); +Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } +}); +Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } +}); // exposed for testing purposes only. -// exposed for testing purposes only. Readable._fromList = fromList; - -// Pluck off n bytes from an array of buffers. +Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } +}); // Pluck off n bytes from an array of buffers. // Length is the combined lengths of all the buffers in the list. // This function is designed to be inlinable, so please take care when making // changes to the function body. + function fromList(n, state) { // nothing buffered if (state.length === 0) return null; - var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list - if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); state.buffer.clear(); } else { // read part of list - ret = fromListPartial(n, state.buffer, state.decoder); - } - - return ret; -} - -// Extracts only enough buffered data to satisfy the amount requested. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function fromListPartial(n, list, hasStrings) { - var ret; - if (n < list.head.data.length) { - // slice is the same for buffers and strings - ret = list.head.data.slice(0, n); - list.head.data = list.head.data.slice(n); - } else if (n === list.head.data.length) { - // first chunk is a perfect match - ret = list.shift(); - } else { - // result spans more than one buffer - ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); - } - return ret; -} - -// Copies a specified amount of characters from the list of buffered data -// chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBufferString(n, list) { - var p = list.head; - var c = 1; - var ret = p.data; - n -= ret.length; - while (p = p.next) { - var str = p.data; - var nb = n > str.length ? str.length : n; - if (nb === str.length) ret += str;else ret += str.slice(0, n); - n -= nb; - if (n === 0) { - if (nb === str.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = str.slice(nb); - } - break; - } - ++c; - } - list.length -= c; - return ret; -} - -// Copies a specified amount of bytes from the list of buffered data chunks. -// This function is designed to be inlinable, so please take care when making -// changes to the function body. -function copyFromBuffer(n, list) { - var ret = Buffer.allocUnsafe(n); - var p = list.head; - var c = 1; - p.data.copy(ret); - n -= p.data.length; - while (p = p.next) { - var buf = p.data; - var nb = n > buf.length ? buf.length : n; - buf.copy(ret, ret.length - n, 0, nb); - n -= nb; - if (n === 0) { - if (nb === buf.length) { - ++c; - if (p.next) list.head = p.next;else list.head = list.tail = null; - } else { - list.head = p; - p.data = buf.slice(nb); - } - break; - } - ++c; + ret = state.buffer.consume(n, state.decoder); } - list.length -= c; return ret; } function endReadable(stream) { var state = stream._readableState; - - // If we get here before consuming all the bytes, then that is a - // bug in node. Should never happen. - if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + debug('endReadable', state.endEmitted); if (!state.endEmitted) { state.ended = true; - pna.nextTick(endReadableNT, state, stream); + process.nextTick(endReadableNT, state, stream); } } function endReadableNT(state, stream) { - // Check that we didn't get one last unshift. + debug('endReadableNT', state.endEmitted, state.length); // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { state.endEmitted = true; stream.readable = false; stream.emit('end'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } } } +if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = require('./internal/streams/from'); + } + + return from(Readable, iterable, opts); + }; +} + function indexOf(xs, x) { for (var i = 0, l = xs.length; i < l; i++) { if (xs[i] === x) return i; } + return -1; } -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_stream_duplex":285,"./internal/streams/BufferList":290,"./internal/streams/destroy":291,"./internal/streams/stream":292,"_process":250,"core-util-is":117,"events":218,"inherits":238,"isarray":240,"process-nextick-args":249,"safe-buffer":298,"string_decoder/":315,"util":84}],288:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":305,"./_stream_duplex":306,"./internal/streams/async_iterator":311,"./internal/streams/buffer_list":312,"./internal/streams/destroy":313,"./internal/streams/from":315,"./internal/streams/state":317,"./internal/streams/stream":318,"_process":270,"buffer":110,"events":220,"inherits":258,"string_decoder/":338,"util":219}],309:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -65930,7 +72863,6 @@ function indexOf(xs, x) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -65972,40 +72904,37 @@ function indexOf(xs, x) { // However, even in such a pathological case, only a single written chunk // would be consumed, and then the rest would wait (un-transformed) until // the results of the previous transformed chunk were consumed. - 'use strict'; module.exports = Transform; -var Duplex = require('./_stream_duplex'); +var _require$codes = require('../errors').codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; -/**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ +var Duplex = require('./_stream_duplex'); -util.inherits(Transform, Duplex); +require('inherits')(Transform, Duplex); function afterTransform(er, data) { var ts = this._transformState; ts.transforming = false; - var cb = ts.writecb; - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); } ts.writechunk = null; ts.writecb = null; - if (data != null) // single equals check for both `null` and `undefined` this.push(data); - cb(er); - var rs = this._readableState; rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { this._read(rs.highWaterMark); } @@ -66013,9 +72942,7 @@ function afterTransform(er, data) { function Transform(options) { if (!(this instanceof Transform)) return new Transform(options); - Duplex.call(this, options); - this._transformState = { afterTransform: afterTransform.bind(this), needTransform: false, @@ -66023,30 +72950,27 @@ function Transform(options) { writecb: null, writechunk: null, writeencoding: null - }; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; + }; // start out asking for a readable event once data is transformed. - // we have implemented the _read method, and done the other things + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things // that Readable wants before the first _read call, so unset the // sync guard flag. + this._readableState.sync = false; if (options) { if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') this._flush = options.flush; - } + } // When the writable side finishes, then flush out anything remaining. + - // When the writable side finishes, then flush out anything remaining. this.on('prefinish', prefinish); } function prefinish() { var _this = this; - if (typeof this._flush === 'function') { + if (typeof this._flush === 'function' && !this._readableState.destroyed) { this._flush(function (er, data) { done(_this, er, data); }); @@ -66058,9 +72982,7 @@ function prefinish() { Transform.prototype.push = function (chunk, encoding) { this._transformState.needTransform = false; return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! +}; // This is the part where you do stuff! // override this function in implementation classes. // 'chunk' is an input chunk. // @@ -66070,8 +72992,10 @@ Transform.prototype.push = function (chunk, encoding) { // Call `cb(err)` when you are done with this chunk. If you pass // an error, then that'll put the hurt on the whole operation. If you // never call cb(), then you'll never get another chunk. + + Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); }; Transform.prototype._write = function (chunk, encoding, cb) { @@ -66079,20 +73003,22 @@ Transform.prototype._write = function (chunk, encoding, cb) { ts.writecb = cb; ts.writechunk = chunk; ts.writeencoding = encoding; + if (!ts.transforming) { var rs = this._readableState; if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } -}; - -// Doesn't matter what the args are here. +}; // Doesn't matter what the args are here. // _transform does all the work. // That we got here means that the readable side wants more data. + + Transform.prototype._read = function (n) { var ts = this._transformState; - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + if (ts.writechunk !== null && !ts.transforming) { ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); } else { // mark that we need a transform, so that any data that comes in @@ -66102,30 +73028,24 @@ Transform.prototype._read = function (n) { }; Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); - _this2.emit('close'); }); }; function done(stream, er, data) { if (er) return stream.emit('error', er); - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases // if there's nothing in the write buffer, then that means // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); return stream.push(null); } -},{"./_stream_duplex":285,"core-util-is":117,"inherits":238}],289:[function(require,module,exports){ -(function (process,global,setImmediate){ +},{"../errors":305,"./_stream_duplex":306,"inherits":258}],310:[function(require,module,exports){ +(function (process,global){(function (){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -66146,35 +73066,29 @@ function done(stream, er, data) { // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. - // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all // the drain event emission and buffering. - 'use strict'; -/**/ - -var pna = require('process-nextick-args'); -/**/ - module.exports = Writable; - /* */ + function WriteReq(chunk, encoding, cb) { this.chunk = chunk; this.encoding = encoding; this.callback = cb; this.next = null; -} - -// It seems a linked list but it is not +} // It seems a linked list but it is not // there will be only 2 of these for each stream + + function CorkedRequest(state) { var _this = this; this.next = null; this.entry = null; + this.finish = function () { onCorkedFinish(_this, state); }; @@ -66182,266 +73096,247 @@ function CorkedRequest(state) { /* */ /**/ -var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick; -/**/ -/**/ + var Duplex; /**/ Writable.WritableState = WritableState; - /**/ -var util = require('core-util-is'); -util.inherits = require('inherits'); -/**/ -/**/ var internalUtil = { deprecate: require('util-deprecate') }; /**/ /**/ + var Stream = require('./internal/streams/stream'); /**/ -/**/ -var Buffer = require('safe-buffer').Buffer; +var Buffer = require('buffer').Buffer; + var OurUint8Array = global.Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { return Buffer.from(chunk); } + function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } -/**/ - var destroyImpl = require('./internal/streams/destroy'); -util.inherits(Writable, Stream); +var _require = require('./internal/streams/state'), + getHighWaterMark = _require.getHighWaterMark; -function nop() {} +var _require$codes = require('../errors').codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; -function WritableState(options, stream) { - Duplex = Duplex || require('./_stream_duplex'); +var errorOrDestroy = destroyImpl.errorOrDestroy; - options = options || {}; +require('inherits')(Writable, Stream); - // Duplex streams are both readable and writable, but share +function nop() {} + +function WritableState(options, stream, isDuplex) { + Duplex = Duplex || require('./_stream_duplex'); + options = options || {}; // Duplex streams are both readable and writable, but share // the same options object. // However, some cases require setting options to different - // values for the readable and the writable sides of the duplex stream. - // These options can be provided separately as readableXXX and writableXXX. - var isDuplex = stream instanceof Duplex; + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. - // object stream flag to indicate whether or not this stream + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; // object stream flag to indicate whether or not this stream // contains buffers or objects. - this.objectMode = !!options.objectMode; - if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; - - // the point at which write() starts returning false + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; // the point at which write() starts returning false // Note: 0 is a valid value, means that we always return false if // the entire buffer is not flushed immediately on write() - var hwm = options.highWaterMark; - var writableHwm = options.writableHighWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); // if _final has been called - // cast to ints. - this.highWaterMark = Math.floor(this.highWaterMark); + this.finalCalled = false; // drain event flag. - // if _final has been called - this.finalCalled = false; + this.needDrain = false; // at the start of calling end() - // drain event flag. - this.needDrain = false; - // at the start of calling end() - this.ending = false; - // when end() has been called, and returned - this.ended = false; - // when 'finish' is emitted - this.finished = false; + this.ending = false; // when end() has been called, and returned - // has it been destroyed - this.destroyed = false; + this.ended = false; // when 'finish' is emitted - // should we decode strings into buffers before passing to _write? + this.finished = false; // has it been destroyed + + this.destroyed = false; // should we decode strings into buffers before passing to _write? // this is here so that some node-core streams can optimize string // handling at a lower level. - var noDecode = options.decodeStrings === false; - this.decodeStrings = !noDecode; - // Crypto is kind of old and crusty. Historically, its default string + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; // Crypto is kind of old and crusty. Historically, its default string // encoding is 'binary' so we have to make this configurable. // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; - // not an actual buffer we keep track of, but a measurement + this.defaultEncoding = options.defaultEncoding || 'utf8'; // not an actual buffer we keep track of, but a measurement // of how much we're waiting to get pushed to some underlying // socket or file. - this.length = 0; - // a flag to see when we're in the middle of a write. - this.writing = false; + this.length = 0; // a flag to see when we're in the middle of a write. - // when true all writes will be buffered until .uncork() call - this.corked = 0; + this.writing = false; // when true all writes will be buffered until .uncork() call - // a flag to be able to tell if the onwrite cb is called immediately, + this.corked = 0; // a flag to be able to tell if the onwrite cb is called immediately, // or on a later tick. We set this to true at first, because any // actions that shouldn't happen until "later" should generally also // not happen before the first write call. - this.sync = true; - // a flag to know if we're processing previously buffered items, which + this.sync = true; // a flag to know if we're processing previously buffered items, which // may call the _write() callback in the same tick, so that we don't // end up in an overlapped onwrite situation. - this.bufferProcessing = false; - // the callback that's passed to _write(chunk,cb) + this.bufferProcessing = false; // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { onwrite(stream, er); - }; + }; // the callback that the user supplies to write(chunk,encoding,cb) - // the callback that the user supplies to write(chunk,encoding,cb) - this.writecb = null; - // the amount that is being written when _write is called. - this.writelen = 0; + this.writecb = null; // the amount that is being written when _write is called. + this.writelen = 0; this.bufferedRequest = null; - this.lastBufferedRequest = null; - - // number of pending user-supplied write callbacks + this.lastBufferedRequest = null; // number of pending user-supplied write callbacks // this must be 0 before 'finish' can be emitted - this.pendingcb = 0; - // emit prefinish if the only thing we're waiting for is _write cbs + this.pendingcb = 0; // emit prefinish if the only thing we're waiting for is _write cbs // This is relevant for synchronous Transform streams - this.prefinished = false; - // True if the error was already emitted and should not be thrown again - this.errorEmitted = false; + this.prefinished = false; // True if the error was already emitted and should not be thrown again - // count buffered requests - this.bufferedRequestCount = 0; + this.errorEmitted = false; // Should close be emitted on destroy. Defaults to true. - // allocate the first CorkedRequest, there is always + this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end') + + this.autoDestroy = !!options.autoDestroy; // count buffered requests + + this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); } WritableState.prototype.getBuffer = function getBuffer() { var current = this.bufferedRequest; var out = []; + while (current) { out.push(current); current = current.next; } + return out; }; (function () { try { Object.defineProperty(WritableState.prototype, 'buffer', { - get: internalUtil.deprecate(function () { + get: internalUtil.deprecate(function writableStateBufferGetter() { return this.getBuffer(); }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') }); } catch (_) {} -})(); - -// Test _writableState for inheritance to account for Duplex streams, +})(); // Test _writableState for inheritance to account for Duplex streams, // whose prototype chain only points to Readable. + + var realHasInstance; + if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { realHasInstance = Function.prototype[Symbol.hasInstance]; Object.defineProperty(Writable, Symbol.hasInstance, { - value: function (object) { + value: function value(object) { if (realHasInstance.call(this, object)) return true; if (this !== Writable) return false; - return object && object._writableState instanceof WritableState; } }); } else { - realHasInstance = function (object) { + realHasInstance = function realHasInstance(object) { return object instanceof this; }; } function Writable(options) { - Duplex = Duplex || require('./_stream_duplex'); - - // Writable ctor is applied to Duplexes, too. + Duplex = Duplex || require('./_stream_duplex'); // Writable ctor is applied to Duplexes, too. // `realHasInstance` is necessary because using plain `instanceof` // would return false, as no `_writableState` property is attached. - // Trying to use the custom `instanceof` for Writable here will also break the // Node.js LazyTransform implementation, which has a non-trivial getter for // `_writableState` that would lead to infinite recursion. - if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { - return new Writable(options); - } + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 - this._writableState = new WritableState(options, this); + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); // legacy. - // legacy. this.writable = true; if (options) { if (typeof options.write === 'function') this._write = options.write; - if (typeof options.writev === 'function') this._writev = options.writev; - if (typeof options.destroy === 'function') this._destroy = options.destroy; - if (typeof options.final === 'function') this._final = options.final; } Stream.call(this); -} +} // Otherwise people can pipe Writable streams, which is just wrong. + -// Otherwise people can pipe Writable streams, which is just wrong. Writable.prototype.pipe = function () { - this.emit('error', new Error('Cannot pipe, not readable')); + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); }; function writeAfterEnd(stream, cb) { - var er = new Error('write after end'); - // TODO: defer error events consistently everywhere, not just the cb - stream.emit('error', er); - pna.nextTick(cb, er); -} + var er = new ERR_STREAM_WRITE_AFTER_END(); // TODO: defer error events consistently everywhere, not just the cb -// Checks that a user-supplied chunk is valid, especially for the particular + errorOrDestroy(stream, er); + process.nextTick(cb, er); +} // Checks that a user-supplied chunk is valid, especially for the particular // mode the stream is in. Currently this means that `null` is never accepted // and undefined/non-string values are only allowed in object mode. + + function validChunk(stream, state, chunk, cb) { - var valid = true; - var er = false; + var er; if (chunk === null) { - er = new TypeError('May not write null values to stream'); - } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { - er = new TypeError('Invalid non-string/buffer chunk'); + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); } + if (er) { - stream.emit('error', er); - pna.nextTick(cb, er); - valid = false; + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; } - return valid; + + return true; } Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer.isBuffer(chunk)) { @@ -66454,21 +73349,16 @@ Writable.prototype.write = function (chunk, encoding, cb) { } if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; - if (typeof cb !== 'function') cb = nop; - - if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } - return ret; }; Writable.prototype.cork = function () { - var state = this._writableState; - - state.corked++; + this._writableState.corked++; }; Writable.prototype.uncork = function () { @@ -66476,23 +73366,33 @@ Writable.prototype.uncork = function () { if (state.corked) { state.corked--; - - if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); } }; Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { // node::ParseEncoding() requires lower case. if (typeof encoding === 'string') encoding = encoding.toLowerCase(); - if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); this._writableState.defaultEncoding = encoding; return this; }; +Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); + function decodeChunk(state, chunk, encoding) { if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { chunk = Buffer.from(chunk, encoding); } + return chunk; } @@ -66501,29 +73401,28 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { // because otherwise some prototype manipulation in // userland will fail enumerable: false, - get: function () { + get: function get() { return this._writableState.highWaterMark; } -}); - -// if we're already writing something, then just put this +}); // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. + function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { isBuf = true; encoding = 'buffer'; chunk = newChunk; } } - var len = state.objectMode ? 1 : chunk.length; + var len = state.objectMode ? 1 : chunk.length; state.length += len; + var ret = state.length < state.highWaterMark; // we must ensure that previous needDrain will not be reset to false. - var ret = state.length < state.highWaterMark; - // we must ensure that previous needDrain will not be reset to false. if (!ret) state.needDrain = true; if (state.writing || state.corked) { @@ -66535,11 +73434,13 @@ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { callback: cb, next: null }; + if (last) { last.next = state.lastBufferedRequest; } else { state.bufferedRequest = state.lastBufferedRequest; } + state.bufferedRequestCount += 1; } else { doWrite(stream, state, false, len, chunk, encoding, cb); @@ -66553,7 +73454,7 @@ function doWrite(stream, state, writev, len, chunk, encoding, cb) { state.writecb = cb; state.writing = true; state.sync = true; - if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); state.sync = false; } @@ -66563,20 +73464,20 @@ function onwriteError(stream, state, sync, er, cb) { if (sync) { // defer the callback if we are being called synchronously // to avoid piling up things on the stack - pna.nextTick(cb, er); - // this can emit finish, and it will always happen + process.nextTick(cb, er); // this can emit finish, and it will always happen // after error - pna.nextTick(finishMaybe, stream, state); + + process.nextTick(finishMaybe, stream, state); stream._writableState.errorEmitted = true; - stream.emit('error', er); + errorOrDestroy(stream, er); } else { // the caller expect this to happen before if // it is async cb(er); stream._writableState.errorEmitted = true; - stream.emit('error', er); - // this can emit finish, but finish must + errorOrDestroy(stream, er); // this can emit finish, but finish must // always follow error + finishMaybe(stream, state); } } @@ -66592,21 +73493,18 @@ function onwrite(stream, er) { var state = stream._writableState; var sync = state.sync; var cb = state.writecb; - + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); onwriteStateUpdate(state); - if (er) onwriteError(stream, state, sync, er, cb);else { // Check if we're actually ready to finish, but don't emit yet - var finished = needFinish(state); + var finished = needFinish(state) || stream.destroyed; if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { clearBuffer(stream, state); } if (sync) { - /**/ - asyncWrite(afterWrite, stream, state, finished, cb); - /**/ + process.nextTick(afterWrite, stream, state, finished, cb); } else { afterWrite(stream, state, finished, cb); } @@ -66618,19 +73516,19 @@ function afterWrite(stream, state, finished, cb) { state.pendingcb--; cb(); finishMaybe(stream, state); -} - -// Must force callback to be called on nextTick, so that we don't +} // Must force callback to be called on nextTick, so that we don't // emit 'drain' before the write() consumer gets the 'false' return // value, and has a chance to attach a 'drain' listener. + + function onwriteDrain(stream, state) { if (state.length === 0 && state.needDrain) { state.needDrain = false; stream.emit('drain'); } -} +} // if there's something in the buffer waiting, then process it + -// if there's something in the buffer waiting, then process it function clearBuffer(stream, state) { state.bufferProcessing = true; var entry = state.bufferedRequest; @@ -66641,29 +73539,30 @@ function clearBuffer(stream, state) { var buffer = new Array(l); var holder = state.corkedRequestsFree; holder.entry = entry; - var count = 0; var allBuffers = true; + while (entry) { buffer[count] = entry; if (!entry.isBuf) allBuffers = false; entry = entry.next; count += 1; } - buffer.allBuffers = allBuffers; - doWrite(stream, state, true, state.length, buffer, '', holder.finish); - - // doWrite is almost always async, defer these to save a bit of time + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); // doWrite is almost always async, defer these to save a bit of time // as the hot path ends with doWrite + state.pendingcb++; state.lastBufferedRequest = null; + if (holder.next) { state.corkedRequestsFree = holder.next; holder.next = null; } else { state.corkedRequestsFree = new CorkedRequest(state); } + state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one @@ -66672,14 +73571,13 @@ function clearBuffer(stream, state) { var encoding = entry.encoding; var cb = entry.callback; var len = state.objectMode ? 1 : chunk.length; - doWrite(stream, state, false, len, chunk, encoding, cb); entry = entry.next; - state.bufferedRequestCount--; - // if we didn't call the onwrite immediately, then + state.bufferedRequestCount--; // if we didn't call the onwrite immediately, then // it means that we need to wait until it does. // also, that means that the chunk and cb are currently // being processed, so move the buffer counter past them. + if (state.writing) { break; } @@ -66693,7 +73591,7 @@ function clearBuffer(stream, state) { } Writable.prototype._write = function (chunk, encoding, cb) { - cb(new Error('_write() is not implemented')); + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); }; Writable.prototype._writev = null; @@ -66710,38 +73608,52 @@ Writable.prototype.end = function (chunk, encoding, cb) { encoding = null; } - if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); // .end() fully uncorks - // .end() fully uncorks if (state.corked) { state.corked = 1; this.uncork(); - } + } // ignore unnecessary end() calls. - // ignore unnecessary end() calls. - if (!state.ending && !state.finished) endWritable(this, state, cb); + + if (!state.ending) endWritable(this, state, cb); + return this; }; +Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); + function needFinish(state) { return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; } + function callFinal(stream, state) { stream._final(function (err) { state.pendingcb--; + if (err) { - stream.emit('error', err); + errorOrDestroy(stream, err); } + state.prefinished = true; stream.emit('prefinish'); finishMaybe(stream, state); }); } + function prefinish(stream, state) { if (!state.prefinished && !state.finalCalled) { - if (typeof stream._final === 'function') { + if (typeof stream._final === 'function' && !state.destroyed) { state.pendingcb++; state.finalCalled = true; - pna.nextTick(callFinal, stream, state); + process.nextTick(callFinal, stream, state); } else { state.prefinished = true; stream.emit('prefinish'); @@ -66751,22 +73663,37 @@ function prefinish(stream, state) { function finishMaybe(stream, state) { var need = needFinish(state); + if (need) { prefinish(stream, state); + if (state.pendingcb === 0) { state.finished = true; stream.emit('finish'); + + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } } } + return need; } function endWritable(stream, state, cb) { state.ending = true; finishMaybe(stream, state); + if (cb) { - if (state.finished) pna.nextTick(cb);else stream.once('finish', cb); + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); } + state.ended = true; stream.writable = false; } @@ -66774,59 +73701,289 @@ function endWritable(stream, state, cb) { function onCorkedFinish(corkReq, state, err) { var entry = corkReq.entry; corkReq.entry = null; + while (entry) { var cb = entry.callback; state.pendingcb--; cb(err); entry = entry.next; - } - if (state.corkedRequestsFree) { - state.corkedRequestsFree.next = corkReq; - } else { - state.corkedRequestsFree = corkReq; - } + } // reuse the free corkReq. + + + state.corkedRequestsFree.next = corkReq; } Object.defineProperty(Writable.prototype, 'destroyed', { - get: function () { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { if (this._writableState === undefined) { return false; } + return this._writableState.destroyed; }, - set: function (value) { + set: function set(value) { // we ignore the value if the stream // has not been initialized yet if (!this._writableState) { return; - } - - // backward compatibility, the user is explicitly + } // backward compatibility, the user is explicitly // managing destroyed + + this._writableState.destroyed = value; } }); - Writable.prototype.destroy = destroyImpl.destroy; Writable.prototype._undestroy = destroyImpl.undestroy; + Writable.prototype._destroy = function (err, cb) { - this.end(); cb(err); }; -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"./_stream_duplex":285,"./internal/streams/destroy":291,"./internal/streams/stream":292,"_process":250,"core-util-is":117,"inherits":238,"process-nextick-args":249,"safe-buffer":298,"timers":325,"util-deprecate":333}],290:[function(require,module,exports){ +}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../errors":305,"./_stream_duplex":306,"./internal/streams/destroy":313,"./internal/streams/state":317,"./internal/streams/stream":318,"_process":270,"buffer":110,"inherits":258,"util-deprecate":356}],311:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; + +var _Object$setPrototypeO; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +var finished = require('./end-of-stream'); + +var kLastResolve = Symbol('lastResolve'); +var kLastReject = Symbol('lastReject'); +var kError = Symbol('error'); +var kEnded = Symbol('ended'); +var kLastPromise = Symbol('lastPromise'); +var kHandlePromise = Symbol('handlePromise'); +var kStream = Symbol('stream'); + +function createIterResult(value, done) { + return { + value: value, + done: done + }; +} + +function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + + if (resolve !== null) { + var data = iter[kStream].read(); // we defer if data is null + // we can be expecting either 'end' or + // 'error' + + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } +} + +function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); +} + +function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + + iter[kHandlePromise](resolve, reject); + }, reject); + }; +} + +var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); +var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + + next: function next() { + var _this = this; + + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + + if (error !== null) { + return Promise.reject(error); + } + + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + + + var lastPromise = this[kLastPromise]; + var promise; + + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + + promise = new Promise(this[kHandlePromise]); + } + + this[kLastPromise] = promise; + return promise; + } +}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; +}), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + + resolve(createIterResult(undefined, true)); + }); + }); +}), _Object$setPrototypeO), AsyncIteratorPrototype); + +var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; // reject if we are waiting for data in the Promise + // returned by next() and store the error + + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + + iterator[kError] = err; + return; + } + + var resolve = iterator[kLastResolve]; + + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; +}; + +module.exports = createReadableStreamAsyncIterator; +}).call(this)}).call(this,require('_process')) +},{"./end-of-stream":314,"_process":270}],312:[function(require,module,exports){ 'use strict'; +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var Buffer = require('safe-buffer').Buffer; -var util = require('util'); +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var _require = require('buffer'), + Buffer = _require.Buffer; + +var _require2 = require('util'), + inspect = _require2.inspect; + +var custom = inspect && inspect.custom || 'inspect'; function copyBuffer(src, target, offset) { - src.copy(target, offset); + Buffer.prototype.copy.call(src, target, offset); } -module.exports = function () { +module.exports = +/*#__PURE__*/ +function () { function BufferList() { _classCallCheck(this, BufferList); @@ -66835,74 +73992,183 @@ module.exports = function () { this.length = 0; } - BufferList.prototype.push = function push(v) { - var entry = { data: v, next: null }; - if (this.length > 0) this.tail.next = entry;else this.head = entry; - this.tail = entry; - ++this.length; - }; + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; - BufferList.prototype.unshift = function unshift(v) { - var entry = { data: v, next: this.head }; - if (this.length === 0) this.tail = entry; - this.head = entry; - ++this.length; - }; + while (p = p.next) { + ret += s + p.data; + } - BufferList.prototype.shift = function shift() { - if (this.length === 0) return; - var ret = this.head.data; - if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; - --this.length; - return ret; - }; + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; - BufferList.prototype.clear = function clear() { - this.head = this.tail = null; - this.length = 0; - }; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } - BufferList.prototype.join = function join(s) { - if (this.length === 0) return ''; - var p = this.head; - var ret = '' + p.data; - while (p = p.next) { - ret += s + p.data; - }return ret; - }; + return ret; + } // Consumes a specified amount of bytes or characters from the buffered data. - BufferList.prototype.concat = function concat(n) { - if (this.length === 0) return Buffer.alloc(0); - if (this.length === 1) return this.head.data; - var ret = Buffer.allocUnsafe(n >>> 0); - var p = this.head; - var i = 0; - while (p) { - copyBuffer(p.data, ret, i); - i += p.data.length; - p = p.next; + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + + return ret; } - return ret; - }; + }, { + key: "first", + value: function first() { + return this.head.data; + } // Consumes a specified amount of characters from the buffered data. - return BufferList; -}(); + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } -if (util && util.inspect && util.inspect.custom) { - module.exports.prototype[util.inspect.custom] = function () { - var obj = util.inspect({ length: this.length }); - return this.constructor.name + ' ' + obj; - }; -} -},{"safe-buffer":298,"util":84}],291:[function(require,module,exports){ -'use strict'; + break; + } -/**/ + ++c; + } -var pna = require('process-nextick-args'); -/**/ + this.length -= c; + return ret; + } // Consumes a specified amount of bytes from the buffered data. + + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + + break; + } + + ++c; + } + + this.length -= c; + return ret; + } // Make sure the linked list only shows the minimal necessary information. + + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread({}, options, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + + return BufferList; +}(); +},{"buffer":110,"util":219}],313:[function(require,module,exports){ +(function (process){(function (){ +'use strict'; // undocumented cb() API, needed for core, not for public API -// undocumented cb() API, needed for core, not for public API function destroy(err, cb) { var _this = this; @@ -66912,38 +74178,61 @@ function destroy(err, cb) { if (readableDestroyed || writableDestroyed) { if (cb) { cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } } - return this; - } - // we set destroyed to true before firing error callbacks in order + return this; + } // we set destroyed to true before firing error callbacks in order // to make it re-entrance safe in case destroy() is called within callbacks + if (this._readableState) { this._readableState.destroyed = true; - } + } // if this is a duplex stream mark the writable part as destroyed as well + - // if this is a duplex stream mark the writable part as destroyed as well if (this._writableState) { this._writableState.destroyed = true; } this._destroy(err || null, function (err) { if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); } } else if (cb) { + process.nextTick(emitCloseNT, _this); cb(err); + } else { + process.nextTick(emitCloseNT, _this); } }); return this; } +function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); +} + +function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); +} + function undestroy() { if (this._readableState) { this._readableState.destroyed = false; @@ -66956,6 +74245,8 @@ function undestroy() { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } @@ -66965,17 +74256,262 @@ function emitErrorNT(self, err) { self.emit('error', err); } +function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); +} + module.exports = { destroy: destroy, - undestroy: undestroy + undestroy: undestroy, + errorOrDestroy: errorOrDestroy }; -},{"process-nextick-args":249}],292:[function(require,module,exports){ -module.exports = require('events').EventEmitter; +}).call(this)}).call(this,require('_process')) +},{"_process":270}],314:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/end-of-stream with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; -},{"events":218}],293:[function(require,module,exports){ -module.exports = require('./readable').PassThrough +var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + callback.apply(this, args); + }; +} + +function noop() {} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + + var writableEnded = stream._writableState && stream._writableState.finished; + + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + + var readableEnded = stream._readableState && stream._readableState.endEmitted; + + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + + var onerror = function onerror(err) { + callback.call(stream, err); + }; + + var onclose = function onclose() { + var err; + + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; +} + +module.exports = eos; +},{"../../../errors":305}],315:[function(require,module,exports){ +module.exports = function () { + throw new Error('Readable.from is not available in the browser') +}; + +},{}],316:[function(require,module,exports){ +// Ported from https://github.com/mafintosh/pump with +// permission from the author, Mathias Buus (@mafintosh). +'use strict'; + +var eos; + +function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; +} + +var _require$codes = require('../../../errors').codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + +function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; +} + +function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; +} + +function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = require('./end-of-stream'); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; // request.destroy just do .end - .abort is what we want + + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; +} + +function call(fn) { + fn(); +} + +function pipe(from, to) { + return from.pipe(to); +} + +function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); +} + +function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); +} + +module.exports = pipeline; +},{"../../../errors":305,"./end-of-stream":314}],317:[function(require,module,exports){ +'use strict'; + +var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE; + +function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; +} + +function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + + return Math.floor(hwm); + } // Default value + + + return state.objectMode ? 16 : 16 * 1024; +} -},{"./readable":294}],294:[function(require,module,exports){ +module.exports = { + getHighWaterMark: getHighWaterMark +}; +},{"../../../errors":305}],318:[function(require,module,exports){ +arguments[4][230][0].apply(exports,arguments) +},{"dup":230,"events":220}],319:[function(require,module,exports){ exports = module.exports = require('./lib/_stream_readable.js'); exports.Stream = exports; exports.Readable = exports; @@ -66983,14 +74519,10 @@ exports.Writable = require('./lib/_stream_writable.js'); exports.Duplex = require('./lib/_stream_duplex.js'); exports.Transform = require('./lib/_stream_transform.js'); exports.PassThrough = require('./lib/_stream_passthrough.js'); +exports.finished = require('./lib/internal/streams/end-of-stream.js'); +exports.pipeline = require('./lib/internal/streams/pipeline.js'); -},{"./lib/_stream_duplex.js":285,"./lib/_stream_passthrough.js":286,"./lib/_stream_readable.js":287,"./lib/_stream_transform.js":288,"./lib/_stream_writable.js":289}],295:[function(require,module,exports){ -module.exports = require('./readable').Transform - -},{"./readable":294}],296:[function(require,module,exports){ -module.exports = require('./lib/_stream_writable.js'); - -},{"./lib/_stream_writable.js":289}],297:[function(require,module,exports){ +},{"./lib/_stream_duplex.js":306,"./lib/_stream_passthrough.js":307,"./lib/_stream_readable.js":308,"./lib/_stream_transform.js":309,"./lib/_stream_writable.js":310,"./lib/internal/streams/end-of-stream.js":314,"./lib/internal/streams/pipeline.js":316}],320:[function(require,module,exports){ 'use strict' var Buffer = require('buffer').Buffer var inherits = require('inherits') @@ -67155,7 +74687,8 @@ function fn5 (a, b, c, d, e, m, k, s) { module.exports = RIPEMD160 -},{"buffer":111,"hash-base":222,"inherits":238}],298:[function(require,module,exports){ +},{"buffer":110,"hash-base":243,"inherits":258}],321:[function(require,module,exports){ +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -67178,6 +74711,8 @@ function SafeBuffer (arg, encodingOrOffset, length) { return Buffer(arg, encodingOrOffset, length) } +SafeBuffer.prototype = Object.create(Buffer.prototype) + // Copy static methods from Buffer copyProps(Buffer, SafeBuffer) @@ -67219,12 +74754,93 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":111}],299:[function(require,module,exports){ +},{"buffer":110}],322:[function(require,module,exports){ +(function (process){(function (){ +/* eslint-disable node/no-deprecated-api */ + +'use strict' + +var buffer = require('buffer') +var Buffer = buffer.Buffer + +var safer = {} + +var key + +for (key in buffer) { + if (!buffer.hasOwnProperty(key)) continue + if (key === 'SlowBuffer' || key === 'Buffer') continue + safer[key] = buffer[key] +} + +var Safer = safer.Buffer = {} +for (key in Buffer) { + if (!Buffer.hasOwnProperty(key)) continue + if (key === 'allocUnsafe' || key === 'allocUnsafeSlow') continue + Safer[key] = Buffer[key] +} + +safer.Buffer.prototype = Buffer.prototype + +if (!Safer.from || Safer.from === Uint8Array.from) { + Safer.from = function (value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('The "value" argument must not be of type number. Received type ' + typeof value) + } + if (value && typeof value.length === 'undefined') { + throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' + typeof value) + } + return Buffer(value, encodingOrOffset, length) + } +} + +if (!Safer.alloc) { + Safer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('The "size" argument must be of type number. Received type ' + typeof size) + } + if (size < 0 || size >= 2 * (1 << 30)) { + throw new RangeError('The value "' + size + '" is invalid for option "size"') + } + var buf = Buffer(size) + if (!fill || fill.length === 0) { + buf.fill(0) + } else if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + return buf + } +} + +if (!safer.kStringMaxLength) { + try { + safer.kStringMaxLength = process.binding('buffer').kStringMaxLength + } catch (e) { + // we can't determine kStringMaxLength in environments where process.binding + // is unsupported, so let's not set it + } +} + +if (!safer.constants) { + safer.constants = { + MAX_LENGTH: safer.kMaxLength + } + if (safer.kStringMaxLength) { + safer.constants.MAX_STRING_LENGTH = safer.kStringMaxLength + } +} + +module.exports = safer + +}).call(this)}).call(this,require('_process')) +},{"_process":270,"buffer":110}],323:[function(require,module,exports){ 'use strict' module.exports = require('./lib')(require('./lib/elliptic')) -},{"./lib":303,"./lib/elliptic":302}],300:[function(require,module,exports){ -(function (Buffer){ +},{"./lib":327,"./lib/elliptic":326}],324:[function(require,module,exports){ +(function (Buffer){(function (){ 'use strict' var toString = Object.prototype.toString @@ -67270,8 +74886,8 @@ exports.isNumberInInterval = function (number, x, y, message) { if (number <= x || number >= y) throw RangeError(message) } -}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) -},{"../../is-buffer/index.js":239}],301:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../../is-buffer/index.js")}) +},{"../../is-buffer/index.js":259}],325:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var bip66 = require('bip66') @@ -67466,7 +75082,7 @@ exports.signatureImportLax = function (sig) { return { r: r, s: s } } -},{"bip66":38,"safe-buffer":298}],302:[function(require,module,exports){ +},{"bip66":38,"safe-buffer":321}],326:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer var createHash = require('create-hash') @@ -67599,7 +75215,10 @@ exports.publicKeyTweakAdd = function (publicKey, tweak, compressed) { tweak = new BN(tweak) if (tweak.cmp(ecparams.n) >= 0) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) - return Buffer.from(ecparams.g.mul(tweak).add(pair.pub).encode(true, compressed)) + var point = ecparams.g.mul(tweak).add(pair.pub) + if (point.isInfinity()) throw new Error(messages.EC_PUBLIC_KEY_TWEAK_ADD_FAIL) + + return Buffer.from(point.encode(true, compressed)) } exports.publicKeyTweakMul = function (publicKey, tweak, compressed) { @@ -67683,7 +75302,7 @@ exports.sign = function (message, privateKey, noncefn, data) { } exports.verify = function (message, signature, publicKey) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -67693,11 +75312,11 @@ exports.verify = function (message, signature, publicKey) { var pair = loadPublicKey(publicKey) if (pair === null) throw new Error(messages.EC_PUBLIC_KEY_PARSE_FAIL) - return ec.verify(message, sigObj, {x: pair.pub.x, y: pair.pub.y}) + return ec.verify(message, sigObj, { x: pair.pub.x, y: pair.pub.y }) } exports.recover = function (message, signature, recovery, compressed) { - var sigObj = {r: signature.slice(0, 32), s: signature.slice(32, 64)} + var sigObj = { r: signature.slice(0, 32), s: signature.slice(32, 64) } var sigr = new BN(sigObj.r) var sigs = new BN(sigObj.s) @@ -67728,7 +75347,7 @@ exports.ecdhUnsafe = function (publicKey, privateKey, compressed) { return Buffer.from(pair.pub.mul(scalar).encode(true, compressed)) } -},{"../messages.json":304,"bn.js":82,"create-hash":119,"elliptic":201,"safe-buffer":298}],303:[function(require,module,exports){ +},{"../messages.json":328,"bn.js":82,"create-hash":118,"elliptic":202,"safe-buffer":321}],327:[function(require,module,exports){ 'use strict' var assert = require('./assert') var der = require('./der') @@ -67975,7 +75594,7 @@ module.exports = function (secp256k1) { } } -},{"./assert":300,"./der":301,"./messages.json":304}],304:[function(require,module,exports){ +},{"./assert":324,"./der":325,"./messages.json":328}],328:[function(require,module,exports){ module.exports={ "COMPRESSED_TYPE_INVALID": "compressed should be a boolean", "EC_PRIVATE_KEY_TYPE_INVALID": "private key should be a Buffer", @@ -68014,7 +75633,7 @@ module.exports={ "TWEAK_LENGTH_INVALID": "tweak length is invalid" } -},{}],305:[function(require,module,exports){ +},{}],329:[function(require,module,exports){ var Buffer = require('safe-buffer').Buffer // prototype class for hash functions @@ -68097,7 +75716,7 @@ Hash.prototype._update = function () { module.exports = Hash -},{"safe-buffer":298}],306:[function(require,module,exports){ +},{"safe-buffer":321}],330:[function(require,module,exports){ var exports = module.exports = function SHA (algorithm) { algorithm = algorithm.toLowerCase() @@ -68114,7 +75733,7 @@ exports.sha256 = require('./sha256') exports.sha384 = require('./sha384') exports.sha512 = require('./sha512') -},{"./sha":307,"./sha1":308,"./sha224":309,"./sha256":310,"./sha384":311,"./sha512":312}],307:[function(require,module,exports){ +},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined * in FIPS PUB 180-1 @@ -68210,7 +75829,7 @@ Sha.prototype._hash = function () { module.exports = Sha -},{"./hash":305,"inherits":238,"safe-buffer":298}],308:[function(require,module,exports){ +},{"./hash":329,"inherits":258,"safe-buffer":321}],332:[function(require,module,exports){ /* * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined * in FIPS PUB 180-1 @@ -68311,7 +75930,7 @@ Sha1.prototype._hash = function () { module.exports = Sha1 -},{"./hash":305,"inherits":238,"safe-buffer":298}],309:[function(require,module,exports){ +},{"./hash":329,"inherits":258,"safe-buffer":321}],333:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -68366,7 +75985,7 @@ Sha224.prototype._hash = function () { module.exports = Sha224 -},{"./hash":305,"./sha256":310,"inherits":238,"safe-buffer":298}],310:[function(require,module,exports){ +},{"./hash":329,"./sha256":334,"inherits":258,"safe-buffer":321}],334:[function(require,module,exports){ /** * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined * in FIPS 180-2 @@ -68503,7 +76122,7 @@ Sha256.prototype._hash = function () { module.exports = Sha256 -},{"./hash":305,"inherits":238,"safe-buffer":298}],311:[function(require,module,exports){ +},{"./hash":329,"inherits":258,"safe-buffer":321}],335:[function(require,module,exports){ var inherits = require('inherits') var SHA512 = require('./sha512') var Hash = require('./hash') @@ -68562,7 +76181,7 @@ Sha384.prototype._hash = function () { module.exports = Sha384 -},{"./hash":305,"./sha512":312,"inherits":238,"safe-buffer":298}],312:[function(require,module,exports){ +},{"./hash":329,"./sha512":336,"inherits":258,"safe-buffer":321}],336:[function(require,module,exports){ var inherits = require('inherits') var Hash = require('./hash') var Buffer = require('safe-buffer').Buffer @@ -68824,7 +76443,7 @@ Sha512.prototype._hash = function () { module.exports = Sha512 -},{"./hash":305,"inherits":238,"safe-buffer":298}],313:[function(require,module,exports){ +},{"./hash":329,"inherits":258,"safe-buffer":321}],337:[function(require,module,exports){ "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}}; sjcl.cipher.aes=function(a){this.j[0][0][0]||this.m();var b,c,d,e,f=this.j[0][4],h=this.j[1];b=a.length;var g=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.c=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^g<<24,g=g<<1^283*(g>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:h[0][f[c>>>24]]^h[1][f[c>>16&255]]^h[2][f[c>>8&255]]^h[3][f[c& 255]]}; @@ -68857,440 +76476,16 @@ sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(thi sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E4;if(0>d||0>c)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,h,g,l,k=[],m=sjcl.bitArray;for(l=1;32*k.length<(d||1);l++){e=f=a.encrypt(m.concat(b,[l]));for(h=1;h*/ - -var Buffer = require('safe-buffer').Buffer; -/**/ - -var isEncoding = Buffer.isEncoding || function (encoding) { - encoding = '' + encoding; - switch (encoding && encoding.toLowerCase()) { - case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': - return true; - default: - return false; - } -}; - -function _normalizeEncoding(enc) { - if (!enc) return 'utf8'; - var retried; - while (true) { - switch (enc) { - case 'utf8': - case 'utf-8': - return 'utf8'; - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return 'utf16le'; - case 'latin1': - case 'binary': - return 'latin1'; - case 'base64': - case 'ascii': - case 'hex': - return enc; - default: - if (retried) return; // undefined - enc = ('' + enc).toLowerCase(); - retried = true; - } - } -}; - -// Do not cache `Buffer.isEncoding` when checking encoding names as some -// modules monkey-patch it to support additional encodings -function normalizeEncoding(enc) { - var nenc = _normalizeEncoding(enc); - if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); - return nenc || enc; -} - -// StringDecoder provides an interface for efficiently splitting a series of -// buffers into a series of JS strings without breaking apart multi-byte -// characters. -exports.StringDecoder = StringDecoder; -function StringDecoder(encoding) { - this.encoding = normalizeEncoding(encoding); - var nb; - switch (this.encoding) { - case 'utf16le': - this.text = utf16Text; - this.end = utf16End; - nb = 4; - break; - case 'utf8': - this.fillLast = utf8FillLast; - nb = 4; - break; - case 'base64': - this.text = base64Text; - this.end = base64End; - nb = 3; - break; - default: - this.write = simpleWrite; - this.end = simpleEnd; - return; - } - this.lastNeed = 0; - this.lastTotal = 0; - this.lastChar = Buffer.allocUnsafe(nb); -} - -StringDecoder.prototype.write = function (buf) { - if (buf.length === 0) return ''; - var r; - var i; - if (this.lastNeed) { - r = this.fillLast(buf); - if (r === undefined) return ''; - i = this.lastNeed; - this.lastNeed = 0; - } else { - i = 0; - } - if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); - return r || ''; -}; - -StringDecoder.prototype.end = utf8End; - -// Returns only complete characters in a Buffer -StringDecoder.prototype.text = utf8Text; - -// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer -StringDecoder.prototype.fillLast = function (buf) { - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); - this.lastNeed -= buf.length; -}; - -// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a -// continuation byte. If an invalid byte is detected, -2 is returned. -function utf8CheckByte(byte) { - if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; - return byte >> 6 === 0x02 ? -1 : -2; -} - -// Checks at most 3 bytes at the end of a Buffer in order to detect an -// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) -// needed to complete the UTF-8 character (if applicable) are returned. -function utf8CheckIncomplete(self, buf, i) { - var j = buf.length - 1; - if (j < i) return 0; - var nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 1; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) self.lastNeed = nb - 2; - return nb; - } - if (--j < i || nb === -2) return 0; - nb = utf8CheckByte(buf[j]); - if (nb >= 0) { - if (nb > 0) { - if (nb === 2) nb = 0;else self.lastNeed = nb - 3; - } - return nb; - } - return 0; -} - -// Validates as many continuation bytes for a multi-byte UTF-8 character as -// needed or are available. If we see a non-continuation byte where we expect -// one, we "replace" the validated continuation bytes we've seen so far with -// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding -// behavior. The continuation byte check is included three times in the case -// where all of the continuation bytes for a character exist in the same buffer. -// It is also done this way as a slight performance increase instead of using a -// loop. -function utf8CheckExtraBytes(self, buf, p) { - if ((buf[0] & 0xC0) !== 0x80) { - self.lastNeed = 0; - return '\ufffd'; - } - if (self.lastNeed > 1 && buf.length > 1) { - if ((buf[1] & 0xC0) !== 0x80) { - self.lastNeed = 1; - return '\ufffd'; - } - if (self.lastNeed > 2 && buf.length > 2) { - if ((buf[2] & 0xC0) !== 0x80) { - self.lastNeed = 2; - return '\ufffd'; - } - } - } -} - -// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. -function utf8FillLast(buf) { - var p = this.lastTotal - this.lastNeed; - var r = utf8CheckExtraBytes(this, buf, p); - if (r !== undefined) return r; - if (this.lastNeed <= buf.length) { - buf.copy(this.lastChar, p, 0, this.lastNeed); - return this.lastChar.toString(this.encoding, 0, this.lastTotal); - } - buf.copy(this.lastChar, p, 0, buf.length); - this.lastNeed -= buf.length; -} - -// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a -// partial character, the character's bytes are buffered until the required -// number of bytes are available. -function utf8Text(buf, i) { - var total = utf8CheckIncomplete(this, buf, i); - if (!this.lastNeed) return buf.toString('utf8', i); - this.lastTotal = total; - var end = buf.length - (total - this.lastNeed); - buf.copy(this.lastChar, 0, end); - return buf.toString('utf8', i, end); -} - -// For UTF-8, a replacement character is added when ending on a partial -// character. -function utf8End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + '\ufffd'; - return r; -} - -// UTF-16LE typically needs two bytes per character, but even if we have an even -// number of bytes available, we need to check if we end on a leading/high -// surrogate. In that case, we need to wait for the next two bytes in order to -// decode the last character properly. -function utf16Text(buf, i) { - if ((buf.length - i) % 2 === 0) { - var r = buf.toString('utf16le', i); - if (r) { - var c = r.charCodeAt(r.length - 1); - if (c >= 0xD800 && c <= 0xDBFF) { - this.lastNeed = 2; - this.lastTotal = 4; - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - return r.slice(0, -1); - } - } - return r; - } - this.lastNeed = 1; - this.lastTotal = 2; - this.lastChar[0] = buf[buf.length - 1]; - return buf.toString('utf16le', i, buf.length - 1); -} - -// For UTF-16LE we do not explicitly append special replacement characters if we -// end on a partial character, we simply let v8 handle that. -function utf16End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) { - var end = this.lastTotal - this.lastNeed; - return r + this.lastChar.toString('utf16le', 0, end); - } - return r; -} - -function base64Text(buf, i) { - var n = (buf.length - i) % 3; - if (n === 0) return buf.toString('base64', i); - this.lastNeed = 3 - n; - this.lastTotal = 3; - if (n === 1) { - this.lastChar[0] = buf[buf.length - 1]; - } else { - this.lastChar[0] = buf[buf.length - 2]; - this.lastChar[1] = buf[buf.length - 1]; - } - return buf.toString('base64', i, buf.length - n); -} - -function base64End(buf) { - var r = buf && buf.length ? this.write(buf) : ''; - if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); - return r; -} - -// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) -function simpleWrite(buf) { - return buf.toString(this.encoding); -} - -function simpleEnd(buf) { - return buf && buf.length ? this.write(buf) : ''; -} -},{"safe-buffer":298}],316:[function(require,module,exports){ +},{}],338:[function(require,module,exports){ +arguments[4][232][0].apply(exports,arguments) +},{"dup":232,"safe-buffer":321}],339:[function(require,module,exports){ module.exports = function (options) { options.signer = options.signer || require('./lib/signer-hmac-only'); return require('./lib/index')(options); } -},{"./lib/index":317,"./lib/signer-hmac-only":318}],317:[function(require,module,exports){ +},{"./lib/index":340,"./lib/signer-hmac-only":341}],340:[function(require,module,exports){ /** * original code from http-signature package by Joyent, Inc. * @@ -69449,7 +76644,7 @@ module.exports = function (options) { }; } -},{"util":335}],318:[function(require,module,exports){ +},{"util":242}],341:[function(require,module,exports){ var createHmac = require('create-hmac'); module.exports = function (stringToSign, options) { @@ -69466,7 +76661,7 @@ module.exports = function (stringToSign, options) { return signature; }; -},{"create-hmac":121}],319:[function(require,module,exports){ +},{"create-hmac":120}],342:[function(require,module,exports){ function Agent() { this._defaults = []; } @@ -69488,7 +76683,7 @@ Agent.prototype._setDefaults = function(req) { module.exports = Agent; -},{}],320:[function(require,module,exports){ +},{}],343:[function(require,module,exports){ /** * Root reference for iframes. */ @@ -70410,7 +77605,7 @@ request.put = function(url, data, fn) { return req; }; -},{"./agent-base":319,"./is-object":321,"./request-base":322,"./response-base":323,"component-emitter":116}],321:[function(require,module,exports){ +},{"./agent-base":342,"./is-object":344,"./request-base":345,"./response-base":346,"component-emitter":115}],344:[function(require,module,exports){ 'use strict'; /** @@ -70427,7 +77622,7 @@ function isObject(obj) { module.exports = isObject; -},{}],322:[function(require,module,exports){ +},{}],345:[function(require,module,exports){ 'use strict'; /** @@ -71123,7 +78318,7 @@ RequestBase.prototype._setTimeouts = function() { } }; -},{"./is-object":321}],323:[function(require,module,exports){ +},{"./is-object":344}],346:[function(require,module,exports){ 'use strict'; /** @@ -71261,7 +78456,7 @@ ResponseBase.prototype._setStatusProperties = function(status){ this.unprocessableEntity = 422 == status; }; -},{"./utils":324}],324:[function(require,module,exports){ +},{"./utils":347}],347:[function(require,module,exports){ 'use strict'; /** @@ -71334,8 +78529,8 @@ exports.cleanHeader = function(header, changesOrigin){ return header; }; -},{}],325:[function(require,module,exports){ -(function (setImmediate,clearImmediate){ +},{}],348:[function(require,module,exports){ +(function (setImmediate,clearImmediate){(function (){ var nextTick = require('process/browser.js').nextTick; var apply = Function.prototype.apply; var slice = Array.prototype.slice; @@ -71412,8 +78607,8 @@ exports.setImmediate = typeof setImmediate === "function" ? setImmediate : funct exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { delete immediateIds[id]; }; -}).call(this,require("timers").setImmediate,require("timers").clearImmediate) -},{"process/browser.js":250,"timers":325}],326:[function(require,module,exports){ +}).call(this)}).call(this,require("timers").setImmediate,require("timers").clearImmediate) +},{"process/browser.js":270,"timers":348}],349:[function(require,module,exports){ var native = require('./native') function getTypeName (fn) { @@ -71525,8 +78720,8 @@ module.exports = { getValueTypeName: getValueTypeName } -},{"./native":329}],327:[function(require,module,exports){ -(function (Buffer){ +},{"./native":352}],350:[function(require,module,exports){ +(function (Buffer){(function (){ var NATIVE = require('./native') var ERRORS = require('./errors') @@ -71619,8 +78814,8 @@ for (var typeName in types) { module.exports = types -}).call(this,{"isBuffer":require("../is-buffer/index.js")}) -},{"../is-buffer/index.js":239,"./errors":326,"./native":329}],328:[function(require,module,exports){ +}).call(this)}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":259,"./errors":349,"./native":352}],351:[function(require,module,exports){ var ERRORS = require('./errors') var NATIVE = require('./native') @@ -71882,7 +79077,7 @@ typeforce.TfPropertyTypeError = TfPropertyTypeError module.exports = typeforce -},{"./errors":326,"./extra":327,"./native":329}],329:[function(require,module,exports){ +},{"./errors":349,"./extra":350,"./native":352}],352:[function(require,module,exports){ var types = { Array: function (value) { return value !== null && value !== undefined && value.constructor === Array }, Boolean: function (value) { return typeof value === 'boolean' }, @@ -71905,7 +79100,7 @@ for (var typeName in types) { module.exports = types -},{}],330:[function(require,module,exports){ +},{}],353:[function(require,module,exports){ (function (root) { "use strict"; @@ -72328,28 +79523,38 @@ UChar.udata={ unorm.shimApplied = false; if (!String.prototype.normalize) { - String.prototype.normalize = function(form) { - var str = "" + this; - form = form === undefined ? "NFC" : form; - - if (form === "NFC") { - return unorm.nfc(str); - } else if (form === "NFD") { - return unorm.nfd(str); - } else if (form === "NFKC") { - return unorm.nfkc(str); - } else if (form === "NFKD") { - return unorm.nfkd(str); - } else { - throw new RangeError("Invalid normalization form: " + form); + Object.defineProperty(String.prototype, "normalize", { + enumerable: false, + configurable: true, + writable: true, + value: function normalize (/*form*/) { + + var str = "" + this; + var form = arguments[0] === undefined ? "NFC" : arguments[0]; + + if (this === null || this === undefined) { + throw new TypeError("Cannot call method on " + Object.prototype.toString.call(this)); + } + + if (form === "NFC") { + return unorm.nfc(str); + } else if (form === "NFD") { + return unorm.nfd(str); + } else if (form === "NFKC") { + return unorm.nfkc(str); + } else if (form === "NFKD") { + return unorm.nfkd(str); + } else { + throw new RangeError("Invalid normalization form: " + form); + } } - }; + }); unorm.shimApplied = true; } }(this)); -},{}],331:[function(require,module,exports){ +},{}],354:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -73083,7 +80288,7 @@ Url.prototype.parseHost = function() { if (host) this.hostname = host; }; -},{"./util":332,"punycode":219,"querystring":281}],332:[function(require,module,exports){ +},{"./util":355,"punycode":221,"querystring":302}],355:[function(require,module,exports){ 'use strict'; module.exports = { @@ -73101,8 +80306,8 @@ module.exports = { } }; -},{}],333:[function(require,module,exports){ -(function (global){ +},{}],356:[function(require,module,exports){ +(function (global){(function (){ /** * Module exports. @@ -73171,12 +80376,8 @@ function config (name) { return String(val).toLowerCase() === 'true'; } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],334:[function(require,module,exports){ -arguments[4][25][0].apply(exports,arguments) -},{"dup":25}],335:[function(require,module,exports){ -arguments[4][26][0].apply(exports,arguments) -},{"./support/isBuffer":334,"_process":250,"dup":26,"inherits":238}],336:[function(require,module,exports){ +}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],357:[function(require,module,exports){ 'use strict' var Buffer = require('safe-buffer').Buffer @@ -73260,15 +80461,15 @@ function encodingLength (number) { return ( number < 0xfd ? 1 - : number <= 0xffff ? 3 - : number <= 0xffffffff ? 5 - : 9 + : number <= 0xffff ? 3 + : number <= 0xffffffff ? 5 + : 9 ) } module.exports = { encode: encode, decode: decode, encodingLength: encodingLength } -},{"safe-buffer":298}],337:[function(require,module,exports){ +},{"safe-buffer":321}],358:[function(require,module,exports){ var bundleFn = arguments[3]; var sources = arguments[4]; var cache = arguments[5]; @@ -73350,8 +80551,8 @@ module.exports = function (fn, options) { return worker; }; -},{}],338:[function(require,module,exports){ -(function (Buffer){ +},{}],359:[function(require,module,exports){ +(function (Buffer){(function (){ var bs58check = require('bs58check') function decodeRaw (buffer, version) { @@ -73416,6 +80617,6 @@ module.exports = { encodeRaw: encodeRaw } -}).call(this,require("buffer").Buffer) -},{"bs58check":107,"buffer":111}]},{},[22])(22) +}).call(this)}).call(this,require("buffer").Buffer) +},{"bs58check":106,"buffer":110}]},{},[22])(22) }); diff --git a/build/blocktrail-sdk.min.js b/build/blocktrail-sdk.min.js index 6bbde98..b6675d1 100644 --- a/build/blocktrail-sdk.min.js +++ b/build/blocktrail-sdk.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).blocktrailSDK=e()}}(function(){var define,module,exports;return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[s]={exports:{}};t[s][0].call(u.exports,function(e){return i(t[s][1][e]||e)},u,u.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0})})})}),s.then(function(e){o.resolve({has_transactions:e})},function(e){o.reject(e)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){if(null===e.data)return e;var t=n.converter.convertAddressTxs(e);return t.data=t.data.filter(function(e){return!e.confirmations}),t}),r)},_.prototype.addressUnspentOutputs=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(t){return null===t.data?t:n.converter.convertAddressUnspentOutputs(t,e)}),r)},_.prototype.batchAddressUnspentOutputs=function(e,t,r){var n=this;return n.converter instanceof f?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBatchAddressUnspentOutputs(e)}),r):("function"==typeof t&&(r=t,t=null),w(n.dataClient.post("/address/unspent-outputs",t,{addresses:e}),r))},_.prototype.verifyAddress=function(e,t,r){return this.verifyMessage(e,e,t,r)},_.prototype.allBlocks=function(e,t){var r=this;return"function"==typeof e&&(t=e,e=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(e)).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlocks(e)}),t)},_.prototype.block=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertBlock(e.data)}),t)},_.prototype.blockLatest=function(e){var t=this;return w(t.dataClient.get(t.converter.getUrlForBlock("latest"),null).then(function(e){return t.converter.handleErrors(t,e)}).then(function(e){return null===e.data?e:t.converter.convertBlock(e.data)}),e)},_.prototype.blockTransactions=function(e,t,r){var n=this;return"function"==typeof t&&(r=t,t=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(e),n.converter.paginationParams(t)).then(function(e){return n.converter.handleErrors(n,e)}).then(function(e){return null===e.data?e:n.converter.convertBlockTxs(e)}),r)},_.prototype.transaction=function(e,t){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(t){return null===t.data?t:r.converter instanceof f?r.dataClient.get(r.converter.getUrlForRawTransaction(e),null).then(function(e){return[t,e.data]}).then(function(e){if(null!==e){var t=e[0],n=e[1];return r.converter.convertTx(t,n)}return e}):r.converter.convertTx(t)}),t)},_.prototype.transactions=function(e,t){var r=this;return r.converter instanceof f?w(r.dataClient.get(r.converter.getUrlForTransactions(e),null).then(function(e){return r.converter.handleErrors(r,e)}).then(function(e){return null===e.data?e:r.converter.convertTxs(e)}),t):w(r.dataClient.post("/transactions",null,e,null,!1),t)},_.prototype.allWebhooks=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/webhooks",e,t)},_.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.post("/webhook",null,{url:e,identifier:t},r)},_.prototype.getLegacyBitcoinCashAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromBase58Check(e,this.network),e}catch(e){}if((t=o.address.fromCashAddress(e,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(t.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(t.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(e){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var t,r;try{return o.address.fromCashAddress(e,this.network),e}catch(e){}if((t=o.address.fromBase58Check(e,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(t.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(t.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(e,t){return this.blocktrailClient.get("/webhook/"+e,null,t)},_.prototype.updateWebhook=function(e,t,r){return this.blocktrailClient.put("/webhook/"+e,null,t,r)},_.prototype.deleteWebhook=function(e,t){return this.blocktrailClient.delete("/webhook/"+e,null,null,t)},_.prototype.getWebhookEvents=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/webhook/"+e+"/events",t,r)},_.prototype.subscribeTransaction=function(e,t,r,n){var i={event_type:"transaction",transaction:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(e,t,r,n){var i={event_type:"address-transactions",address:t,confirmations:r};return this.blocktrailClient.post("/webhook/"+e+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(e,t,r){return t.forEach(function(e){e.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+e+"/events/batch",null,t,r)},_.prototype.subscribeNewBlocks=function(e,t){return this.blocktrailClient.post("/webhook/"+e+"/events",null,{event_type:"block"},t)},_.prototype.unsubscribeAddressTransactions=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/address-transactions/"+t,null,null,r)},_.prototype.unsubscribeTransaction=function(e,t,r){return this.blocktrailClient.delete("/webhook/"+e+"/transaction/"+t,null,null,r)},_.prototype.unsubscribeNewBlocks=function(e,t){return this.blocktrailClient.delete("/webhook/"+e+"/block",null,null,t)},_.prototype.getWalletLatestBlock=function(e){return this.blocktrailClient.get("/block/latest",null,e)},_.prototype.initWallet=function(e,t){var r=this;if("object"!=typeof e&&(e={identifier:arguments[0],passphrase:arguments[1]},t=arguments[2]),e.check_backup_key&&"string"!=typeof e.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(t);var a=e.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(t){var i=e.keyIndex||t.key_index;if(e.walletVersion=t.wallet_version,e.check_backup_key&&e.check_backup_key!==t.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(t.backup_public_key[0],r.network),f=n.mapValues(t.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),u=n.mapValues(t.primary_public_keys,function(e){return o.HDNode.fromBase58(e[0],r.network)}),h=new c(r,a,e.walletVersion,t.primary_mnemonic,t.encrypted_primary_seed,t.encrypted_secret,u,s,f,i,t.segwit||0,r.testnet,r.regtest,t.checksum,t.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.recoverySecret=t.recovery_secret,e.readOnly?h:h.unlock(e).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(e,t){var r=this;if("object"!=typeof e){var n=arguments[0],o=arguments[1],s=arguments[2];t=arguments[3],"function"==typeof s&&(t=s,s=null),e={identifier:n,passphrase:o,keyIndex:s}}e.walletVersion=e.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(t),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),e.keyIndex=e.keyIndex||0,e.passphrase=e.passphrase||e.password,delete e.password,!e.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;e.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):e.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(e).progress(function(e){a.notify(e)}).then(function(e){a.resolve(e)},function(e){a.reject(e)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(e){var t=this,r=i.defer();return i.nextTick(function(){if(!e.primaryMnemonic&&!e.primarySeed){if(!e.passphrase&&!e.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;e.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==e.storePrimaryMnemonic&&(e.storePrimaryMnemonic=!0)}e.backupMnemonic||e.backupPublicKey||(e.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),t.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),t.resolveBackupPublicKeyFromOptions(e).then(function(e){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),a=e.keyIndex,f=e.primaryPrivateKey.deriveHardened(a).neutered();return t.storeNewWalletV1(e.identifier,[f.toBase58(),"M/"+a+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storePrimaryMnemonic&&e.primaryMnemonic,s,a,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V1,e.primaryMnemonic,null,null,{keyIndex:f},e.backupPublicKey,u,a,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:e.passphrase,primarySeed:e.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:e.primaryMnemonic,backupMnemonic:e.backupMnemonic,blocktrailPublicKeys:u}]})})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)})}),r.promise},_.prototype._createNewWalletV2=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||y(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return function(e,t){return i.when(e).then(function(e){if(e.storeDataOnServer){if(!e.secret){if(!e.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");t(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),e.secret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),e.encryptedSecret=v.AES.encrypt(e.secret,e.passphrase).toString(v.format.OpenSSL)}t(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),e.encryptedPrimarySeed=v.AES.encrypt(e.primarySeed.toString("base64"),e.secret).toString(v.format.OpenSSL),e.recoverySecret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),t(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),e.recoveryEncryptedSecret=v.AES.encrypt(e.secret,e.recoverySecret).toString(v.format.OpenSSL)}return e})}(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),f=e.keyIndex;return t.storeNewWalletV2(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+f+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,f,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V2,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,u,f,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(e.encryptedPrimarySeed,"base64","hex")):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed.toString("hex")):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(e.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:e.encryptedSecret?a.entropyToMnemonic(b.convert(e.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:u}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype._createNewWalletV3=function(e){var t=this,r=i.defer();return e=n.merge({},e),E(e).then(function(e){if(e.passphrase=e.passphrase||e.password,delete e.password,e.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return e.primarySeed=e.primarySeed||y(c.WALLET_ENTROPY_BITS/8),e}).then(function(e){return t.produceEncryptedDataV3(e,r.notify.bind(r))}).then(function(e){return S(e,t.network,r.notify.bind(r))}).then(function(e){var i=o.crypto.hash160(e.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,t.network.pubKeyHash),f=e.keyIndex;return t.storeNewWalletV3(e.identifier,[e.primaryPublicKey.toBase58(),"M/"+f+"'"],[e.backupPublicKey.toBase58(),"M"],!!e.storeDataOnServer&&e.encryptedPrimarySeed,!!e.storeDataOnServer&&e.encryptedSecret,!!e.storeDataOnServer&&e.recoverySecret,s,f,e.support_secret||null,e.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var u=n.mapValues(i.blocktrail_public_keys,function(e){return o.HDNode.fromBase58(e[0],t.network)}),h=new c(t,e.identifier,c.WALLET_VERSION_V3,null,e.storeDataOnServer?e.encryptedPrimarySeed:null,e.storeDataOnServer?e.encryptedSecret:null,{keyIndex:e.primaryPublicKey},e.backupPublicKey,u,f,i.segwit||0,t.testnet,t.regtest,s,i.upgrade_key_index,e.useCashAddress,e.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:e.passphrase,primarySeed:e.primarySeed,secret:e.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:e.encryptedPrimarySeed?p.encode(e.encryptedPrimarySeed):null,backupSeed:e.backupSeed?a.entropyToMnemonic(e.backupSeed):null,recoveryEncryptedSecret:e.recoveryEncryptedSecret?p.encode(e.recoveryEncryptedSecret):null,encryptedSecret:e.encryptedSecret?p.encode(e.encryptedSecret):null,blocktrailPublicKeys:u}]})})}).then(function(e){r.resolve(e)},function(e){r.reject(e)}),r.promise},_.prototype.storeNewWalletV1=function(e,t,r,n,i,o,s){var a={identifier:e,wallet_version:c.WALLET_VERSION_V1,primary_public_key:t,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(e,t,r,n,i,o,s,a,f,u){var h={identifier:e,wallet_version:c.WALLET_VERSION_V2,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:f||null,segwit:u};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(e,t,r,n,i,o,s,a,f,u){var h={identifier:e,wallet_version:c.WALLET_VERSION_V3,primary_public_key:t,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:f||null,segwit:u};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e,null,t,r)},_.prototype.upgradeKeyIndex=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/upgrade",null,{key_index:t,primary_public_key:r},n)},_.prototype.getWalletBalance=function(e,t){return this.blocktrailClient.get("/wallet/"+e+"/balance",null,!0,t)},_.prototype.doWalletDiscovery=function(e,t,r){return this.blocktrailClient.get("/wallet/"+e+"/discovery",{gap:t},!0,r)},_.prototype.getNewDerivation=function(e,t,r){return this.blocktrailClient.post("/wallet/"+e+"/path",null,{path:t},r)},_.prototype.deleteWallet=function(e,t,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+e,{force:n},{checksum:t,signature:r},i)},_.prototype.coinSelection=function(e,t,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var f=i.defer();f.promise.spreadNodeify(a);var u={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(u.forcefee=s.forcefee),f.resolve(this.blocktrailClient.post("/wallet/"+e+"/coin-selection",u,t).then(function(e){return[e.utxos,e.fee,e.change,e]},function(e){if(e.message.match(/too low to pay the fee/))throw b.WalletFeeError(e);throw e})),f.promise},_.prototype.feePerKB=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.blocktrailClient.get("/fee-per-kb")),t.promise},_.prototype.sendTransaction=function(e,t,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof t?c.raw_transaction=t:"object"==typeof t&&Object.keys(t).map(function(e){c[e]=t[e]});var f={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(f.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(f.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(e){return String.fromCharCode(e)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+e+"/send",f,c,a)},_.prototype.setupWalletWebhook=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/webhook",null,{url:r,identifier:t},n)},_.prototype.deleteWalletWebhook=function(e,t,r){return this.blocktrailClient.delete("/wallet/"+e+"/webhook/"+t,null,null,r)},_.prototype.walletTransactions=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/transactions",t,!0,r)},_.prototype.walletAddresses=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/addresses",t,!0,r)},_.prototype.labelWalletAddress=function(e,t,r,n){return this.blocktrailClient.post("/wallet/"+e+"/address/"+t+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(e,t,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:t?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+e+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(e,t,r){return"function"==typeof t&&(r=t,t=null),this.blocktrailClient.get("/wallet/"+e+"/utxos",t,!0,r)},_.prototype.allWallets=function(e,t){return"function"==typeof e&&(t=e,e=null),this.blocktrailClient.get("/wallets",e,!0,t)},_.prototype.verifyMessage=function(e,t,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(t,this.network.messagePrefix,e,new Buffer(r,"base64"));o.resolve(a)}catch(e){o.reject(e)}return o.promise},_.prototype.faucetWithdrawl=function(e,t,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:e,amount:t},r)},_.prototype.sendRawTransaction=function(e,t){return this.blocktrailClient.post("/send-raw-tx",null,e,t)},_.prototype.price=function(e){return this.blocktrailClient.get("/price",null,!1,e)},t.exports=_}).call(this,e("_process"),e("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:250,bip39:34,"bitcoinjs-lib":49,"bitcoinjs-message":78,buffer:111,"crypto-js":158,lodash:241,q:278,randombytes:282}],2:[function(e,t,r){var n=function(){};n.prototype.paginationParams=function(e){return e},n.prototype.getUrlForBlock=function(e){return"/block/"+e},n.prototype.getUrlForTransaction=function(e){return"/transaction/"+e},n.prototype.getUrlForBlockTransaction=function(e){return"/block/"+e+"/transactions"},n.prototype.getUrlForAddress=function(e){return"/address/"+e},n.prototype.getUrlForAddressTransactions=function(e){return"/address/"+e+"/transactions"},n.prototype.getUrlForAddressUnspent=function(e){return"/address/"+e+"/unspent-outputs"},n.prototype.convertBlock=function(e){return e},n.prototype.convertBlockTxs=function(e){return e},n.prototype.convertTx=function(e){return e},n.prototype.convertAddressTxs=function(e){return e},n.prototype.convertAddress=function(e){return e},n.prototype.convertAddressUnspentOutputs=function(e){return e},n.prototype.convertBatchAddressUnspentOutputs=function(e){return e},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(e,t){return t},t.exports=n},{}],3:[function(e,t,r){(function(Buffer){var r=e("util"),n=e("assert"),i=e("crypto-js"),o=e("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(e,t,r){return new Buffer(e,t).toString(r)},c=function(e,t){return function(e,t){var r=o.mnemonicToEntropy(e),n=a(r,"hex","base64"),c=i.AES.decrypt(n,t).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(e,t).toString(i.enc.Utf8)},f=function(e,t){return a(c(e,t),"base64","hex")},u=function(e,t){var r=i.AES.encrypt(e,t).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(e,t){return new Buffer(f(e,t),"hex")},s.aesDecryptMnemonicToSeedHex=f,s.aesEncryptSeedToMnemonic=u,s.aesEncryptSeedHexToMnemonic=function(e,t){return u(a(e,"hex","base64"),t)},s.aesEncryptSeedBufferToMnemonic=function(e,t){return u(e.toString("base64"),t)},s.V3Crypt={KeyDerivation:e("./keyderivation"),Encryption:e("./encryption"),EncryptionMnemonic:e("./encryption_mnemonic")},s.toSatoshi=function(e){return parseInt((e*s.COIN).toFixed(0),10)},s.toBTC=function(e){return(e/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(e){e.spreadNodeify&&e.spreadDone||(e.spreadDone=function(t,r,n){return e(t).spreadDone(r,n)},e.makePromise.prototype.spreadDone=function(e,t){return this.all().done(function(t){return e.apply(void 0,t)},t)},e.spreadNodeify=function(t,r){return e(t).spreadNodeify(r)},e.makePromise.prototype.spreadNodeify=function(t){if(!t)return this;this.then(function(r){e.nextTick(function(){t.apply(void 0,[null].concat(r))})},function(r){e.nextTick(function(){t(r)})})})},Error.extend=function(e,t){n(e,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=e,this.code=t,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var e,t=0,r=this.length-1;t<=r;++t,--r)e=this[t],this[t]=this[r],this[r]=e;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(e("q")),t.exports=s}).call(this,e("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:23,bip39:34,buffer:111,"crypto-js":158,q:278,util:335}],4:[function(e,t,r){var n=e("./wallet"),i=e("./blocktrail"),o=e("bitcoinjs-lib"),s=function(e,t){this.network=e,this.useNewCashAddr=t};function a(e,t,r){var n;try{n=o.address.toOutputScript(e,t,r)}catch(e){n=null}return n}function c(e){var t;try{t=o.script.toASM(e)}catch(e){t=null}return t}function f(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function u(e){var t;try{t=o.script.classifyOutput(e)}catch(e){t=null}return t}function h(e){switch(e){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+e)}}function l(e){return new Date(1e3*e).toISOString().replace(/\.000Z$/,"+0000")}function d(e){return e&&1===e.length?e[0]:e}function p(e){var t,r={};for(var n in r.size=e.vsize,r.hash=e.hash,r.block_height=e.block_height,r.time=r.block_time=l(e.block_time),r.block_hash=e.block_hash,r.confirmations=e.confirmations,r.is_coinbase=e.is_coinbase,t=r.is_coinbase?e.outputs[0].value-e.fee:e.inputs_value,r.total_input_value=t,r.total_output_value=e.outputs.reduce(function(e,t){return e+t.value},0),r.total_fee=e.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,e.inputs){var s,a,c,u,p=e.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&e)&&(r+=t),0!==(e>>>=1);)t+=t;return r});var i={chunkSize:4,paddingDummy:129},o=function(e){if(e[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-e.length%i.chunkSize)};i.encode=function(e){r(e instanceof Buffer,"Data must be provided as a Buffer");var t=o(e),i=n.entropyToMnemonic(t+e.toString("hex"));try{n.mnemonicToEntropy(i)}catch(e){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(e){r("string"==typeof e,"Mnemonic must be provided as a string");for(var t=new Buffer(n.mnemonicToEntropy(e),"hex"),i=0;t[i]===this.paddingDummy;)i++;var s=t.slice(i,t.length);if(o(s)!==t.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},t.exports=i}).call(this,e("buffer").Buffer)},{assert:23,bip39:34,buffer:111}],7:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(e,t,i){if(i=i||this.defaultIterations,r(e instanceof Buffer,"Password must be provided as a Buffer"),r(t instanceof Buffer,"Salt must be provided as a Buffer"),r(t.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),t.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(e,t,i,this.keySizeBits/8)}};t.exports=i}).call(this,e("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:23,buffer:111}],8:[function(e,t,r){(function(Buffer){t.exports={digest:function(e,t,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(e,t,r,n).buffer)}}}).call(this,e("buffer").Buffer)},{buffer:111}],9:[function(e,t,r){t.exports={VERSION:"3.7.22"}},{}],10:[function(e,t,r){(function(r){var n=e("./blocktrail"),i=e("lodash"),o=e("url"),s=e("querystring"),a=e("q"),c=e("create-hash"),f=e("superagent"),u=e("superagent-http-signature/index-hmac-only"),h=e("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(e){this.https=e.https,this.host=e.host,this.endpoint=e.endpoint,this.auth=e.auth,this.port=e.port,this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.contentMd5=void 0===e.contentMd5||e.contentMd5,this.params=i.defaults({},e.params),this.headers=i.defaults({},e.headers)}p.qs=function(e){var t=[],r=Object.keys(e);return r.sort(),r.forEach(function(r){var n={};n[r]=e[r],t.push(s.stringify(n))}),t.join("&")},p.prototype.request=function(e,t,r,n,s){this.deferred=a.defer(),this.callback=s||d;var f=o.parse(t,!0),u=p.qs(i.defaults({},r||{},f.query||{},this.params||{}));this.path="".concat(this.endpoint,f.pathname),u&&(this.path=this.path.concat("?",u)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===e||"DELETE"===e?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",e,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:e,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(e){var t=this,r=e.method,n=!1;"http-signature"===e.auth&&(n=!0,delete e.auth);var o=(t.https?"https://":"http://")+e.hostname+e.path,s=f(r,o);if(!t.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(t.payload),i.forEach(e.headers,function(e,t){s.set(t,e)}),n){if(!t.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return t.deferred.reject(a),t.callback(a)}s.use(u({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:t.apiSecret,keyId:t.apiKey}))}return s.end(function(e,r){var n;if(e){var i=p.handleFailure(e.response&&e.response.body,e.status);return t.deferred.reject(i),t.callback(i,e.response&&e.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!e&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(t){e=t}return n||(n=r.text),e||200===r.status||(e=p.handleFailure(r.text,r.statusCode)),e?t.deferred.reject(e):t.deferred.resolve(n),t.callback(e,n)}),t.deferred},p.handleFailure=function(e,t){var r,n;if("object"==typeof e)r=e;else try{r=JSON.parse(e)}catch(e){}if(r){var i=r.msg||"";i||429===t&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(e){"msg"!==e&&(n[e]=r[e])})}else n=e?new Error(e):new Error("Unknown Server Error");return t&&(n.statusCode=t),p.convertError(n)},p.convertError=function(e){return e.requires_2fa&&!e.requires_email_2fa?new n.WalletMissing2FAError:e.requires_email_2fa?new n.WalletMissingEmail2FAError:e.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:e},t.exports=p}).call(this,e("_process"))},{"./blocktrail":3,_process:250,"create-hash":119,debug:184,lodash:241,q:278,querystring:281,superagent:320,"superagent-http-signature/index-hmac-only":316,url:331}],11:[function(e,t,r){var n=e("lodash"),i=e("./request"),o=e("q"),s=function(t){this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.https=t.https,this.host=t.host,this.port=t.port,this.endpoint=t.endpoint,this.btccom=!!t.btccom,void 0!==t.throttleRequestsTimeout?this.throttleRequestsTimeout=t.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+e("./pkginfo").VERSION},t.defaultHeaders))};s.prototype.throttle=function(){var e=this,t=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return t.resolve(),o.delay(e.throttleRequestsTimeout)}):(this.nextRequest=o.delay(e.throttleRequestsTimeout),t.resolve()):t.resolve(),t.promise},s.prototype.create_request=function(e){return e=n.defaults({},e,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(e)},s.prototype.post=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",e,t,r,n)})},s.prototype.put=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",e,t,r,n)})},s.prototype.get=function(e,t,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",e,t,null,n)})},s.prototype.delete=function(e,t,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",e,t,r,n)})},t.exports=function(e){return new s(e)}},{"./pkginfo":9,"./request":10,lodash:241,q:278}],12:[function(e,t,r){var n=e("../api_client"),i=e("lodash"),o=e("q"),s=e("async"),a=function(e){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,e);var t=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=t.network,this.settings.testnet=t.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(e,t){switch(e.toLowerCase()){case"btc":case"bitcoin":return t?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return t?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+e)}},a.prototype.setPaginationLimit=function(e){this.settings.paginationLimit=e},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(e){return Math.max(e.optimal,e.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(e){var t=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:t.settings.paginationLimit};t.client.batchAddressUnspentOutputs(e,o).then(function(e){i=i.concat(e.data),n++,r()},function(e){console.log("error happened:",e),r(e)})},function(){return null},function(e){e&&console.log("complete, but with errors",e.message);var t={};i.forEach(function(e){var r=e.address;void 0===t[r]&&(t[r]=[]),t[r].push({hash:e.hash,index:e.index,value:e.value,script_hex:e.script_hex})}),r.resolve(t)}),r.promise},a.prototype.batchAddressHasTransactions=function(e){return this.client.batchAddressHasTransactions(e).then(function(e){return e.has_transactions})},t.exports=a},{"../api_client":1,async:27,lodash:241,q:278}],13:[function(e,t,r){var n=e("../blocktrail"),i=e("superagent"),o=e("lodash"),s=e("q"),a=function(e){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===e.host&&e.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,e),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(e){var t=s.defer(),r={addrs:e.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.txid,index:e.vout,value:n.toSatoshi(e.amount),script_hex:e.scriptPubKey,confirmations:e.confirmations})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={addrs:e.join(",")};return this.postEndpoint("addrs/txs",t).then(function(e){return e.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(e){return-1===e[4]?1e5:e[4]<1e-5?1e3:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("tx/send",{rawtx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=s.defer();return i.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=s.defer();return i.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,lodash:241,q:278,superagent:320}],14:[function(e,t,r){e("../blocktrail");var n=e("superagent"),i=e("lodash"),o=e("q"),s=e("bitcoinjs-lib"),a=function(e){if(!("host"in e))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,e)};a.prototype.getBatchUnspentOutputs=function(e){var t=o.defer(),r={address:e};return this.postEndpoint("addressListUnspent",r).then(function(e){var r={};e.forEach(function(e){var t=e.address;void 0===r[t]&&(r[t]=[]),r[t].push({hash:e.tx_hash,index:e.tx_pos,value:e.value,script_hex:s.address.toOutputScript(t,s.networks.bitcoincash),confirmations:1})}),t.resolve(r)},function(e){t.reject(e)}),t.promise},a.prototype.batchAddressHasTransactions=function(e){var t={address:e};return this.postEndpoint("addressHasTransactions",t).then(function(e){return e.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(e){return-1===e[4]?1e5:parseInt(1e8*e[4],10)})},a.prototype.sendTx=function(e){return this.postEndpoint("publishTx",{tx:e})},a.prototype.getEndpoint=function(e){return this.getRequest(this.settings.host+"/"+e)},a.prototype.postEndpoint=function(e,t){return this.postRequest(this.settings.host+"/"+e,t)},a.prototype.getRequest=function(e){var t=o.defer();return n.get(e).end(function(e,r){if(e)t.reject(e);else{if(!r.ok)return t.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return t.resolve(r.body);try{var n=JSON.parse(r.text);return t.resolve(n)}catch(r){return t.reject(e)}}}),t.promise},a.prototype.postRequest=function(e,t){var r=o.defer();return n.post(e).send(t).set("Content-Type","application/json").end(function(e,t){if(e)r.reject(e);else{if(!t.ok)return r.reject(t.text);try{var n=JSON.parse(t.text);return r.resolve(n)}catch(n){return t.headers["content-type"].indexOf("application/json")>=0?r.reject(e):r.resolve(t.body)}}}),r.promise},t.exports=a},{"../blocktrail":3,"bitcoinjs-lib":49,lodash:241,q:278,superagent:320}],15:[function(e,t,r){(function(Buffer){var r=e("assert"),n=e("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(e){return e?33:65},getLengthForScriptPush:function(e){if(e<75)return 1;if(e<=255)return 2;if(e<=65535)return 3;if(e<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(e){if(e<253)return 1;var t;if(e<65535)t=2;else if(e<4294967295)t=4;else{if(!(e<0x10000000000000000))throw new Error("Size of varint too large");t=8}return 1+t},estimateMultisigStackSize:function(e,t){var r,n=[0];for(r=0;r0&&(s.map(function(e){f+=a.getLengthForVarInt(e)+e}),f+=a.getLengthForVarInt(s.length)),[c,f]},estimateInputFromScripts:function(e,t,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(e)){var c=n.script.multisig.output.decode(e);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(e)){var f=n.script.pubKey.output.decode(e);a=this.estimateP2PKStackSize(f)[0]}else{if(!n.script.pubKeyHash.output.check(e))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,t,i)},estimateUtxo:function(e,t){var r=Buffer.from(e.scriptpubkey_hex,"hex"),i=null,o=null;e.redeem_script&&("string"==typeof e.redeem_script?i=Buffer.from(e.redeem_script,"hex"):e.redeem_script instanceof Buffer&&(i=e.redeem_script)),e.witness_script&&("string"==typeof e.witness_script?o=Buffer.from(e.witness_script,"hex"):e.witness_script instanceof Buffer&&(o=e.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var f=n.script.types,u=[f.MULTISIG,f.P2PKH,f.P2PK],h=n.script.classifyOutput(a);if(-1===u.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,t);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(e,t){var r=0,n=0;return e.map(function(e){var o=i.estimateUtxo(e);r+=40+o.scriptSig,t&&(n+=o.witness)}),t&&n>0&&(r+=2+n),r},calculateOutputsSize:function(e){var t=0;return e.map(function(e){var r=i.getLengthForVarInt(e.script.length);t+=8+r+e.script.length}),t},estimateTxWeight:function(e,t){var r=i.calculateOutputsSize(e.outs);return 3*(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!1)+i.getLengthForVarInt(e.outs.length)+r+4)+(4+i.getLengthForVarInt(t.length)+this.estimateInputsSize(t,!0)+i.getLengthForVarInt(e.outs.length)+r+4)},estimateTxVsize:function(e,t){return parseInt(Math.ceil(i.estimateTxWeight(e,t)/4),10)}};t.exports=i}).call(this,e("buffer").Buffer)},{assert:23,"bitcoinjs-lib":49,buffer:111}],16:[function(e,t,r){var n=e("lodash"),i=e("q"),o=e("async"),s=function(e,t){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,t),this.dataClient=e};s.prototype.getUTXOs=function(e){var t=this,r={},s=i.defer();return o.eachSeries(n.chunk(e,t.settings.batchChunkSize),function(e,i){t.settings.logging&&console.log("checking batch of "+e.length+" addresses for UTXOs",e.join(",")),t.dataClient.getBatchUnspentOutputs(e).done(function(e){n.each(e,function(e,t){e.length>0&&(r[t]=e)}),i()},function(e){i(e)})},function(e){e&&console.log("error encountered",e),s.resolve(r)}),s.promise},t.exports=s},{async:27,lodash:241,q:278}],17:[function(e,t,r){(function(e){var r=!!e.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),t.exports=function(){return r}}).call(this,e("_process"))},{_process:250}],18:[function(e,t,r){(function(Buffer){var r=e("lodash"),n=e("assert"),i=e("q"),o=e("async"),s=e("bitcoinjs-lib"),a=e("bitcoinjs-message"),c=e("./blocktrail"),f=e("crypto-js"),u=e("./encryption"),h=e("./encryption_mnemonic"),l=e("./size_estimation"),d=e("bip39"),p="sign",b=function(e,t,i,o,a,c,f,u,h,l,d,p,y,v,m,g,w){this.sdk=e,this.identifier=t,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!g,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(u instanceof s.HDNode),n(r.every(f,function(e){return e instanceof s.HDNode})),n(r.every(h,function(e){return e instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=u,this.blocktrailPublicKeys=h,this.primaryPublicKeys=f,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=m,this.secret=null,this.seedHex=null};function y(e,t){var r,n;try{r=s.address.fromBech32(e,t),n=null}catch(e){n=e}if(!n&&r.prefix!==t.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function v(e,t){var r,n;e=e.toLowerCase();try{r=s.address.fromCashAddress(e),n=null}catch(e){n=e}if(n)try{r=s.address.fromCashAddress(t.cashAddrPrefix+":"+e),n=null}catch(e){n=e}if(!n&&r.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix");return[n,r]}function m(e,t){var r,n;try{r=s.address.fromBase58Check(e),n=null}catch(e){n=e}if(!n&&r.version!==t.pubKeyHash&&r.version!==t.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(e,t){var n=this,o=i.defer();return o.promise.nodeify(t),e=r.merge({},e),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(e);case b.WALLET_VERSION_V2:return n.unlockV2(e);case b.WALLET_VERSION_V3:return n.unlockV3(e);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(e){n.primaryPrivateKey=e;var t=n.primaryPrivateKey.getAddress();if(t!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+t+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(e){o.resolve(e)},function(e){o.reject(e)}),o.promise},b.prototype.unlockV1=function(e){var t=this;return e.primaryMnemonic=void 0!==e.primaryMnemonic?e.primaryMnemonic:t.primaryMnemonic,e.secretMnemonic=void 0!==e.secretMnemonic?e.secretMnemonic:t.secretMnemonic,t.sdk.resolvePrimaryPrivateKeyFromOptions(e).then(function(e){return t.primarySeed=e.primarySeed,e.primaryPrivateKey})},b.prototype.unlockV2=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(e.primarySeed)r.primarySeed=e.primarySeed;else if(e.secret)try{if(r.primarySeed=new Buffer(f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(f.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");e.passphrase=e.passphrase||e.password;try{if(r.secret=f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedSecret),e.passphrase).toString(f.enc.Utf8),!r.secret.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(f.AES.decrypt(f.format.OpenSSL.parse(e.encryptedPrimarySeed),r.secret).toString(f.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(e){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),n.resolve(i.fcall(function(){return i.when().then(function(){if(e.encryptedPrimarySeed=void 0!==e.encryptedPrimarySeed?e.encryptedPrimarySeed:r.encryptedPrimarySeed,e.encryptedSecret=void 0!==e.encryptedSecret?e.encryptedSecret:r.encryptedSecret,e.secret&&(r.secret=e.secret),e.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!e.primarySeed){if(e.secret)return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(e.passphrase&&e.password)throw new c.WalletCreateError("Can't specify passphrase and password");return e.passphrase=e.passphrase||e.password,delete e.password,r.sdk.promisedDecrypt(new Buffer(e.encryptedSecret,"base64"),new Buffer(e.passphrase)).then(function(e){r.secret=e},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(e.encryptedPrimarySeed,"base64"),r.secret).then(function(e){r.primarySeed=e},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=e.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(e,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(e,n.notify.bind(n)):void 0}).then(function(e){n.resolve(e)},function(e){n.reject(e)}),n.promise},b.prototype._upgradeV2ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(e,t){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:e,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,t||function(){}).then(function(e){return r.recoveryEncryptedSecret=e.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:e.encryptedPrimarySeed.toString("base64"),encrypted_secret:e.encryptedSecret.toString("base64"),recovery_secret:e.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=e.secret,r.encryptedPrimarySeed=e.encryptedPrimarySeed,r.encryptedSecret=e.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(e){var t=this;return i.when(null).then(function(){if(t.walletVersion===b.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(t.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!t.secret)throw new c.WalletLockedError("No secret");var r,n;if(t.walletVersion===b.WALLET_VERSION_V2)r=f.AES.encrypt(t.secret,e).toString(f.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof e)e=new Buffer(e);else if(!(e instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=u.encrypt(t.secret,e),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(e,t){var r=this,n=i.defer();return n.promise.nodeify(t),i.fcall(function(){return r.doPasswordChange(e).then(function(e){var t=e[0],n=e[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:t}).then(function(){return r.encryptedSecret=t,{encryptedSecret:n}})}).then(function(e){n.resolve(e)},function(e){n.reject(e)})}),n.promise},b.prototype.getAddressByPath=function(e){return this.getWalletScriptByPath(e).address},b.prototype.getRedeemScriptByPath=function(e){return this.getWalletScriptByPath(e).redeemScript},b.prototype.getWalletScriptByPath=function(e){var t,r,n=this.getPrimaryPublicKey(e),i=this.getBlocktrailPublicKey(e),o=b.deriveByPath(this.backupPublicKey,e.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),f=parseInt(e.split("/")[2]);"bitcoincash"!==this.network&&f===b.CHAIN_BTC_SEGWIT?(t=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(t))):(t=null,r=c);var u=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:t,redeemScript:r,scriptPubKey:u,address:s.address.fromOutputScript(u,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[t]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+t+") is unknown to us");this.primaryPublicKeys[t]=b.deriveByPath(this.primaryPrivateKey,"M/"+t+"'","m")}var r=this.primaryPublicKeys[t];return b.deriveByPath(r,e,"M/"+t+"'")},b.prototype.getBlocktrailPublicKey=function(e){var t=(e=e.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[t])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+t+") is unknown to us");var r=this.blocktrailPublicKeys[t];return b.deriveByPath(r,e,"M/"+t+"'")},b.prototype.upgradeKeyIndex=function(e,t){var n=this,o=i.defer();if(o.promise.nodeify(t),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(e).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,e,[a.toBase58(),"M/"+e+"'"]).then(function(t){return n.keyIndex=e,r.forEach(t.blocktrail_public_keys,function(e,t){n.blocktrailPublicKeys[t]=s.HDNode.fromBase58(e[0],n.network)}),n.primaryPublicKeys[e]=a,!0})),o.promise},b.prototype.getNewAddress=function(e,t){var r=this;"function"==typeof e&&(t=e,e=null);var n=i.defer();if(n.promise.spreadNodeify(t),e!==parseInt(e,10)){if(void 0!==e&&null!==e)return n.reject(new Error("Invalid chain index")),n.promise;e=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+e).then(function(e){var t,n=e.path,i=e.address;try{t=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type&&(r.bypassNewAddressCheck=!1)}catch(t){throw new c.WalletAddressError("Failed to decode address ["+e.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(e.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===t.type){var a;try{a=r.decodeAddress(o)}catch(e){throw new c.WalletAddressError("Error while verifying address from server ["+e.message+"]")}if(a.decoded.hash.toString("hex")!==t.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var f=a.decoded.version===s.script.types.P2PKH&&t.decoded.version===r.network.pubKeyHash,u=a.decoded.version===s.script.types.P2SH&&t.decoded.version===r.network.scriptHash;if(!f&&!u)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+e.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier).then(function(e){return[e.confirmed,e.unconfirmed]})),t.promise},b.prototype.getInfo=function(e){var t=i.defer();return t.promise.spreadNodeify(e),t.resolve(this.sdk.getWalletBalance(this.identifier)),t.promise},b.prototype.deleteWallet=function(e,t){"function"==typeof e&&(t=e,e=!1);var r=i.defer();if(r.promise.nodeify(t),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,e).then(function(e){return e.deleted})),r.promise},b.prototype.pay=function(e,t,r,n,o,s,a,f){var u=this;"function"==typeof t?(f=t,t=null):"function"==typeof r?(f=r,r=!1):"function"==typeof n?(f=n,n=!0):"function"==typeof o?(f=o,o=null):"function"==typeof s?(f=s,s=null):"function"==typeof a&&(f=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(f),u.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),u.buildTransaction(e,t,r,n,o,a).then(function(e){return e},function(e){l.reject(e)},function(e){l.notify(e)}).spread(function(e,t){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:e.toHex(),base_transaction:e.__toBuffer(null,null,!1).toString("hex")};return u.sendTransaction(r,t.map(function(e){return e.path}),h,s,a.prioboost,a).then(function(e){if(l.notify(b.PAY_PROGRESS_DONE),e&&e.complete&&"false"!==e.complete)return e.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(e){throw e}).then(function(e){l.resolve(e)},function(e){l.reject(e)})}),l.promise)},b.prototype.decodeAddress=function(e){return b.getAddressAndType(e,this.network,this.useNewCashAddr)},b.getAddressAndType=function(e,t,r){var n,i,o;function a(r,s){var a=r(e,t);null===a[0]?(n=a[1],i=s):o=a[0]}if(t!==s.networks.bitcoin&&t!==s.networks.testnet&&t!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in t&&r&&a(v,"cashaddr"),n||a(m,"base58"),n)return{address:e,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},b.convertPayToOutputs=function(e,t,r){var n,i=[];if(Array.isArray(e))n=function(e,t,r){if("object"!=typeof t)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(t);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=t.scriptPubKey,r.value=t.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=t.address,r.value=t.value;else{if(2!==n.length||2!==t.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=t[0],r.value=t[1]}};else{if("object"!=typeof e)throw new Error("Invalid input");n=function(e,t,r){if(r.address=e.trim(),r.value=t,r.address===b.OP_RETURN){var n=Buffer.isBuffer(t)?t:new Buffer(t,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(e).forEach(function(o){var a={};if(n(o,e[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var f=b.getAddressAndType(a.address,t,r);a.scriptPubKey=s.address.toOutputScript(f.address,t,r).toString("hex"),delete a.address}catch(e){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+e.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(e,t,n,a,f,u,h){var l=this;"function"==typeof t?(h=t,t=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof f?(h=f,f=null):"function"==typeof u&&(h=u,u={}),a=void 0===a||a,f=f||b.FEE_STRATEGY_OPTIMAL,u=u||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(e,l.network,l.useNewCashAddr)}catch(e){return d.reject(e),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,f,u).spread(function(e,n,u){var d,y,v=[],m=i.defer();return o.waterfall([function(t){var r=e.map(function(e){return e.value}).reduce(function(e,t){return e+t})-h.map(function(e){return e.value}).reduce(function(e,t){return e+t})-n;if(r>2*c.DUST&&r!==u)return t(new c.WalletFeeError("the amount of change ("+u+") suggested by the coin selection seems incorrect ("+r+")"));t()},function(e){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),e()},function(t){var r;for(r=0;r0)if(u<=c.DUST)u=0;else if(!t)return m.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return e(r);t=n,e()});e()},function(e){if(u>0){var n={scriptPubKey:s.address.toOutputScript(t,l.network,l.useNewCashAddr),value:u};a?v.splice(r.random(0,v.length),0,n):v.push(n)}e()},function(e){v.forEach(function(e){y.addOutput(e.scriptPubKey,e.value)}),e()},function(t){var r,n,i,o,a;for(m.notify(b.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return t(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}t()}],function(t){t?m.reject(new c.WalletSendError(t)):m.resolve([d,e])}),m.promise}))}),d.promise},b.prototype.coinSelection=function(e,t,r,n,o,s){var a;"function"==typeof t?(s=t,t=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),t=void 0===t||t,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(e,this.network,this.useNewCashAddr)}catch(e){var c=i.defer();return c.promise.nodeify(s),c.reject(e),c.promise}return this.sdk.coinSelection(this.identifier,a,t,r,n,o,s)},b.prototype.sendTransaction=function(e,t,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var f=i.defer();return f.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,e,t,r,n,o,s).then(function(e){f.resolve(e)},function(e){e.requires_2fa?f.reject(new c.WalletMissing2FAError):e.message.match(/Invalid two_factor_token/)?f.reject(new c.WalletInvalid2FAError):f.reject(e)}),f.promise},b.prototype.setupWebhook=function(e,t,r){return"function"==typeof t&&(r=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,t,e,r)},b.prototype.deleteWebhook=function(e,t){return"function"==typeof e&&(t=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,e,t)},b.prototype.transactions=function(e,t){return this.sdk.walletTransactions(this.identifier,e,t)},b.prototype.maxSpendable=function(e,t,r,n){return"function"==typeof e?(n=e,e=!1):"function"==typeof t?(n=t,t=null):"function"==typeof r&&(n=r,r={}),"object"==typeof e?(r=e,e=!1):"object"==typeof t&&(r=t,t=null),void 0!==(r=r||{}).allowZeroConf&&(e=r.allowZeroConf),void 0!==r.feeStrategy&&(t=r.feeStrategy),t=t||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,e,t,r,n)},b.prototype.addresses=function(e,t){return this.sdk.walletAddresses(this.identifier,e,t)},b.prototype.labelAddress=function(e,t,r){return this.sdk.labelWalletAddress(this.identifier,e,t,r)},b.prototype.utxos=function(e,t){return this.sdk.walletUTXOs(this.identifier,e,t)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(e){return e.sort(function(e,t){return e.toString("hex").localeCompare(t.toString("hex"))}),e},b.estimateIncompleteTxFee=function(e,t){var r=b.estimateIncompleteTxSize(e),n=r/1e3,i=Math.ceil(r/1e3);return t?parseInt(n*t,10):parseInt(i*c.BASE_FEE,10)},b.estimateVsizeFee=function(e,t,r){var n=l.estimateTxVsize(e,t),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},b.estimateIncompleteTxSize=function(e){var t=16;return t+=34*e.outs.length,e.ins.forEach(function(e){var r=e.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var f=s.script.decompile(a),u=f[0];if(u===s.opcodes.OP_0||us.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=f[a.chunks.length-2];if(u===s.opcodes.OP_0||us.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=u-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+e)+" using blocktrail key index: "+r+", chain: "+c),f.notify({message:"generating addresses "+p+" -> "+(p+e),increment:e,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,e,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+e+" addresses..."),f.notify({message:"starting fund discovery for "+e+" addresses",increment:e,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(u.keys(c)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(u.keys(c)).then(function(h){if(t.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p=0;f--)if(u[f]!==h[f])return!1;for(f=u.length-1;f>=0;f--)if(c=u[f],!m(e[c],t[c],r,n))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function g(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function w(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function _(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&y(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!e&&o.isError(i),c=!e&&i&&!r;if((a&&s&&w(i,r)||c)&&y(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(i,r)||!e&&i)throw i}h.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=p(b((t=this).actual),128)+" "+t.operator+" "+p(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=d(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},o.inherits(h.AssertionError,Error),h.fail=y,h.ok=v,h.equal=function(e,t,r){e!=t&&y(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&y(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){m(e,t,!1)||y(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){m(e,t,!0)||y(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){m(e,t,!1)&&y(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){m(t,r,!0)&&y(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&y(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&y(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){_(!0,e,t,r)},h.doesNotThrow=function(e,t,r){_(!1,e,t,r)},h.ifError=function(e){if(e)throw e};var E=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":26}],24:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],25:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],26:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(t)?n.showHidden=t:t&&r._extend(n,t),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),u(n,e,n.depth)}function c(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function f(e,t){return e}function u(e,t,n){if(e.customInspect&&t&&S(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return v(i)||(i=u(e,i,n)),i}var o=function(e,t){if(m(t))return e.stylize("undefined","undefined");if(v(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(b(t))return e.stylize("null","null")}(e,t);if(o)return o;var s=Object.keys(t),a=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),E(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(t);if(0===s.length){if(S(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(g(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(_(t))return e.stylize(Date.prototype.toString.call(t),"date");if(E(t))return h(t)}var f,w="",k=!1,A=["{","}"];(d(t)&&(k=!0,A=["[","]"]),S(t))&&(w=" [Function"+(t.name?": "+t.name:"")+"]");return g(t)&&(w=" "+RegExp.prototype.toString.call(t)),_(t)&&(w=" "+Date.prototype.toUTCString.call(t)),E(t)&&(w=" "+h(t)),0!==s.length||k&&0!=t.length?n<0?g(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=k?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,w,A)):A[0]+w+A[1]}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),I(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=b(r)?u(e,c.value,null):u(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n")):a=e.stylize("[Circular]","special")),m(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function b(e){return null===e}function y(e){return"number"==typeof e}function v(e){return"string"==typeof e}function m(e){return void 0===e}function g(e){return w(e)&&"[object RegExp]"===k(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===k(e)}function E(e){return w(e)&&("[object Error]"===k(e)||e instanceof Error)}function S(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function A(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(m(o)&&(o=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=t.pid;s[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else s[e]=function(){};return s[e]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(e){return null==e},r.isNumber=y,r.isString=v,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=m,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){var e,t;console.log("%s - %s",(e=new Date,t=[A(e.getHours()),A(e.getMinutes()),A(e.getSeconds())].join(":"),[e.getDate(),x[e.getMonth()],t].join(" ")),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":25,_process:250,inherits:24}],27:[function(e,t,r){(function(e,r){!function(){var n,i,o={};function s(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(e){return"[object Array]"===a.call(e)},f=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=e.length&&r()}f(e,function(e){t(e,s(i))})},o.forEach=o.each,o.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r();var n=0,i=function(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1)>=e.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(e,t,r,n){l(t).apply(null,[e,r,n])},o.forEachLimit=o.eachLimit;var l=function(e){return function(t,r,n){if(n=n||function(){},!t.length||e<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=t.length)return n();for(;s=t.length?n():a())})}()}},d=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.each].concat(t))}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[o.eachSeries].concat(t))}},b=function(e,t,r,n){if(t=u(t,function(e,t){return{index:t,value:e}}),n){var i=[];e(t,function(e,t){r(e.value,function(r,n){i[e.index]=n,t(r)})},function(e){n(e,i)})}else e(t,function(e,t){r(e.value,function(e){t(e)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(e,t,r,n){return y(t)(e,r,n)};var y=function(e){return function(e,t){return function(){var r=Array.prototype.slice.call(arguments);return t.apply(null,[l(e)].concat(r))}}(e,b)};o.reduce=function(e,t,r,n){o.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(e,t,r,n){var i=u(e,function(e){return e}).reverse();o.reduce(i,t,r,n)},o.foldr=o.reduceRight;var v=function(e,t,r,n){var i=[];e(t=u(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r&&i.push(e),t()})},function(e){n(u(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var m=function(e,t,r,n){var i=[];e(t=u(t,function(e,t){return{index:t,value:e}}),function(e,t){r(e.value,function(r){r||i.push(e),t()})},function(e){n(u(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};o.reject=d(m),o.rejectSeries=p(m);var g=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(e){n()})};o.detect=d(g),o.detectSeries=p(g),o.some=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(e){r(!1)})},o.any=o.some,o.every=function(e,t,r){o.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(e){r(!0)})},o.all=o.every,o.sortBy=function(e,t,r){o.map(e,function(e,r){t(e,function(t,n){t?r(t):r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,u(t.sort(function(e,t){var r=e.criteria,n=t.criteria;return rn?1:0}),function(e){return e.value}))})},o.auto=function(e,t){t=t||function(){};var r=h(e),n=r.length;if(!n)return t();var i={},s=[],a=function(e){s.unshift(e)},u=function(){n--,f(s.slice(0),function(e){e()})};a(function(){if(!n){var e=t;t=function(){},e(null,i)}}),f(r,function(r){var n=c(e[r])?e[r]:[e[r]],l=function(e){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),e){var s={};f(h(i),function(e){s[e]=i[e]}),s[r]=n,t(e,s),t=function(){}}else i[r]=n,o.setImmediate(u)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return t=function(e,t){return e&&i.hasOwnProperty(t)},n=!0,((e=d).reduce?e.reduce(t,n):(f(e,function(e,r,i){n=t(n,e,r,i)}),n))&&!i.hasOwnProperty(r);var e,t,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(e){for(var t=0;t>>1);r(t,e[o])>=0?n=o:i=o-1}return n}(e.tasks,s,r)+1,0,s),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),o.setImmediate(e.process)})}(n,e,t,i)},delete n.unshift,n},o.cargo=function(e,t){var r=!1,n=[],i={tasks:n,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,r){c(e)||(e=[e]),f(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof t?n.splice(0,t):n.splice(0,n.length),a=u(s,function(e){return e.data});i.empty&&i.empty(),r=!0,e(a,function(){r=!1;var e=arguments;f(s,function(t){t.callback&&t.callback.apply(null,e)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(e){return function(t){var r=Array.prototype.slice.call(arguments,1);t.apply(null,r.concat([function(t){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&f(r,function(t){console[e](t)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(e,t){var r={},n={};t=t||function(e){return e};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=t.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],e.apply(null,i.concat([function(){r[a]=arguments;var e=n[a];delete n[a];for(var t=0,i=e.length;t2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(e,t){!function r(n){if(n){if(t)return t(n);throw n}e(r)}()},void 0!==t&&t.exports?t.exports=o:void 0!==define&&define.amd?define([],function(){return o}):n.async=o}()}).call(this,e("_process"),e("timers").setImmediate)},{_process:250,timers:325}],28:[function(e,t,r){const Buffer=e("safe-buffer").Buffer;t.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);t.fill(255);for(let r=0;r>>0,f=new Uint8Array(c);for(;e[o];){let n=t[e.charCodeAt(o)];if(255===n)return;let i=0;for(let e=c-1;(0!==n||i>>0,f[e]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");a=i,o++}if(" "===e[o])return;let u=c-a;for(;u!==c&&0===f[u];)u++;const h=Buffer.allocUnsafe(s+(c-u));h.fill(0,0,s);let l=s;for(;u!==c;)h[l++]=f[u++];return h}return{encode:function(t){if(!Buffer.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";let i=0,s=0,a=0;const c=t.length;for(;a!==c&&0===t[a];)a++,i++;const f=(c-a)*o+1>>>0,u=new Uint8Array(f);for(;a!==c;){let e=t[a],n=0;for(let t=f-1;(0!==e||n>>0,u[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");s=n,a++}let h=f-s;for(;h!==f&&0===u[h];)h++;let l=n.repeat(i);for(;h>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function c(e){for(var t=1,r=0;r126)throw new Error("Invalid prefix ("+e+")");t=a(t)^n>>5}t=a(t);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+e);var o=e.slice(0,n),s=e.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var f=c(o),u=[],h=0;h=s.length||u.push(d)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:o,words:u}},encode:function(e,t){if(e.length+7+t.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(e=e.toLowerCase()),i=e+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var f=0;f<6;++f)r=a(r);r^=1;for(var u=0;u<6;++u){var h=r>>5*(5-u)&31;i+=n.charAt(h)}return i},toWords:function(e){return f(e,8,5,!0)},fromWords:function(e){return f(e,5,8,!1)}}},{}],30:[function(e,t,r){function BigInteger(e,t,r){if(!(this instanceof BigInteger))return new BigInteger(e,t,r);null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}var n=BigInteger.prototype;n.__bigi=e("../package.json").version,BigInteger.isBigInteger=function(e,t){return e&&e.__bigi&&(!t||e.__bigi===n.__bigi)},BigInteger.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function f(e){return a.charAt(e)}function u(e,t){var r=c[e.charCodeAt(t)];return null==r?-1:r}function h(e){var t=new BigInteger;return t.fromInt(e),t}function l(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function d(e){this.m=e}function p(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function E(e){return e}function S(e){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.convert=function(e){var t=new BigInteger;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},p.prototype.revert=function(e){var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},p.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},n.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+i:this.t=0},n.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&e[n]:u(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},n.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},n.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},n.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},n.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},n.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var f=o.t,u=o[f-1];if(0!=u){var h=u*(1<1?o[f-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(m,r)),BigInteger.ONE.dlShiftTo(f,m),m.subTo(o,o);o.t=0;){var g=r[--y]==u?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,g,r,v,0,f))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=t.convert(this),o=l(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},n.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=f(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=f(r));return i?o:"0"},n.negate=function(){var e=new BigInteger;return BigInteger.ZERO.subTo(this,e),e},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(e){var t=new BigInteger;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},n.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new p(t),this.exp(e,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},n.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},n.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},n.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},n.millerRabin=function(e){var t=this.subtract(BigInteger.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>k.length&&(e=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},n.equals=function(e){return 0==this.compareTo(e)},n.min=function(e){return this.compareTo(e)<0?this:e},n.max=function(e){return this.compareTo(e)>0?this:e},n.and=function(e){var t=new BigInteger;return this.bitwiseTo(e,b,t),t},n.or=function(e){var t=new BigInteger;return this.bitwiseTo(e,y,t),t},n.xor=function(e){var t=new BigInteger;return this.bitwiseTo(e,v,t),t},n.andNot=function(e){var t=new BigInteger;return this.bitwiseTo(e,m,t),t},n.not=function(){for(var e=new BigInteger,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var u=new BigInteger;for(n.sqrTo(s[1],u);a<=f;)s[a]=new BigInteger,n.mulTo(u,s[a-2],s[a]),a+=2}var b,y,v=e.t-1,m=!0,g=new BigInteger;for(i=l(e[v])-1;v>=0;){for(i>=c?b=e[v]>>i-c&f:(b=(e[v]&(1<0&&(b|=e[v-1]>>this.DB+i-c)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),m)s[b].copyTo(o),m=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(y=o,o=g,g=y),n.mulTo(g,s[b],o)}for(;v>=0&&0==(e[v]&1<=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(e)>=0;)a.subTo(e,a);for(;a.signum()<0;)a.addTo(e,a);return a},n.pow=function(e){return this.exp(e,new _)},n.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(t=0;t-1});n(i,"Invalid mnemonic");var o=r.map(function(e){return p(t.indexOf(e).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),f=o.slice(s),u=c.match(/(.{1,8})/g).map(function(e){return parseInt(e,2)}),l=new Buffer(u),d=h(l);return n(d===f,"Invalid mnemonic checksum"),l.toString("hex")}function u(e,t){t=t||a;var r=new Buffer(e,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(e){var r=parseInt(e,2);return t[r]}).join(" ")}function h(e){var t=i("sha256").update(e).digest(),r=8*e.length/32;return d([].slice.call(t)).slice(0,r)}function l(e){return"mnemonic"+(s.nfkd(e)||"")}function d(e){return e.map(function(e){return p(e.toString(2),"0",8)}).join("")}function p(e,t,r){for(;e.length>>24]^y[a>>16&255]^v[c>>8&255]^m[255&t]^i[p],u=e[a>>>24]^y[c>>16&255]^v[t>>8&255]^m[255&o]^i[p+1],h=e[c>>>24]^y[t>>16&255]^v[o>>8&255]^m[255&a]^i[p+2],t=e[t>>>24]^y[o>>16&255]^v[a>>8&255]^m[255&c]^i[p+3],p+=4,o=f,a=u,c=h;for(l=0;4>l;l++)b[r?3&-l:l]=g[o>>>24]<<24^g[a>>16&255]<<16^g[c>>8&255]<<8^g[255&t]^i[p++],f=o,o=a,a=c,c=t,t=f;return b}function c(e,t){var r,n=s.random.D[e],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;rt&&(e.i[t]=e.i[t]+1|0,!e.i[t]);t++);return e.F.encrypt(e.i)}function l(e,t){return function(){t.apply(e,arguments)}}void 0!==t&&t.exports&&(t.exports=s),"function"==typeof define&&define([],function(){return s}),s.cipher.aes=function(e){this.o[0][0][0]||this.t();var t,r,i,o,a=this.o[0][4],c=this.o[1],f=1;for(4!==(t=e.length)&&6!==t&&8!==t&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==e%t&&(r=r<<8^r>>>24^f<<24,f=f<<1^283*(f>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(e){return a(this,e,0)},decrypt:function(e){return a(this,e,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var e,t,r,n,i,o,s,a=this.o[0],c=this.o[1],f=a[4],u=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!f[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,f[t]=o,u[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},s.bitArray={bitSlice:function(e,t,r){return e=s.bitArray.R(e.slice(t/32),32-(31&t)).slice(1),r===i?e:s.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(s.bitArray.bitLength(e)!==s.bitArray.bitLength(t))return o;var r,n=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=s.bitArray.getPartial(o),n.push(s.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},s.codec.utf8String={fromBits:function(e){var t,r,n="",i=s.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],n=0;for(t=0;t>>i)>>>26),6>i?(a=e[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!t;)n+="=";return n},toBits:function(e,t){e=e.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,f=0;for(t&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(e.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),f=i<<32-a):f^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,f,1)),o}},s.codec.base64url={fromBits:function(e){return s.codec.base64.fromBits(e,1,1)},toBits:function(e){return s.codec.base64.toBits(e,1)}},s.hash.sha256=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha256.hash=function(e){return(new s.hash.sha256).update(e).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=512+t&-512;t<=e;t+=512)this.r(r.splice(0,16));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+2;15&e;e++)t.push(0);for(t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}var t,r=0,n=2;e:for(;64>r;n++){for(t=2;t*t<=n;t++)if(0==n%t)continue e;8>r&&(this.l[r]=e(Math.pow(n,.5))),this.b[r]=e(Math.pow(n,1/3)),r++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?t=n[e]:(t=n[e+1&15],r=n[e+14&15],t=n[15&e]=(t>>>7^t>>>18^t>>>3^t<<25^t<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&e]+n[e+9&15]|0),t=t+d+(u>>>6^u>>>11^u>>>25^u<<26^u<<21^u<<7)+(l^u&(h^l))+o[e],d=l,l=h,h=u,u=f+t|0,f=c,c=a,s=t+((a=s)&c^f&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+f|0,i[4]=i[4]+u|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(e){this.b[0]||this.t(),e?(this.e=e.e.slice(0),this.d=e.d.slice(0),this.c=e.c):this.reset()},s.hash.sha512.hash=function(e){return(new s.hash.sha512).update(e).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(e){"string"==typeof e&&(e=s.codec.utf8String.toBits(e));var t,r=this.d=s.bitArray.concat(this.d,e);for(t=this.c,e=this.c=t+s.bitArray.bitLength(e),t=1024+t&-1024;t<=e;t+=1024)this.r(r.splice(0,32));return this},finalize:function(){var e,t=this.d,r=this.e;for(e=(t=s.bitArray.concat(t,[s.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.c/4294967296)),t.push(0|this.c);t.length;)this.r(t.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}var r,n=0,i=2;e:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue e;8>n&&(this.l[2*n]=e(Math.pow(i,.5)),this.l[2*n+1]=t(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=e(Math.pow(i,1/3)),this.b[2*n+1]=t(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(e){var t,r,n=e.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],m=i[12],g=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=f,x=u,I=h,T=l,P=d,B=p,C=b,M=y,R=v,O=m,L=g,N=w,j=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((K=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(e-7)],z=n[2*(e-16)],q=n[2*(e-16)+1];t=t+H+((r=D+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=K)>>>0>>0?1:0),t+=z+((r+=q)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;H=B&M^~B&O;var F=C&R^~C&L,W=(K=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];D=(D=(D=(D=N+((C<<18|B>>>14)^(C<<14|B>>>18)^(B<<23|C>>>9))+((U=j+((B<<18|C>>>14)^(B<<14|C>>>18)^(C<<23|B>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+K+((r=q+W)>>>0>>0?1:0),N=O,j=L,O=M,L=R,M=B,R=C,B=T+D+((C=P+U|0)>>>0

>>0?1:0)|0,T=x,P=I,x=k,I=A,k=E,A=S,E=D+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,f=i[3]=f+A|0,i[2]=c+k+(f>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=u+x+(h>>>0>>0?1:0)|0,d=i[7]=d+P|0,i[6]=l+T+(d>>>0

>>0?1:0)|0,b=i[9]=b+C|0,i[8]=p+B+(b>>>0>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+M+(v>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=m+O+(g>>>0>>0?1:0)|0,_=i[15]=_+j|0,i[14]=w+N+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(e){s.mode.ccm.w.push(e)},unListenProgress:function(e){-1<(e=s.mode.ccm.w.indexOf(e))&&s.mode.ccm.w.splice(e,1)},X:function(e){var t,r=s.mode.ccm.w.slice();for(t=0;tu&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-u&&(a=15-u),r=f.clamp(r,8*(15-a)),t=s.mode.ccm.O(e,t,r,i,o,a),c=s.mode.ccm.s(e,c,r,t,o,a),f.concat(c.data,c.tag)},decrypt:function(e,t,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,f=a.bitLength(t),u=a.clamp(t,f-o),h=a.bitSlice(t,f-o);f=(f-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),t=2;4>t&&f>>>8*t;t++);return t<15-c&&(t=15-c),r=a.clamp(r,8*(15-t)),u=s.mode.ccm.s(e,u,r,h,o,t),e=s.mode.ccm.O(e,u.data,r,i,o,t),a.equal(u.tag,e)||n(new s.exception.corrupt("ccm: tag doesn't match")),u.data},ga:function(e,t,r,n,i,o){var a=[],c=s.bitArray,f=c.j;if(n=[c.partial(8,(t.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=e.encrypt(n),t.length)for(65279>=(r=c.bitLength(t)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,t),t=0;to||16h&&(s.mode.ccm.X(a/f),h+=l),r[3]++,i=e.encrypt(r),t[a]^=i[0],t[a+1]^=i[1],t[a+2]^=i[2],t[a+3]^=i[3];return{tag:n,data:c.clamp(t,u)}}},s.mode.ocb2={name:"ocb2",encrypt:function(e,t,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,f=s.mode.ocb2.K,u=s.bitArray,h=u.j,l=[0,0,0,0];r=f(e.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),e.encrypt(o(n(o(c,n(c))),a))},K:function(e){return[e[0]<<1^e[1]>>>31,e[1]<<1^e[2]>>>31,e[2]<<1^e[3]>>>31,e[3]<<1^135*(e[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(e,t,r,n,i){var o=t.slice(0);return t=s.bitArray,n=n||[],e=s.mode.gcm.s(!0,e,o,n,r,i||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,a){var c=t.slice(0),f=s.bitArray,u=f.bitLength(c);return a=a||128,i=i||[],a<=u?(t=f.bitSlice(c,u-a),c=f.bitSlice(c,0,u-a)):(t=c,c=[]),e=s.mode.gcm.s(o,e,c,i,r,a),f.equal(e.tag,t)||n(new s.exception.corrupt("gcm: tag doesn't match")),e.data},ba:function(e,t){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=t.slice(0),r=0;128>r;r++){for((n=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(e,t,r){var n,i=r.length;for(t=t.slice(0),n=0;ni&&(e=t.hash(e)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),e=new(o=o||s.misc.hmac)(e);var a,c,f,u,h=[],l=s.bitArray;for(u=1;32*h.length<(i||1);u++){for(o=a=e.encrypt(l.concat(t,[u])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[u].update([o,this.H++,2,t,f,e.length].concat(e))}break;case"string":t===i&&(t=e.length),this.f[u].update([o,this.H++,3,t,f,e.length]),this.f[u].update(e);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[u]+=t,this.g+=t,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(e){return e=this.L[e!==i?e:this.G],this.n&&this.n>=e?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=e?this.C|this.p:this.p},getProgress:function(e){return e=this.L[e||this.G],this.n>=e?1:this.g>e?1:this.g/e},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(e,t){this.D[e][this.Y++]=t},removeEventListener:function(e,t){var r,n,i=this.D[e],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===t&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=t.iter||64!==t.ts&&96!==t.ts&&128!==t.ts||128!==t.ks&&192!==t.ks&&256!==t.ks||!t.iv||2>t.iv.length||472)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}}},{"safe-buffer":298}],39:[function(e,t,r){t.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],40:[function(e,t,r){var n=e("./index.json"),i={};for(var o in n){i[n[o]]=o}t.exports=i},{"./index.json":39}],41:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bech32"),i=e("cashaddress"),o=e("bs58check"),s=e("./script"),a=e("./templates"),c=e("./networks"),f=e("typeforce"),u=e("./types");function h(e){var t=o.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function l(e){var t=n.decode(e),r=n.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:Buffer.from(r)}}function d(e){return i.decode(e)}function p(e,t){f(u.tuple(u.Hash160bit,u.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)}function b(e,t,r){var i=n.toWords(e);return i.unshift(t),n.encode(r,i)}function y(e,t,r){return i.encode(r,t,e)}t.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(e,t,r){if(t=t||c.bitcoin,r=r||!1,"cashAddrPrefix"in t&&r){if(s.pubKeyHash.output.check(e))return y(s.compile(e).slice(3,23),a.types.P2PKH,t.cashAddrPrefix);if(s.scriptHash.output.check(e))return y(s.compile(e).slice(2,22),a.types.P2SH,t.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(e))return p(s.compile(e).slice(3,23),t.pubKeyHash);if(s.scriptHash.output.check(e))return p(s.compile(e).slice(2,22),t.scriptHash)}if(s.witnessPubKeyHash.output.check(e))return b(s.compile(e).slice(2,22),0,t.bech32);if(s.witnessScriptHash.output.check(e))return b(s.compile(e).slice(2,34),0,t.bech32);throw new Error(s.toASM(e)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(e,t,r){var n;if("cashAddrPrefix"in(t=t||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}try{if("pubkeyhash"===(n=d(t.cashAddrPrefix+":"+e)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(e){}if(n&&n.prefix!==t.cashAddrPrefix)throw new Error(e+" has an invalid prefix")}try{if((n=h(e)).version===t.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===t.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(e){}if(!n&&"bech32"in t){try{n=l(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(e+" has no matching Script")}}},{"./networks":50,"./script":51,"./templates":53,"./types":77,bech32:29,bs58check:107,cashaddress:114,"safe-buffer":298,typeforce:328}],42:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("merkle-lib/fastRoot"),s=e("typeforce"),a=e("./types"),c=e("varuint-bitcoin"),f=e("./transaction");function u(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}u.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var t=0;function r(r){return t+=r,e.slice(t-r,t)}function n(){var r=e.readUInt32LE(t);return t+=4,r}var i=new u;if(i.version=function(){var r=e.readInt32LE(t);return t+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===e.length)return i;function o(){var r=f.fromBuffer(e.slice(t),!0);return t+=r.byteLength(),r}var s,a=(s=c.decode(e,t),t+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&e,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-t),n},u.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},u.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=u.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},u.prototype.checkProofOfWork=function(){var e=n(this.getHash()),t=u.calculateTarget(this.bits);return e.compare(t)<=0},t.exports=u},{"./crypto":44,"./transaction":75,"./types":77,"buffer-reverse":109,"merkle-lib/fastRoot":243,"safe-buffer":298,typeforce:328,"varuint-bitcoin":336}],43:[function(e,t,r){var n=e("pushdata-bitcoin"),i=e("varuint-bitcoin");function o(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}t.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(e,t,r){return o(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},{"pushdata-bitcoin":277,"varuint-bitcoin":336}],44:[function(e,t,r){var n=e("create-hash");function i(e){return n("rmd160").update(e).digest()}function o(e){return n("sha256").update(e).digest()}t.exports={hash160:function(e){return i(o(e))},hash256:function(e){return o(o(e))},ripemd160:i,sha1:function(e){return n("sha1").update(e).digest()},sha256:o}},{"create-hash":119}],45:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("create-hmac"),i=e("typeforce"),o=e("./types"),BigInteger=e("bigi"),s=e("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),f=e("ecurve").getCurveByName("secp256k1");function u(e,t,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),u=Buffer.alloc(32,1);s=n("sha256",s).update(u).update(a).update(t).update(e).digest(),u=n("sha256",s).update(u).digest(),s=n("sha256",s).update(u).update(c).update(t).update(e).digest(),u=n("sha256",s).update(u).digest(),u=n("sha256",s).update(u).digest();for(var h=BigInteger.fromBuffer(u);h.signum()<=0||h.compareTo(f.n)>=0||!r(h);)s=n("sha256",s).update(u).update(a).digest(),u=n("sha256",s).update(u).digest(),u=n("sha256",s).update(u).digest(),h=BigInteger.fromBuffer(u);return h}var h=f.n.shiftRight(1);t.exports={deterministicGenerateK:u,sign:function(e,t){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=t.toBuffer(32),c=BigInteger.fromBuffer(e),l=f.n,d=f.G;return u(e,a,function(e){var i=d.multiply(e);return!f.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=e.modInverse(l).multiply(c.add(t.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(e,t,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=f.n,s=f.G,a=t.r,c=t.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var u=BigInteger.fromBuffer(e),h=c.modInverse(n),l=u.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!f.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:f}},{"./ecsignature":47,"./types":77,bigi:32,"create-hmac":121,ecurve:198,"safe-buffer":298,typeforce:328}],46:[function(e,t,r){var n=e("./address"),i=e("./crypto"),o=e("./ecdsa"),s=e("randombytes"),a=e("typeforce"),c=e("./types"),f=e("wif"),u=e("./networks"),BigInteger=e("bigi"),h=e("ecurve"),l=o.__curve;function ECPair(e,t,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},e){if(e.signum()<=0)throw new Error("Private key must be greater than 0");if(e.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(c.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||u.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(e,t){var r=h.Point.decodeFrom(l,e);return new ECPair(null,r,{compressed:r.compressed,network:t})},ECPair.fromWIF=function(e,t){var r=f.decode(e),n=r.version;if(c.Array(t)){if(!(t=t.filter(function(e){return n===e.wif}).pop()))throw new Error("Unknown network version")}else if(t=t||u.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},ECPair.makeRandom=function(e){var t,r=(e=e||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),t=BigInteger.fromBuffer(n)}while(t.signum()<=0||t.compareTo(l.n)>=0);return new ECPair(t,null,e)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");return o.sign(e,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return f.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(e,t){return o.verify(e,t,this.Q)},t.exports=ECPair},{"./address":41,"./crypto":44,"./ecdsa":45,"./networks":50,"./types":77,bigi:32,ecurve:198,randombytes:282,typeforce:328,wif:338}],47:[function(e,t,r){(function(Buffer){var r=e("bip66"),n=e("typeforce"),i=e("./types"),BigInteger=e("bigi");function o(e,t){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=e,this.s=t}o.parseCompact=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t!==(7&t))throw new Error("Invalid signature parameter");return{compressed:!!(4&t),i:3&t,signature:new o(BigInteger.fromBuffer(e.slice(1,33)),BigInteger.fromBuffer(e.slice(33)))}},o.fromDER=function(e){var t=r.decode(e);return new o(BigInteger.fromDERInteger(t.r),BigInteger.fromDERInteger(t.s))},o.parseScriptSignature=function(e){var t=e.readUInt8(e.length-1),r=-193&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);return{signature:o.fromDER(e.slice(0,-1)),hashType:t}},o.prototype.toCompact=function(e,t){t&&(e+=4),e+=27;var r=Buffer.alloc(65);return r.writeUInt8(e,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var e=Buffer.from(this.r.toDERInteger()),t=Buffer.from(this.s.toDERInteger());return r.encode(e,t)},o.prototype.toScriptSignature=function(e){var t=-193&e;if(t<=0||t>=4)throw new Error("Invalid hashType "+e);var r=Buffer.alloc(1);return r.writeUInt8(e,0),Buffer.concat([this.toDER(),r])},t.exports=o}).call(this,e("buffer").Buffer)},{"./types":77,bigi:32,bip66:38,buffer:111,typeforce:328}],48:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bs58check"),i=e("./crypto"),o=e("create-hmac"),s=e("typeforce"),a=e("./types"),c=e("./networks"),BigInteger=e("bigi"),ECPair=e("./ecpair"),f=e("ecurve"),u=f.getCurveByName("secp256k1");function HDNode(e,t){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!e.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=e,this.chainCode=t,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(e,t){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:t}),i)},HDNode.fromSeedHex=function(e,t){return HDNode.fromSeedBuffer(Buffer.from(e,"hex"),t)},HDNode.fromBase58=function(e,t){var r=n.decode(e);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(t)){if(!(i=t.filter(function(e){return o===e.bip32.private||o===e.bip32.public}).pop()))throw new Error("Unknown network version")}else i=t||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=f.Point.decodeFrom(u,r.slice(45,78));u.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var e=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},HDNode.prototype.sign=function(e){return this.keyPair.sign(e)},HDNode.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},HDNode.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(e){s(a.UInt32,e);var t=e>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),f=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(u.n)>=0)return this.derive(e+1);if(this.isNeutered()){var l=u.G.multiply(h).add(this.keyPair.Q);if(u.isInfinity(l))return this.derive(e+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(u.n);if(0===d.signum())return this.derive(e+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,f);return p.depth=this.depth+1,p.index=e,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(e){return s(a.UInt31,e),this.derive(e+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(e){s(a.BIP32Path,e);var t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new Error("Not a master node");t=t.slice(1)}return t.reduce(function(e,t){var r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)},t.exports=HDNode},{"./crypto":44,"./ecpair":46,"./networks":50,"./types":77,bigi:32,bs58check:107,"create-hmac":121,ecurve:198,"safe-buffer":298,typeforce:328}],49:[function(e,t,r){t.exports={Block:e("./block"),ECPair:e("./ecpair"),ECSignature:e("./ecsignature"),HDNode:e("./hdnode"),Transaction:e("./transaction"),TransactionBuilder:e("./transaction_builder"),address:e("./address"),bufferutils:e("./bufferutils"),crypto:e("./crypto"),networks:e("./networks"),opcodes:e("bitcoin-ops"),script:e("./script")}},{"./address":41,"./block":42,"./bufferutils":43,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./hdnode":48,"./networks":50,"./script":51,"./transaction":75,"./transaction_builder":76,"bitcoin-ops":39}],50:[function(e,t,r){t.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],51:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=e("pushdata-bitcoin"),o=e("typeforce"),s=e("./types"),a=e("./script_number"),c=e("bitcoin-ops"),f=e("bitcoin-ops/map"),u=c.OP_RESERVED;function h(e){return s.Buffer(e)||function(e){return s.Number(e)&&(e===c.OP_0||e>=c.OP_1&&e<=c.OP_16||e===c.OP_1NEGATE)}(e)}function l(e){return s.Array(e)&&e.every(h)}function d(e){return 0===e.length?c.OP_0:1===e.length?e[0]>=1&&e[0]<=16?u+e[0]:129===e[0]?c.OP_1NEGATE:void 0:void 0}function p(e){if(Buffer.isBuffer(e))return e;o(s.Array,e);var t=e.reduce(function(e,t){return Buffer.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+i.encodingLength(t.length)+t.length:e+1},0),r=Buffer.allocUnsafe(t),n=0;if(e.forEach(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,n),void(n+=1);n+=i.encode(r,e.length,n),e.copy(r,n),n+=e.length}else r.writeUInt8(e,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(e){if(s.Array(e))return e;o(s.Buffer,e);for(var t=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(e,r);if(null===a)return[];if((r+=a.size)+a.number>e.length)return[];var f=e.slice(r,r+a.number);r+=a.number;var u=d(f);void 0!==u?t.push(u):t.push(f)}else t.push(n),r+=1}return t}function y(e){var t=-193&e;return t>0&&t<4}t.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(e){return void 0!==c[e]?c[e]:(o(s.Hex,e),Buffer.from(e,"hex"))}))},toASM:function(e){return Buffer.isBuffer(e)&&(e=b(e)),e.map(function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]}).join(" ")},toStack:function(e){return e=b(e),o(l,e),e.map(function(e){return Buffer.isBuffer(e)?e:e===c.OP_0?Buffer.allocUnsafe(0):a.encode(e-u)})},number:e("./script_number"),isCanonicalPubKey:function(e){if(!Buffer.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!Buffer.isBuffer(e)&&!!y(e[e.length-1])&&n.check(e.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var v=e("./templates");for(var m in v)t.exports[m]=v[m]},{"./script_number":52,"./templates":53,"./types":77,bip66:38,"bitcoin-ops":39,"bitcoin-ops/map":40,"pushdata-bitcoin":277,"safe-buffer":298,typeforce:328}],52:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;t.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),n=Buffer.allocUnsafe(r),i=e<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":298}],53:[function(e,t,r){var n=e("../script").decompile,i=e("./multisig"),o=e("./nulldata"),s=e("./pubkey"),a=e("./pubkeyhash"),c=e("./scripthash"),f=e("./witnesspubkeyhash"),u=e("./witnessscripthash"),h=e("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};t.exports={classifyInput:function(e,t){var r=n(e);return a.input.check(r)?l.P2PKH:i.input.check(r,t)?l.MULTISIG:c.input.check(r,t)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(e){if(f.output.check(e))return l.P2WPKH;if(u.output.check(e))return l.P2WSH;if(a.output.check(e))return l.P2PKH;if(c.output.check(e))return l.P2SH;var t=n(e);return i.output.check(t)?l.MULTISIG:s.output.check(t)?l.P2PK:h.output.check(t)?l.WITNESS_COMMITMENT:o.output.check(t)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return f.input.check(r)?l.P2WPKH:u.input.check(r,t)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:f,witnessScriptHash:u,witnessCommitment:h,types:l}},{"../script":51,"./multisig":54,"./nulldata":57,"./pubkey":58,"./pubkeyhash":61,"./scripthash":64,"./witnesscommitment":67,"./witnesspubkeyhash":69,"./witnessscripthash":72}],54:[function(e,t,r){t.exports={input:e("./input"),output:e("./output")}},{"./input":55,"./output":56}],55:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){return e===o.OP_0||n.isCanonicalSignature(e)}function a(e,t){var r=n.decompile(e);return!(r.length<2)&&(r[0]===o.OP_0&&(t?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function f(e,t){if(i([s],e),t){var r=n.multisig.output.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,e.map(function(e){return e===o.OP_0?c:e}))}function u(e,t){return i(a,e,t),e.slice(1)}t.exports={check:a,decode:function(e,t){return u(n.decompile(e),t)},decodeStack:u,encode:function(e,t){return n.compile(f(e,t))},encodeStack:f}},{"../../script":51,"bitcoin-ops":39,"safe-buffer":298,typeforce:328}],56:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=s.OP_RESERVED;function c(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},t.exports={check:c,decode:function(e,t){var r=n.decompile(e);return o(c,r,t),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(r1&&t[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},t.exports={output:{check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Buffer,e),n.compile([s.OP_RETURN,e])}}}},{"../script":51,"../types":77,"bitcoin-ops":39,typeforce:328}],58:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./input":59,"./output":60,dup:54}],59:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function s(e){return i(n.isCanonicalSignature,e),[e]}function a(e){return i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e){return n.compile(s(e))},encodeStack:s}},{"../../script":51,typeforce:328}],60:[function(e,t,r){var n=e("../../script"),i=e("typeforce"),o=e("bitcoin-ops");function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},t.exports={check:s,decode:function(e){var t=n.decompile(e);return i(s,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},{"../../script":51,"bitcoin-ops":39,typeforce:328}],61:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./input":62,"./output":63,dup:54}],62:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function s(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function a(e){return i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},t.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e,t){return n.compile(s(e,t))},encodeStack:s}},{"../../script":51,typeforce:328}],63:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 25===t.length&&t[0]===s.OP_DUP&&t[1]===s.OP_HASH160&&20===t[2]&&t[23]===s.OP_EQUALVERIFY&&t[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_DUP,s.OP_HASH160,e,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:328}],64:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./input":65,"./output":66,dup:54}],65:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("typeforce");function o(e,t){var r=n.decompile(e);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,t),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(e,t){var r=n.compile(t);return[].concat(e,r)}function a(e){return i(o,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}o.toJSON=function(){return"scriptHash input"},t.exports={check:o,decode:function(e){var t=a(n.decompile(e));return t.redeemScriptSig=n.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:a,encode:function(e,t){var r=n.decompile(e);return n.compile(s(r,t))},encodeStack:s}},{"../../script":51,"safe-buffer":298,typeforce:328}],66:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 23===t.length&&t[0]===s.OP_HASH160&&20===t[1]&&t[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_HASH160,e,s.OP_EQUAL])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:328}],67:[function(e,t,r){t.exports={output:e("./output")}},{"./output":68}],68:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(e){var t=n.compile(e);return t.length>37&&t[0]===s.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},t.exports={check:c,decode:function(e){return o(c,e),n.decompile(e)[1].slice(4,36)},encode:function(e){o(i.Hash256bit,e);var t=Buffer.allocUnsafe(36);return a.copy(t,0),e.copy(t,4),n.compile([s.OP_RETURN,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":298,typeforce:328}],69:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./input":70,"./output":71,dup:54}],70:[function(e,t,r){var n=e("../../script"),i=e("typeforce");function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}s.toJSON=function(){return"witnessPubKeyHash input"},t.exports={check:s,decodeStack:function(e){return i(s,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},{"../../script":51,typeforce:328}],71:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 22===t.length&&t[0]===s.OP_0&&20===t[1]}a.toJSON=function(){return"Witness pubKeyHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_0,e])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:328}],72:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{"./input":73,"./output":74,dup:54}],73:[function(e,t,r){var n=e("../scripthash/input");t.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":65}],74:[function(e,t,r){var n=e("../../script"),i=e("../../types"),o=e("typeforce"),s=e("bitcoin-ops");function a(e){var t=n.compile(e);return 34===t.length&&t[0]===s.OP_0&&32===t[1]}a.toJSON=function(){return"Witness scriptHash output"},t.exports={check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Hash256bit,e),n.compile([s.OP_0,e])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:328}],75:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./crypto"),o=e("./script"),s=e("./bufferutils"),a=e("bitcoin-ops"),c=e("typeforce"),f=e("./types"),u=e("varuint-bitcoin");function h(e){var t=e.length;return u.encodingLength(t)+t}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),m={script:d,valueBuffer:v};l.fromBuffer=function(e,t){var r=0;function n(t){return r+=t,e.slice(r-t,r)}function i(){var t=e.readUInt32LE(r);return r+=4,t}function o(){var t=s.readUInt64LE(e,r);return r+=8,t}function a(){var t=u.decode(e,r);return r+=u.decode.bytes,t}function c(){return n(a())}function f(){for(var e=a(),t=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(t).filter(function(e){return e!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(e>=this.outs.length)return y;s.outs.length=e+1;for(var u=0;u0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(f.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,o)}return this.hashForSignature(e,t,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(e,t){return this.__toBuffer(e,t,!0)},l.prototype.__toBuffer=function(e,t,r){e||(e=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=t||0;function o(t){i+=t.copy(e,i)}function a(t){i=e.writeUInt8(t,i)}function c(t){i=e.writeUInt32LE(t,i)}function f(t){u.encode(t,e,i),i+=u.encode.bytes}function h(e){f(e.length),o(e)}n=this.version,i=e.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),f(this.ins.length),this.ins.forEach(function(e){o(e.hash),c(e.index),h(e.script),c(e.sequence)}),f(this.outs.length),this.outs.forEach(function(t){var r;t.valueBuffer?o(t.valueBuffer):(r=t.value,i=s.writeUInt64LE(e,r,i)),h(t.script)}),d&&this.ins.forEach(function(e){var t;f((t=e.witness).length),t.forEach(h)}),c(this.locktime),void 0!==t?e.slice(t,i):e},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(e,t){c(f.tuple(f.Number,f.Buffer),arguments),this.ins[e].script=t},l.prototype.setWitness=function(e,t){c(f.tuple(f.Number,[f.Buffer]),arguments),this.ins[e].witness=t},t.exports=l},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":109,"safe-buffer":298,typeforce:328,"varuint-bitcoin":336}],76:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-reverse"),i=e("./address"),o=e("./crypto"),s=e("./script"),a=e("./networks"),c=e("bitcoin-ops"),f=e("typeforce"),u=e("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=e("./ecpair"),p=e("./ecsignature"),b=e("./transaction");function y(e){return-1!==l.indexOf(e)}function v(e){return-1!==d.indexOf(e)}function m(e,t){if(0===e.length&&0===t.length)return{};var r,n,i,a,c,f,u,l,d,p,b=!1,m=!1,g=!1,w=s.decompile(e);s.classifyInput(w,!0)===h.P2SH&&(g=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(t,!0);if(_===h.P2WSH){if(f=t[t.length-1],u=s.classifyOutput(f),m=!0,b=!0,0===e.length){if(r=s.witnessScriptHash.output.encode(o.sha256(f)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(f)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(f)))throw new Error("unsupported witness script");a=f,i=u,p=t.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=t[t.length-1],S=o.hash160(E);if(0===e.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=t}else if(c){if(!v(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(e),p=w;var k=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=t.slice(1).map(function(e){return 0===e.length?void 0:e})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return g&&(A.redeemScript=c,A.redeemScriptType=l),m&&(A.witnessScript=f,A.witnessScriptType=u),A}function g(e,t,r){f(u.Buffer,e);var n=s.decompile(e);t||(t=s.classifyOutput(e));var i=[];switch(t){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:i,scriptType:t,signatures:i.map(function(){})}}function w(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(e,t,r,n,i){var a,c,l,d,p,b,y,v,m,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(e,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=g(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=b=a.scriptType,m=i}else if(r){if(w(e,p=o.hash160(r)),!(a=g(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,m=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,y=o.sha256(i)),!(a=g(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,v=b=a.scriptType,m=i}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(c=e.prevOutType,l=e.prevOutScript,!(a=g(e.prevOutScript,e.prevOutType,t)).pubKeys)return;E=e.prevOutType===h.P2WPKH,v=c,m=l}else a=g(l=s.pubKeyHash.output.encode(o.hash160(t)),h.P2PKH,t),E=!1,v=c=h.P2PKH,m=l;if(void 0!==n||E){if(f(u.Satoshi,n),void 0!==e.value&&e.value!==n)throw new Error("Input didn't match witnessValue");e.value=n}v===h.P2WPKH&&(m=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(m))),_&&(e.redeemScript=r,e.redeemScriptType=d),S&&(e.witnessScript=i,e.witnessScriptType=b),e.pubKeys=a.pubKeys,e.signatures=a.signatures,e.signScript=m,e.signType=v,e.prevOutScript=l,e.prevOutType=c,e.witness=E}function E(e,t,r,n){if(e===h.P2PKH){if(1===t.length&&Buffer.isBuffer(t[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&Buffer.isBuffer(t[0]))return s.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map(function(e){return e||c.OP_0}),n||(t=t.filter(function(e){return e!==c.OP_0})),s.multisig.input.encodeStack(t)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(e,t){this.prevTxMap={},this.network=e||a.bitcoin,this.maximumFeeRate=t||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&void 0!==e.witness}function A(e){return e.readUInt8(e.length-1)}S.prototype.enableBitcoinCash=function(e){void 0===e&&(e=!0),this.bitcoinCash=e},S.prototype.enableBitcoinGold=function(e){void 0===e&&(e=!0),this.bitcoinGold=e},S.prototype.setLockTime=function(e){if(f(u.UInt32,e),this.inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},S.prototype.setVersion=function(e){f(u.UInt32,e),this.tx.version=e},S.fromTransaction=function(e,t,r){var n=new S(t);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(e.version),n.setLockTime(e.locktime),e.outs.forEach(function(e){n.addOutput(e.script,e.value)}),e.ins.forEach(function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness,value:e.value})}),n.inputs.forEach(function(t,n){!function(e,t,r,n,i){if(e.signType===h.MULTISIG&&e.signScript&&e.pubKeys.length!==e.signatures.length){var o=e.signatures.concat();e.signatures=e.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,f){if(!s)return!1;var u,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:u=t.hashForCashSignature(r,e.signScript,n,h.hashType);break;case b.FORKID_BTG:u=t.hashForGoldSignature(r,e.signScript,n,h.hashType);break;default:u=e.witness?t.hashForWitnessV0(r,e.signScript,n,h.hashType):t.hashForSignature(r,e.signScript,h.hashType)}return!!c.verify(u,h.signature)&&(o[f]=void 0,a=s,!0)}),a})}}(t,e,n,t.value,r)}),n},S.prototype.addInput=function(e,t,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof e)e=n(Buffer.from(e,"hex"));else if(e instanceof b){var s=e.outs[t];i=s.script,o=s.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(e,t,r){if(b.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=m(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=g(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!e)throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];y(r)&&(n=E(r,e.signatures,e.pubKeys,t));var o=!1;if(r===s.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");y(e.redeemScriptType)&&(n=E(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(o=!0,r=e.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,e.signatures,e.pubKeys,t);break;case s.types.P2WSH:if(!t&&!y(e.witnessScriptType))throw new Error("Impossible to sign this type");y(e.witnessScriptType)&&((i=E(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return o&&n.push(e.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,e);if(!e&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},S.prototype.sign=function(e,t,r,n,i,o){if(t.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);n=n||b.SIGHASH_ALL;var s=this.inputs[e];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=t.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(e,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(e,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(e,s.signScript,i,n):this.tx.hashForSignature(e,s.signScript,n),!s.pubKeys.some(function(e,r){if(!c.equals(e))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!t.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=t.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(e){return void 0===e.signatures||e.signatures.every(function(e){return!e||A(e)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?e<=t:void 0)})})},S.prototype.__overMaximumFees=function(e){return(this.inputs.reduce(function(e,t){return e+(t.value>>>0)},0)-this.tx.outs.reduce(function(e,t){return e+t.value},0))/e>this.maximumFeeRate},t.exports=S},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":109,"safe-buffer":298,typeforce:328}],77:[function(e,t,r){var n=e("typeforce"),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),f=n.compile({r:a,s:a}),u=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:f,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:u,Satoshi:function(e){return n.UInt53(e)&&e<=s},UInt31:function(e){return n.UInt32(e)&&e<=i}};for(var l in n)h[l]=n[l];t.exports=h},{typeforce:328}],78:[function(e,t,r){(function(Buffer){var r=e("bs58check"),n=e("buffer-equals"),i=e("create-hash"),o=e("secp256k1"),s=e("varuint-bitcoin");function a(e,t){var r=s.encodingLength(e.length),n=new Buffer(t.length+r+e.length);return n.write(t,0),s.encode(e.length,n,t.length),n.write(e,t.length+r),function(e){var t=i("sha256").update(e).digest();return i("sha256").update(t).digest()}(n)}t.exports={magicHash:a,sign:function(e,t,r,n){var i=a(e,t),s=o.sign(i,r);return function(e,t,r){return r&&(t+=4),Buffer.concat([new Buffer([t+27]),e])}(s.signature,s.recovery,n)},verify:function(e,t,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var f,u,h=function(e){if(65!==e.length)throw new Error("Invalid signature length");var t=e.readUInt8(0)-27;if(t>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&t),recovery:3&t,signature:e.slice(1)}}(c),l=a(e,t),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(f=d,u=i("sha256").update(f).digest(),i("ripemd160").update(u).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this,e("buffer").Buffer)},{bs58check:81,buffer:111,"buffer-equals":108,"create-hash":119,secp256k1:299,"varuint-bitcoin":336}],79:[function(e,t,r){t.exports=function(e){for(var t={},r=e.length,n=e.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var f=0;e[f]===n&&f0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===t[c]&&c=0;--f)a+=e[n[f]];return a},decodeUnsafe:o,decode:function(e){var t=o(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}},{}],80:[function(e,t,r){var n=e("base-x");t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":79}],81:[function(e,t,r){(function(Buffer){"use strict";var r=e("bs58"),n=e("create-hash");function i(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}function o(e){var t=e.slice(0,-4),r=e.slice(-4),n=i(t);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return t}function s(e){var t=r.decodeUnsafe(e);if(t)return o(new Buffer(t))}t.exports={encode:function(e){var t=i(e);return r.encode(Buffer.concat([e,t],e.length+4))},decode:function(e){var t=r.decode(e),n=o(new Buffer(t));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this,e("buffer").Buffer)},{bs58:80,buffer:111,"create-hash":119}],82:[function(e,t,r){!function(t,r){"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 o(e,t,r){if(o.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 Buffer;"object"==typeof t?t.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{Buffer=e("buffer").Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function a(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.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)},o.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)},o.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=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.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 o=e.length-r,s=o%n,c=Math.min(o,o-s)+r,f=0,u=r;u1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[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 h(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],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var f=1;f>>26,h=67108863&c,l=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=l;d++){var p=f-d|0;u+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[f]=0|h,c=0|u}return 0!==c?r.words[f]=0|c:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-h.length]+h+r:h+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.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=f[e],d=u[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(e);r=(p=p.idivn(d)).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")},o.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},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==Buffer),this.toArrayLike(Buffer,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,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,a,c="le"===t,f=new e(o),u=this.clone();if(c){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),f[a]=s;for(;a=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},o.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},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.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;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.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<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.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 o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,m=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],P=8191&T,B=T>>>13,C=0|s[7],M=8191&C,R=C>>>13,O=0|s[8],L=8191&O,N=O>>>13,j=0|s[9],D=8191&j,U=j>>>13,K=0|a[0],H=8191&K,z=K>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],X=8191&J,Z=J>>>13,$=0|a[4],Q=8191&$,ee=$>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,fe=ae>>>13,ue=0|a[8],he=8191&ue,le=ue>>>13,de=0|a[9],pe=8191&de,be=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(f+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,H)|0))<<13)|0;f=((o=Math.imul(l,z))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,z))+Math.imul(b,H)|0,o=Math.imul(b,z);var ve=(f+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;f=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(v,H),i=(i=Math.imul(v,z))+Math.imul(m,H)|0,o=Math.imul(m,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var me=(f+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;f=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,z))+Math.imul(_,H)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(m,F)|0,o=o+Math.imul(m,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var ge=(f+(n=n+Math.imul(h,X)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,X)|0))<<13)|0;f=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,z))+Math.imul(k,H)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(m,G)|0,o=o+Math.imul(m,Y)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,X)|0,o=o+Math.imul(b,Z)|0;var we=(f+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;f=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,z))+Math.imul(I,H)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,X)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(f+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;f=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(P,H),i=(i=Math.imul(P,z))+Math.imul(B,H)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ee=(f+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(l,oe)|0))<<13)|0;f=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(M,H),i=(i=Math.imul(M,z))+Math.imul(R,H)|0,o=Math.imul(R,z),n=n+Math.imul(P,F)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0;var Se=(f+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(l,ce)|0))<<13)|0;f=((o=o+Math.imul(l,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,z))+Math.imul(N,H)|0,o=Math.imul(N,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(P,G)|0,i=(i=i+Math.imul(P,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,X)|0,i=(i=i+Math.imul(x,Z)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,Z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(b,ce)|0,o=o+Math.imul(b,fe)|0;var ke=(f+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;f=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,z))+Math.imul(U,H)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(N,F)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,Z)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(v,ce)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(m,ce)|0,o=o+Math.imul(m,fe)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,le)|0;var Ae=(f+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(l,pe)|0))<<13)|0;f=((o=o+Math.imul(l,be)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(N,G)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(m,he)|0,o=o+Math.imul(m,le)|0;var xe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,X)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,Z)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(S,ce)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(k,ce)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Ie=(f+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,be)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,be)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,Z))+Math.imul(U,X)|0,o=Math.imul(U,Z),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,n=n+Math.imul(x,ce)|0,i=(i=i+Math.imul(x,fe)|0)+Math.imul(I,ce)|0,o=o+Math.imul(I,fe)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,le)|0;var Te=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,be)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,ee))+Math.imul(U,Q)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(P,ce)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(B,ce)|0,o=o+Math.imul(B,fe)|0,n=n+Math.imul(x,he)|0,i=(i=i+Math.imul(x,le)|0)+Math.imul(I,he)|0,o=o+Math.imul(I,le)|0;var Pe=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,se)|0,n=n+Math.imul(M,ce)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(R,ce)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(P,he)|0,i=(i=i+Math.imul(P,le)|0)+Math.imul(B,he)|0,o=o+Math.imul(B,le)|0;var Be=(f+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,be)|0)+Math.imul(I,pe)|0))<<13)|0;f=((o=o+Math.imul(I,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,se))+Math.imul(U,oe)|0,o=Math.imul(U,se),n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(N,ce)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,he)|0,i=(i=i+Math.imul(M,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Ce=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,be)|0)+Math.imul(B,pe)|0))<<13)|0;f=((o=o+Math.imul(B,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,ce),i=(i=Math.imul(D,fe))+Math.imul(U,ce)|0,o=Math.imul(U,fe),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,le)|0;var Me=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,be)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(U,he)|0,o=Math.imul(U,le);var Re=(f+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,be)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,be)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Oe=(f+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,be))+Math.imul(U,pe)|0))<<13)|0;return f=((o=Math.imul(U,be))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,c[0]=ye,c[1]=ve,c[2]=me,c[3]=ge,c[4]=we,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=ke,c[9]=Ae,c[10]=xe,c[11]=Ie,c[12]=Te,c[13]=Pe,c[14]=Be,c[15]=Ce,c[16]=Me,c[17]=Re,c[18]=Oe,0!==f&&(c[19]=f,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(l=h),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?l(this,e,t):r<63?h(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,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,f=0;f=0&&(0!==u||f>=i);f--){var h=0|this.words[f];this.words[f]=u<<26-o|h>>>o,u=h&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=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<=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},o.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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,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 a,c=n.length-i.length;if("mod"!==t){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var f=0;f=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.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),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.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},o.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;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),c=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var u=r.clone(),h=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(u),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(u),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(c)):(r.isub(t),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,u=1;0==(t.words[0]&u)&&f<26;++f,u<<=1);if(f>0)for(t.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}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(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new _(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function g(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},i(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new g;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return b[e]=t,t},_.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),f=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRed(this);0!==this.pow(u,f).cmp(c);)u.redIAdd(c);for(var h=this.pow(u,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var f=t.words[n],u=c-1;u>=0;u--){var h=f>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,_),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:84}],83:[function(e,t,r){var n;function i(e){this.rand=e}if(t.exports=function(e){return n||(n=new i(null)),n.generate(e)},t.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>24]^u[p>>>16&255]^h[b>>>8&255]^l[255&y]^t[v++],s=f[p>>>24]^u[b>>>16&255]^h[y>>>8&255]^l[255&d]^t[v++],a=f[b>>>24]^u[y>>>16&255]^h[d>>>8&255]^l[255&p]^t[v++],c=f[y>>>24]^u[d>>>16&255]^h[p>>>8&255]^l[255&b]^t[v++],d=o,p=s,b=a,y=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^t[v++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[v++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[v++],c=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^t[v++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var f=a^a<<1^a<<2^a<<3^a<<4;f=f>>>8^255&f^99,r[s]=f,n[f]=s;var u=e[s],h=e[u],l=e[h],d=257*e[f]^16843008*f;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*u^16843008*s,o[0][f]=d<<24|d>>>8,o[1][f]=d<<16|d>>>16,o[2][f]=d<<8|d>>>24,o[3][f]=d,0===s?s=a=1:(s=u^e[e[e[l^u]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=n(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/t|0]<<24):t>6&&o%t==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-t]^c}for(var f=[],u=0;u>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=f},c.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},c.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},t.exports.AES=c},{"safe-buffer":298}],86:[function(e,t,r){var n=e("./aes"),Buffer=e("safe-buffer").Buffer,i=e("cipher-base"),o=e("inherits"),s=e("./ghash"),a=e("buffer-xor"),c=e("./incr32");function f(e,t,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(t);var f=this._cipher.encryptBlock(a);this._ghash=new s(f),r=function(e,t,r){if(12===t.length)return e._finID=Buffer.concat([t,Buffer.from([0,0,0,1])]),Buffer.concat([t,Buffer.from([0,0,0,2])]);var n=new s(r),i=t.length,o=i%16;n.update(t),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,f=Buffer.alloc(8);f.writeUIntBE(a,0,8),n.update(f),e._finID=n.state;var u=Buffer.from(e._finID);return c(u),u}(this,r,f),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=e,this._authTag=null,this._called=!1}o(f,i),f.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;t<16&&(t=Buffer.alloc(t,0),this._ghash.update(t))}this._called=!0;var r=this._mode.encrypt(this,e);return this._decrypt?this._ghash.update(e):this._ghash.update(r),this._len+=e.length,r},f.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},u.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(t,!1,r.key,r.iv);return h(e,n.key,n.iv)},r.createDecipheriv=h},{"./aes":85,"./authCipher":86,"./modes":98,"./streamCipher":101,"cipher-base":115,evp_bytestokey:217,inherits:238,"safe-buffer":298}],89:[function(e,t,r){var n=e("./modes"),i=e("./authCipher"),Buffer=e("safe-buffer").Buffer,o=e("./streamCipher"),s=e("cipher-base"),a=e("./aes"),c=e("evp_bytestokey");function f(e,t,r){s.call(this),this._cache=new h,this._cipher=new a.AES(t),this._prev=Buffer.from(r),this._mode=e,this._autopadding=!0}e("inherits")(f,s),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get();)r=this._mode.encrypt(this,t),n.push(r);return Buffer.concat(n)};var u=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(e,t,r){var s=n[e.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof t&&(t=Buffer.from(t)),t.length!==s.key/8)throw new TypeError("invalid key length "+t.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,t,r):"auth"===s.type?new i(s.module,t,r):new f(s.module,t,r)}f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return e=this._mode.encrypt(this,e),this._cipher.scrub(),e;if(!e.equals(u))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=Buffer.concat([this.cache,e])},h.prototype.get=function(){if(this.cache.length>15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},h.prototype.flush=function(){for(var e=16-this.cache.length,t=Buffer.allocUnsafe(e),r=-1;++r>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(e){var t;for(this.cache=Buffer.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,e,0,t])),this.state},t.exports=o},{"safe-buffer":298}],91:[function(e,t,r){t.exports=function(e){for(var t,r=e.length;r--;){if(255!==(t=e.readUInt8(r))){t++,e.writeUInt8(t,r);break}e.writeUInt8(0,r)}}},{}],92:[function(e,t,r){var n=e("buffer-xor");r.encrypt=function(e,t){var r=n(t,e._prev);return e._prev=e._cipher.encryptBlock(r),e._prev},r.decrypt=function(e,t){var r=e._prev;e._prev=t;var i=e._cipher.decryptBlock(t);return n(i,r)}},{"buffer-xor":110}],93:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("buffer-xor");function i(e,t,r){var i=t.length,o=n(t,e._cache);return e._cache=e._cache.slice(i),e._prev=Buffer.concat([e._prev,r?t:o]),o}r.encrypt=function(e,t,r){for(var n,o=Buffer.allocUnsafe(0);t.length;){if(0===e._cache.length&&(e._cache=e._cipher.encryptBlock(e._prev),e._prev=Buffer.allocUnsafe(0)),!(e._cache.length<=t.length)){o=Buffer.concat([o,i(e,t,r)]);break}n=e._cache.length,o=Buffer.concat([o,i(e,t.slice(0,n),r)]),t=t.slice(n)}return o}},{"buffer-xor":110,"safe-buffer":298}],94:[function(e,t,r){var Buffer=e("safe-buffer").Buffer;function n(e,t,r){for(var n,o,s,a=-1,c=0;++a<8;)n=e._cipher.encryptBlock(e._prev),o=t&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,e._prev=i(e._prev,r?o:s);return c}function i(e,t){var r=e.length,n=-1,i=Buffer.allocUnsafe(e.length);for(e=Buffer.concat([e,Buffer.from([t])]);++n>7;return i}r.encrypt=function(e,t,r){for(var i=t.length,o=Buffer.allocUnsafe(i),s=-1;++so)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return f(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),n=s(r),i=n.write(e,t);i!==r&&(n=n.slice(0,i));return n}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function l(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(i)return n?-1:N(e).length;t=(""+t).toLowerCase(),i=!0}}function d(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function p(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),K(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var u=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+h<=r)switch(h){case 1:f<128&&(u=f);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&f)<<6|63&o)>127&&(u=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&f)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return A(this,t,r);case"latin1":case"binary":return x(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,i){if(U(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),u=0;u>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return m(this,e,t,r);case"latin1":case"binary":return g(this,e,t,r);case"base64":return w(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function A(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function B(e,t,r,n,i,o){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function C(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(e,t,r,n,o){return t=+t,r>>>=0,o||C(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function R(e,t,r,n,o){return t=+t,r>>>=0,o||C(e,0,r,8),i.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o>>=0,t>>>=0,r||P(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||P(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||B(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n)||B(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);B(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);B(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||B(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return M(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return M(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function D(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function U(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function K(e){return e!=e}},{"base64-js":112,ieee754:236}],112:[function(e,t,r){"use strict";r.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=function(e){for(var t,r=f(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),c=0,u=s>0?n-4:n,h=0;h>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===s&&(t=i[e.charCodeAt(h)]<<2|i[e.charCodeAt(h+1)]>>4,a[c++]=255&t);1===s&&(t=i[e.charCodeAt(h)]<<10|i[e.charCodeAt(h+1)]<<4|i[e.charCodeAt(h+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},r.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,s=[],a=t;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],113:[function(e,t,r){"use strict";for(var BigInteger=e("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),t.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),t.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),t.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),t.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function u(e){for(var t=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");var t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);var n=(e=t).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+e);if(0===n)throw new Error("Missing prefix for "+e);var a=e.slice(0,n),c=e.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=u(a),l=[],d=0;d=c.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+e);return{prefix:a,words:l}},encode:function(e,t){if(e.length+o+1+t.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=u(e=e.toLowerCase()),s=e+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=f(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&t||t>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,e>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&e),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+f.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:f.scriptType,prefix:t.prefix,hash:Buffer.from(c.slice(1))}},encode:function(e,t,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(t in s))throw new Error("Unsupported script type");return r.encode(e,r.toWords(c(t,n)))}}}).call(this,e("buffer").Buffer)},{"./base32":113,buffer:111}],115:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("stream").Transform,i=e("string_decoder").StringDecoder;function o(e){n.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}e("inherits")(o,n),o.prototype.update=function(e,t,r){"string"==typeof e&&(e=Buffer.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},o.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},o.prototype._finalOrDigest=function(e){var t=this.__final()||Buffer.alloc(0);return e&&(t=this._toString(t,e,!0)),t},o.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new i(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},t.exports=o},{inherits:238,"safe-buffer":298,stream:314,string_decoder:220}],116:[function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}void 0!==t&&(t.exports=n),n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;ir)?t=("rmd160"===e?new a:c(e)).update(t).digest():t.lengths?t=e(t):t.length>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;r<<=7,r|=127&o}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(e,t,r){var n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(var o=0;o=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6}(e,t,r,this.reporter);if(n.length<128)return(i=new Buffer(2))[0]=o,i[1]=n.length,this._createEncoderBuffer([i,n]);for(var a=1,c=n.length;c>=256;c>>=8)a++;(i=new Buffer(2+a))[0]=o,i[1]=128|a;c=1+a;for(var f=n.length;f>0;c--,f>>=8)i[c]=255&f;return this._createEncoderBuffer([i,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var r=new Buffer(2*e.length),n=0;n=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}var i=0;for(n=0;n=128;o>>=7)i++}var s=new Buffer(i),a=s.length-1;for(n=e.length-1;n>=0;n--){o=e[n];for(s[a--]=127&o;(o>>=7)>0;)s[a--]=128|127&o}return this._createEncoderBuffer(s)},c.prototype._encodeTime=function(e,t){var r,n=new Date(e);return"gentime"===t?r=[f(n.getFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},c.prototype._encodeNull=function(){return this._createEncoderBuffer("")},c.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){var r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=new Buffer(r)}if(Buffer.isBuffer(e)){var n=e.length;0===e.length&&n++;var i=new Buffer(n);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);n=1;for(var o=e;o>=256;o>>=8)n++;for(o=(i=new Array(n)).length-1;o>=0;o--)i[o]=255&e,e>>=8;return 128&i[0]&&i.unshift(0),this._createEncoderBuffer(new Buffer(i))},c.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},c.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},c.prototype._skipDefault=function(e,t,r){var n,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n=0||!i.umod(e.prime1)||!i.umod(e.prime2);)i=new r(n(t));return i}t.exports=i,i.getr=o}).call(this,e("buffer").Buffer)},{"bn.js":82,buffer:111,randombytes:282}],139:[function(e,t,r){t.exports=e("./browser/algorithms.json")},{"./browser/algorithms.json":140}],140:[function(e,t,r){t.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],141:[function(e,t,r){t.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],142:[function(e,t,r){(function(Buffer){var r=e("create-hash"),n=e("stream"),i=e("inherits"),o=e("./sign"),s=e("./verify"),a=e("./algorithms.json");function c(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hashType=t.hash,this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function f(e){n.Writable.call(this);var t=a[e];if(!t)throw new Error("Unknown message digest");this._hash=r(t.hash),this._tag=t.id,this._signType=t.sign}function u(e){return new c(e)}function h(e){return new f(e)}Object.keys(a).forEach(function(e){a[e].id=new Buffer(a[e].id,"hex"),a[e.toLowerCase()]=a[e]}),i(c,n.Writable),c.prototype._write=function(e,t,r){this._hash.update(e),r()},c.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},c.prototype.sign=function(e,t){this.end();var r=this._hash.digest(),n=o(r,e,this._hashType,this._signType,this._tag);return t?n.toString(t):n},i(f,n.Writable),f.prototype._write=function(e,t,r){this._hash.update(e),r()},f.prototype.update=function(e,t){return"string"==typeof e&&(e=new Buffer(e,t)),this._hash.update(e),this},f.prototype.verify=function(e,t,r){"string"==typeof t&&(t=new Buffer(t,r)),this.end();var n=this._hash.digest();return s(t,n,e,this._signType,this._tag)},t.exports={Sign:u,Verify:h,createSign:u,createVerify:h}}).call(this,e("buffer").Buffer)},{"./algorithms.json":140,"./sign":143,"./verify":144,buffer:111,"create-hash":119,inherits:238,stream:314}],143:[function(e,t,r){(function(Buffer){var r=e("create-hmac"),n=e("browserify-rsa"),i=e("elliptic").ec,o=e("bn.js"),s=e("parse-asn1"),a=e("./curves.json");function c(e,t,n,i){if((e=new Buffer(e.toArray())).length0&&r.ishrn(n),r}function u(e,t,n){var i,o;do{for(i=new Buffer(0);8*i.length=t)throw new Error("invalid sig")}t.exports=function(e,t,a,c,f){var u=i(a);if("ec"===u.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(e,t,r){var i=o[r.data.algorithm.curve.join(".")];if(!i)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var s=new n(i),a=r.data.subjectPrivateKey.data;return s.verify(t,e,a)}(e,t,u)}if("dsa"===u.type){if("dsa"!==c)throw new Error("wrong public key type");return function(e,t,n){var o=n.data.p,a=n.data.q,c=n.data.g,f=n.data.pub_key,u=i.signature.decode(e,"der"),h=u.s,l=u.r;s(h,a),s(l,a);var d=r.mont(o),p=h.invm(a);return 0===c.toRed(d).redPow(new r(t).mul(p).mod(a)).fromRed().mul(f.toRed(d).redPow(l.mul(p).mod(a)).fromRed()).mod(o).mod(a).cmp(l)}(e,t,u)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");t=Buffer.concat([f,t]);for(var h=u.modulus.byteLength(),l=[1],d=0;t.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=e[r],y=e[b],v=e[y],m=257*e[p]^16843008*p;s[r]=m<<24|m>>>8,a[r]=m<<16|m>>>16,c[r]=m<<8|m>>>24,f[r]=m;m=16843009*v^65537*y^257*b^16843008*r;u[p]=m<<24|m>>>8,h[p]=m<<16|m>>>16,l[p]=m<<8|m>>>24,d[p]=m,r?(r=b^e[e[e[v^b]]],n^=e[e[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],f=0;f>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,s,a,c,f,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,u,h,l,d,o);r=e[t+1];e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,s,a){for(var c=this._nRounds,f=e[t]^r[0],u=e[t+1]^r[1],h=e[t+2]^r[2],l=e[t+3]^r[3],d=4,p=1;p>>24]^i[u>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[u>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&f]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[f>>>8&255]^s[255&u]^r[d++],m=n[l>>>24]^i[f>>>16&255]^o[u>>>8&255]^s[255&h]^r[d++];f=b,u=y,h=v,l=m}b=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[u>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^r[d++],m=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&h])^r[d++];e[t]=b,e[t+1]=y,e[t+2]=v,e[t+3]=m},keySize:8});t.AES=r._createHelper(b)}(),e.AES},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],151:[function(e,t,r){var n,i;n=this,i=function(e){e.lib.Cipher||function(t){var r=e,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),f=r.algo.EvpKDF,u=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:v}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()}),h=(n.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),d=h.CBC=function(){var e=l.extend();function r(e,r,n){var i=this._iv;if(i){var o=i;this._iv=t}else o=this._prevBlock;for(var s=0;s>>2];e.sigBytes-=t}},b=(n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:d,padding:p}),reset:function(){u.reset.call(this);var e=this.cfg,t=e.iv,r=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode=n.call(r,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){e.pad(this._data,this.blockSize);var t=this._process(!0)}else{t=this._process(!0);e.unpad(t)}return t},blockSize:4}),n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext,r=e.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(t);else n=t;return n.toString(c)},parse:function(e){var t=c.parse(e),r=t.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),t.sigBytes-=16}return b.create({ciphertext:t,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:e,mode:s.mode,padding:s.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),m=(r.kdf={}).OpenSSL={execute:function(e,t,r,n){n||(n=o.random(8));var i=f.create({keySize:t+r}).compute(e,n),s=o.create(i.words.slice(t),4*r);return i.sigBytes=4*t,b.create({key:i,iv:s,salt:n})}},g=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:m}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt);return n.iv=i.iv,v.decrypt.call(this,e,t,i.key,n)}})}()},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],152:[function(e,t,r){var n,i;n=this,i=function(){var e=e||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={},o=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)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=void 0!=t?t:4*e.length},toString:function(e){return(e||c).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 o=0;o>>2]>>>24-o%4*8&255;t[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>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=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var r,n=[],i=function(t){t=t;var 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)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},f=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},u=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.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,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,f=e.min(4*c,i);if(c){for(var u=0;u>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],154:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.WordArray,n=t.enc;n.Utf16=n.Utf16BE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,n=[],i=0;i>>1]|=e.charCodeAt(i)<<16-i%2*16;return r.create(n,2*t)}};function i(e){return e<<8&4278255360|e>>>8&16711935}n.Utf16LE={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o>>1]|=i(e.charCodeAt(o)<<16-o%2*16);return r.create(n,2*t)}}}(),e.enc.Utf16},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],155:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,f=0;f>>2]|=e[i]<<24-i%4*8;r.call(this,n,t)}else r.apply(this,arguments)}).prototype=t}}(),e.lib.WordArray},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],160:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var e=0;e<64;e++)a[e]=4294967296*t.abs(t.sin(e+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],d=e[t+2],p=e[t+3],b=e[t+4],y=e[t+5],v=e[t+6],m=e[t+7],g=e[t+8],w=e[t+9],_=e[t+10],E=e[t+11],S=e[t+12],k=e[t+13],A=e[t+14],x=e[t+15],I=o[0],T=o[1],P=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=u(T=u(T=u(T=u(T=f(T=f(T=f(T=f(T,P=f(P,B=f(B,I=f(I,T,P,B,s,7,a[0]),T,P,c,12,a[1]),I,T,d,17,a[2]),B,I,p,22,a[3]),P=f(P,B=f(B,I=f(I,T,P,B,b,7,a[4]),T,P,y,12,a[5]),I,T,v,17,a[6]),B,I,m,22,a[7]),P=f(P,B=f(B,I=f(I,T,P,B,g,7,a[8]),T,P,w,12,a[9]),I,T,_,17,a[10]),B,I,E,22,a[11]),P=f(P,B=f(B,I=f(I,T,P,B,S,7,a[12]),T,P,k,12,a[13]),I,T,A,17,a[14]),B,I,x,22,a[15]),P=u(P,B=u(B,I=u(I,T,P,B,c,5,a[16]),T,P,v,9,a[17]),I,T,E,14,a[18]),B,I,s,20,a[19]),P=u(P,B=u(B,I=u(I,T,P,B,y,5,a[20]),T,P,_,9,a[21]),I,T,x,14,a[22]),B,I,b,20,a[23]),P=u(P,B=u(B,I=u(I,T,P,B,w,5,a[24]),T,P,A,9,a[25]),I,T,p,14,a[26]),B,I,g,20,a[27]),P=u(P,B=u(B,I=u(I,T,P,B,k,5,a[28]),T,P,d,9,a[29]),I,T,m,14,a[30]),B,I,S,20,a[31]),P=h(P,B=h(B,I=h(I,T,P,B,y,4,a[32]),T,P,g,11,a[33]),I,T,E,16,a[34]),B,I,A,23,a[35]),P=h(P,B=h(B,I=h(I,T,P,B,c,4,a[36]),T,P,b,11,a[37]),I,T,m,16,a[38]),B,I,_,23,a[39]),P=h(P,B=h(B,I=h(I,T,P,B,k,4,a[40]),T,P,s,11,a[41]),I,T,p,16,a[42]),B,I,v,23,a[43]),P=h(P,B=h(B,I=h(I,T,P,B,w,4,a[44]),T,P,S,11,a[45]),I,T,x,16,a[46]),B,I,d,23,a[47]),P=l(P,B=l(B,I=l(I,T,P,B,s,6,a[48]),T,P,m,10,a[49]),I,T,A,15,a[50]),B,I,y,21,a[51]),P=l(P,B=l(B,I=l(I,T,P,B,S,6,a[52]),T,P,p,10,a[53]),I,T,_,15,a[54]),B,I,c,21,a[55]),P=l(P,B=l(B,I=l(I,T,P,B,g,6,a[56]),T,P,x,10,a[57]),I,T,v,15,a[58]),B,I,k,21,a[59]),P=l(P,B=l(B,I=l(I,T,P,B,b,6,a[60]),T,P,E,10,a[61]),I,T,d,15,a[62]),B,I,w,21,a[63]),o[0]=o[0]+I|0,o[1]=o[1]+T|0,o[2]=o[2]+P|0,o[3]=o[3]+B|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,f=0;f<4;f++){var u=c[f];c[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function f(e,t,r,n,i,o,s){var a=e+(t&r|~t&n)+i+s;return(a<>>32-o)+t}function u(e,t,r,n,i,o,s){var a=e+(t&n|r&~n)+i+s;return(a<>>32-o)+t}function h(e,t,r,n,i,o,s){var a=e+(t^r^n)+i+s;return(a<>>32-o)+t}function l(e,t,r,n,i,o,s){var a=e+(r^(t|~n))+i+s;return(a<>>32-o)+t}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),e.MD5},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],161:[function(e,t,r){var n,i;n=this,i=function(e){return e.mode.CFB=function(){var t=e.lib.BlockCipherMode.extend();function r(e,t,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var t=e>>16&255,r=e>>8&255,n=255&e;255===t?(t=0,255===r?(r=0,255===n?n=0:++n):++r):++t,e=0,e+=t<<16,e+=r<<8,e+=n}else e+=1<<24;return e}var n=t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(e){0===(e[0]=r(e[0]))&&(e[1]=r(e[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,e.sigBytes+=i},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Ansix923},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152}],167:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso10126={pad:function(t,r){var n=4*r,i=n-t.sigBytes%n;t.concat(e.lib.WordArray.random(i-1)).concat(e.lib.WordArray.create([i<<24],1))},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}},e.pad.Iso10126},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152}],168:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.Iso97971={pad:function(t,r){t.concat(e.lib.WordArray.create([2147483648],1)),e.pad.ZeroPadding.pad(t,r)},unpad:function(t){e.pad.ZeroPadding.unpad(t),t.sigBytes--}},e.pad.Iso97971},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152}],169:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.NoPadding={pad:function(){},unpad:function(){}},e.pad.NoPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152}],170:[function(e,t,r){var n,i;n=this,i=function(e){return e.pad.ZeroPadding={pad:function(e,t){var r=4*t;e.clamp(),e.sigBytes+=r-(e.sigBytes%r||r)},unpad:function(e){for(var t=e.words,r=e.sigBytes-1;!(t[r>>>2]>>>24-r%4*8&255);)r--;e.sigBytes=r+1}},e.pad.ZeroPadding},"object"==typeof r?t.exports=r=i(e("./core"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152}],171:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a,c;return r=(t=e).lib,n=r.Base,i=r.WordArray,o=t.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=this.cfg,n=a.create(r.hasher,e),o=i.create(),s=i.create([1]),c=o.words,f=s.words,u=r.keySize,h=r.iterations;c.length>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],n=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(t){var o=t.words,s=o[0],c=o[1],f=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=f>>>16|4294901760&u,l=u<<16|65535&f;n[0]^=f,n[1]^=h,n[2]^=u,n[3]^=l,n[4]^=f,n[5]^=h,n[6]^=u,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,f=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^f}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.RabbitLegacy=r._createHelper(s)}(),e.RabbitLegacy},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],173:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=[],i=[],o=[],s=t.algo.Rabbit=r.extend({_doReset:function(){for(var e=this._key.words,t=this.cfg.iv,r=0;r<4;r++)e[r]=16711935&(e[r]<<8|e[r]>>>24)|4278255360&(e[r]<<24|e[r]>>>8);var n=this._X=[e[0],e[3]<<16|e[2]>>>16,e[1],e[0]<<16|e[3]>>>16,e[2],e[1]<<16|e[0]>>>16,e[3],e[2]<<16|e[1]>>>16],i=this._C=[e[2]<<16|e[2]>>>16,4294901760&e[0]|65535&e[1],e[3]<<16|e[3]>>>16,4294901760&e[1]|65535&e[2],e[0]<<16|e[0]>>>16,4294901760&e[2]|65535&e[3],e[1]<<16|e[1]>>>16,4294901760&e[3]|65535&e[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(t){var o=t.words,s=o[0],c=o[1],f=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),u=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=f>>>16|4294901760&u,l=u<<16|65535&f;i[0]^=f,i[1]^=h,i[2]^=u,i[3]^=l,i[4]^=f,i[5]^=h,i[6]^=u,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(e,t){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),e[t+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var e=this._X,t=this._C,r=0;r<8;r++)i[r]=t[r];t[0]=t[0]+1295307597+this._b|0,t[1]=t[1]+3545052371+(t[0]>>>0>>0?1:0)|0,t[2]=t[2]+886263092+(t[1]>>>0>>0?1:0)|0,t[3]=t[3]+1295307597+(t[2]>>>0>>0?1:0)|0,t[4]=t[4]+3545052371+(t[3]>>>0>>0?1:0)|0,t[5]=t[5]+886263092+(t[4]>>>0>>0?1:0)|0,t[6]=t[6]+1295307597+(t[5]>>>0>>0?1:0)|0,t[7]=t[7]+3545052371+(t[6]>>>0>>0?1:0)|0,this._b=t[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=e[r]+t[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,f=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^f}e[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,e[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,e[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,e[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,e[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,e[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,e[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,e[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}t.Rabbit=r._createHelper(s)}(),e.Rabbit},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],174:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.StreamCipher,n=t.algo,i=n.RC4=r.extend({_doReset:function(){for(var e=this._key,t=e.words,r=e.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=t[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(e,t){e[t]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var e=this._S,t=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+e[t=(t+1)%256])%256;var o=e[t];e[t]=e[r],e[r]=o,n|=e[(e[t]+e[r])%256]<<24-8*i}return this._i=t,this._j=r,n}t.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var e=this.cfg.drop;e>0;e--)o.call(this)}});t.RC4Drop=r._createHelper(s)}(),e.RC4},"object"==typeof r?t.exports=r=i(e("./core"),e("./enc-base64"),e("./md5"),e("./evpkdf"),e("./cipher-core")):"function"==typeof define&&define.amd?define(["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],i):i(n.CryptoJS)},{"./cipher-core":151,"./core":152,"./enc-base64":153,"./evpkdf":155,"./md5":160}],175:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),f=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,I,T=this._hash.words,P=h.words,B=l.words,C=a.words,M=c.words,R=f.words,O=u.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)I=o+e[t+C[r]]|0,I+=r<16?p(s,d,w)+P[0]:r<32?b(s,d,w)+P[1]:r<48?y(s,d,w)+P[2]:r<64?v(s,d,w)+P[3]:m(s,d,w)+P[4],I=(I=g(I|=0,R[r]))+_|0,o=_,_=w,w=g(d,10),d=s,s=I,I=E+e[t+M[r]]|0,I+=r<16?m(S,k,A)+B[0]:r<32?v(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],I=(I=g(I|=0,O[r]))+x|0,E=x,x=A,A=g(k,10),k=S,S=I;I=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=I},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function p(e,t,r){return e^t^r}function b(e,t,r){return e&t|~e&r}function y(e,t,r){return(e|~t)^r}function v(e,t,r){return e&r|t&~r}function m(e,t,r){return e^(t|~r)}function g(e,t){return e<>>32-t}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),e.RIPEMD160},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],176:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s;return r=(t=e).lib,n=r.WordArray,i=r.Hasher,o=[],s=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],f=0;f<80;f++){if(f<16)o[f]=0|e[t+f];else{var u=o[f-3]^o[f-8]^o[f-14]^o[f-16];o[f]=u<<1|u>>>31}var h=(n<<5|n>>>27)+c+o[f];h+=f<20?1518500249+(i&s|~i&a):f<40?1859775393+(i^s^a):f<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA1=i._createHelper(s),t.HmacSHA1=i._createHmacHelper(s),e.SHA1},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],177:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o;return r=(t=e).lib.WordArray,n=t.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var e=i._doFinalize.call(this);return e.sigBytes-=4,e}}),t.SHA224=i._createHelper(o),t.HmacSHA224=i._createHmacHelper(o),e.SHA224},"object"==typeof r?t.exports=r=i(e("./core"),e("./sha256")):"function"==typeof define&&define.amd?define(["./core","./sha256"],i):i(n.CryptoJS)},{"./core":152,"./sha256":178}],178:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(a[i]=r(t.pow(n,.5))),c[i]=r(t.pow(n,1/3)),i++),n++}();var f=[],u=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],u=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)f[d]=0|e[t+d];else{var p=f[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=f[d-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;f[d]=b+f[d-7]+v+f[d-16]}var m=n&i^n&o^i&o,g=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&u^~a&h)+c[d]+f[d];l=h,h=u,u=a,a=s+w|0,s=o,o=i,i=n,n=w+(g+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+u|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=t.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=o._createHelper(u),r.HmacSHA256=o._createHmacHelper(u)}(Math),e.SHA256},"object"==typeof r?t.exports=r=i(e("./core")):"function"==typeof define&&define.amd?define(["./core"],i):i(n.CryptoJS)},{"./core":152}],179:[function(e,t,r){var n,i;n=this,i=function(e){return function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],f=[],u=[];!function(){for(var e=1,t=0,r=0;r<24;r++){c[e+5*t]=(r+1)*(r+2)/2%64;var n=(2*e+3*t)%5;e=t%5,t=n}for(e=0;e<5;e++)for(t=0;t<5;t++)f[e+5*t]=t+(2*e+3*t)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],m=h[(l+1)%5],g=m.high,w=m.low;for(d=v.high^(g<<1|w>>>31),p=v.low^(w<<1|g>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[f[_]];A.high=d,A.low=p}var x=h[0],I=r[0];x.high=I.high,x.low=I.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],P=h[_],B=h[(l+1)%5+5*b],C=h[(l+2)%5+5*b];T.high=P.high^~B.high&C.high,T.low=P.low^~B.low&C.low}T=r[0];var M=u[a];T.high^=M.high,T.low^=M.low}},_doFinalize:function(){var e=this._data,r=e.words,n=(this._nDataBytes,8*e.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(t.ceil((n+1)/o)*o>>>5)-1]|=128,e.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,f=[],u=0;u>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),f.push(d),f.push(l)}return new i.init(f,a)},clone:function(){for(var e=o.clone.call(this),t=e._state=this._state.slice(0),r=0;r<25;r++)t[r]=t[r].clone();return e}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),e.SHA3},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":152,"./x64-core":183}],180:[function(e,t,r){var n,i;n=this,i=function(e){var t,r,n,i,o,s,a;return r=(t=e).x64,n=r.Word,i=r.WordArray,o=t.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var e=s._doFinalize.call(this);return e.sigBytes-=16,e}}),t.SHA384=s._createHelper(a),t.HmacSHA384=s._createHmacHelper(a),e.SHA384},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core"),e("./sha512")):"function"==typeof define&&define.amd?define(["./core","./x64-core","./sha512"],i):i(n.CryptoJS)},{"./core":152,"./sha512":181,"./x64-core":183}],181:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib.Hasher,n=t.x64,i=n.Word,o=n.WordArray,s=t.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],f=[];!function(){for(var e=0;e<80;e++)f[e]=a()}();var u=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],u=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,v=o.high,m=o.low,g=s.high,w=s.low,_=a.high,E=a.low,S=u.high,k=u.low,A=h.high,x=h.low,I=l.high,T=l.low,P=d,B=p,C=b,M=y,R=v,O=m,L=g,N=w,j=_,D=E,U=S,K=k,H=A,z=x,q=I,F=T,W=0;W<80;W++){var V=f[W];if(W<16)var G=V.high=0|e[t+2*W],Y=V.low=0|e[t+2*W+1];else{var J=f[W-15],X=J.high,Z=J.low,$=(X>>>1|Z<<31)^(X>>>8|Z<<24)^X>>>7,Q=(Z>>>1|X<<31)^(Z>>>8|X<<24)^(Z>>>7|X<<25),ee=f[W-2],te=ee.high,re=ee.low,ne=(te>>>19|re<<13)^(te<<3|re>>>29)^te>>>6,ie=(re>>>19|te<<13)^(re<<3|te>>>29)^(re>>>6|te<<26),oe=f[W-7],se=oe.high,ae=oe.low,ce=f[W-16],fe=ce.high,ue=ce.low;G=(G=(G=$+se+((Y=Q+ae)>>>0>>0?1:0))+ne+((Y=Y+ie)>>>0>>0?1:0))+fe+((Y=Y+ue)>>>0>>0?1:0);V.high=G,V.low=Y}var he,le=j&U^~j&H,de=D&K^~D&z,pe=P&C^P&R^C&R,be=B&M^B&O^M&O,ye=(P>>>28|B<<4)^(P<<30|B>>>2)^(P<<25|B>>>7),ve=(B>>>28|P<<4)^(B<<30|P>>>2)^(B<<25|P>>>7),me=(j>>>14|D<<18)^(j>>>18|D<<14)^(j<<23|D>>>9),ge=(D>>>14|j<<18)^(D>>>18|j<<14)^(D<<23|j>>>9),we=c[W],_e=we.high,Ee=we.low,Se=q+me+((he=F+ge)>>>0>>0?1:0),ke=ve+be;q=H,F=z,H=U,z=K,U=j,K=D,j=L+(Se=(Se=(Se=Se+le+((he=he+de)>>>0>>0?1:0))+_e+((he=he+Ee)>>>0>>0?1:0))+G+((he=he+Y)>>>0>>0?1:0))+((D=N+he|0)>>>0>>0?1:0)|0,L=R,N=O,R=C,O=M,C=P,M=B,P=Se+(ye+pe+(ke>>>0>>0?1:0))+((B=he+ke|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+P+(p>>>0>>0?1:0),y=i.low=y+M,i.high=b+C+(y>>>0>>0?1:0),m=o.low=m+O,o.high=v+R+(m>>>0>>0?1:0),w=s.low=w+N,s.high=g+L+(w>>>0>>0?1:0),E=a.low=E+D,a.high=_+j+(E>>>0>>0?1:0),k=u.low=k+K,u.high=S+U+(k>>>0>>0?1:0),x=h.low=x+z,h.high=A+H+(x>>>0>>0?1:0),T=l.low=T+F,l.high=I+q+(T>>>0>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32});t.SHA512=r._createHelper(u),t.HmacSHA512=r._createHmacHelper(u)}(),e.SHA512},"object"==typeof r?t.exports=r=i(e("./core"),e("./x64-core")):"function"==typeof define&&define.amd?define(["./core","./x64-core"],i):i(n.CryptoJS)},{"./core":152,"./x64-core":183}],182:[function(e,t,r){var n,i;n=this,i=function(e){return function(){var t=e,r=t.lib,n=r.WordArray,i=r.BlockCipher,o=t.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],f=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var e=this._key.words,t=[],r=0;r<56;r++){var n=s[r]-1;t[r]=e[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var f=i[o]=[],u=c[o];for(r=0;r<24;r++)f[r/6|0]|=t[(a[r]-1+u)%28]<<31-r%6,f[4+(r/6|0)]|=t[28+(a[r+24]-1+u)%28]<<31-r%6;f[0]=f[0]<<1|f[0]>>>31;for(r=1;r<7;r++)f[r]=f[r]>>>4*(r-1)+3;f[7]=f[7]<<5|f[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._subKeys)},decryptBlock:function(e,t){this._doCryptBlock(e,t,this._invSubKeys)},_doCryptBlock:function(e,t,r){this._lBlock=e[t],this._rBlock=e[t+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=f[c][((s^i[c])&u[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),e[t]=this._lBlock,e[t+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(e,t){var r=(this._lBlock>>>e^this._rBlock)&t;this._rBlock^=r,this._lBlock^=r<>>e^this._lBlock)&t;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},r.enable(i())}).call(this,e("_process"))},{"./debug":185,_process:250}],185:[function(e,t,r){var n;function i(e){function t(){if(t.enabled){var e=t,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t>>1];r=s.r28shl(r,a),i=s.r28shl(i,a),s.pc2(r,i,e.keys,o)}},c.prototype._update=function(e,t,r,n){var i=this._desState,o=s.readUInt32BE(e,t),a=s.readUInt32BE(e,t+4);s.ip(o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,o,a,i.tmp,0):this._decrypt(i,o,a,i.tmp,0),o=i.tmp[0],a=i.tmp[1],s.writeUInt32BE(r,o,n),s.writeUInt32BE(r,a,n+4)},c.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,o=l}s.rip(a,o,n,i)},c.prototype._decrypt=function(e,t,r,n,i){for(var o=r,a=t,c=e.keys.length-2;c>=0;c-=2){var f=e.keys[c],u=e.keys[c+1];s.expand(o,e.tmp,0),f^=e.tmp[0],u^=e.tmp[1];var h=s.substitute(f,u),l=o;o=(a^s.permute(h))>>>0,a=l}s.rip(o,a,n,i)}},{"../des":186,inherits:238,"minimalistic-assert":245}],190:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits"),o=e("../des"),s=o.Cipher,a=o.DES;function c(e){s.call(this,e);var t=new function(e,t){n.equal(t.length,24,"Invalid key length");var r=t.slice(0,8),i=t.slice(8,16),o=t.slice(16,24);this.ciphers="encrypt"===e?[a.create({type:"encrypt",key:r}),a.create({type:"decrypt",key:i}),a.create({type:"encrypt",key:o})]:[a.create({type:"decrypt",key:o}),a.create({type:"encrypt",key:i}),a.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=t}i(c,s),t.exports=c,c.create=function(e){return new c(e)},c.prototype._update=function(e,t,r,n){var i=this._edeState;i.ciphers[0]._update(e,t,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},c.prototype._pad=a.prototype._pad,c.prototype._unpad=a.prototype._unpad},{"../des":186,inherits:238,"minimalistic-assert":245}],191:[function(e,t,r){"use strict";r.readUInt32BE=function(e,t){return(e[0+t]<<24|e[1+t]<<16|e[2+t]<<8|e[3+t])>>>0},r.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},r.ip=function(e,t,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(e,t,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=t>>>a+s&1,i<<=1,i|=e>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=t>>>a+s&1,o<<=1,o|=e>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(e,t,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(e,t,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},r.padSplit=function(e,t,r){for(var n=e.toString(2);n.lengthe;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),t.cmp(c)){if(!t.cmp(f))for(;r.mod(u).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":82,"miller-rabin":244,randombytes:282}],195:[function(e,t,r){t.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],196:[function(e,t,r){var n=e("assert"),BigInteger=e("bigi"),Point=e("./point");function i(e,t,r,n,i,o,s){this.p=e,this.a=t,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=e.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),Point.fromAffine(this,t,n)},i.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},i.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=t.pow(3).add(n.multiply(t)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},t.exports=i},{"./point":200,assert:23,bigi:32}],197:[function(e,t,r){t.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],198:[function(e,t,r){var Point=e("./point"),n=e("./curve"),i=e("./names");t.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":196,"./names":199,"./point":200}],199:[function(e,t,r){var BigInteger=e("bigi"),n=e("./curves.json"),i=e("./curve");t.exports=function(e){var t=n[e];if(!t)return null;var r=new BigInteger(t.p,16),o=new BigInteger(t.a,16),s=new BigInteger(t.b,16),a=new BigInteger(t.n,16),c=new BigInteger(t.h,16),f=new BigInteger(t.Gx,16),u=new BigInteger(t.Gy,16);return new i(r,o,s,f,u,a,c)}},{"./curve":196,"./curves.json":197,bigi:32}],200:[function(e,t,r){var n=e("assert"),Buffer=e("safe-buffer").Buffer,BigInteger=e("bigi"),i=BigInteger.valueOf(3);function Point(e,t,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=e,this.x=t,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(e,t,r){return new Point(e,t,r,BigInteger.ONE)},Point.prototype.equals=function(e){return e===this||(this.curve.isInfinity(this)?this.curve.isInfinity(e):this.curve.isInfinity(e)?this.curve.isInfinity(this):0===e.y.multiply(this.z).subtract(this.y.multiply(e.z)).mod(this.curve.p).signum()&&0===e.x.multiply(this.z).subtract(this.x.multiply(e.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var e=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,e,this.z)},Point.prototype.add=function(e){if(this.curve.isInfinity(this))return e;if(this.curve.isInfinity(e))return this;var t=this.x,r=this.y,n=e.x,o=e.y.multiply(this.z).subtract(r.multiply(e.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(t.multiply(e.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),f=t.multiply(a),u=o.square().multiply(this.z),h=u.subtract(f.shiftLeft(1)).multiply(e.z).subtract(c).multiply(s).mod(this.curve.p),l=f.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(u.multiply(o)).multiply(e.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(e.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var e=this.x,t=this.y,r=t.multiply(this.z).mod(this.curve.p),n=r.multiply(t).mod(this.curve.p),o=this.curve.a,s=e.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),f=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,f)},Point.prototype.multiply=function(e){if(this.curve.isInfinity(this))return this;if(0===e.signum())return this.curve.infinity;for(var t=e,r=t.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=t.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var s=e.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(t)),--n}return i},Point.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var t,r=this.affineX,n=this.affineY,i=this.curve.pLength;return e?(t=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((t=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(t,1+i)),r.toBuffer(i).copy(t,1),t},Point.decodeFrom=function(e,t){var r,i=t.readUInt8(0),o=4!==i,s=Math.floor((e.p.bitLength()+7)/8),a=BigInteger.fromBuffer(t.slice(1,1+s));if(o){n.equal(t.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=e.pointFromX(c,a)}else{n.equal(t.length,1+s+s,"Invalid sequence length");var f=BigInteger.fromBuffer(t.slice(1+s));r=Point.fromAffine(e,a,f)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},t.exports=Point},{assert:23,bigi:32,"safe-buffer":298}],201:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":216,"./elliptic/curve":204,"./elliptic/curves":207,"./elliptic/ec":208,"./elliptic/eddsa":211,"./elliptic/utils":215,brorand:83}],202:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,s=i.getJSF,a=i.assert;function c(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=c;t--)f=(f<<1)+n[t];s.push(f)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(c=0;c=0;f--){for(t=0;f>=0&&0===s[f];f--)t++;if(f>=0&&t++,c=c.dblp(t),f<0)break;var u=s[f];a(0!==u),c="affine"===e.type?u>0?c.mixedAdd(i[u-1>>1]):c.mixedAdd(i[-u-1>>1].neg()):u>0?c.add(i[u-1>>1]):c.add(i[-u-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,f=this._wnafT3,u=0,h=0;h=1;h-=2){var d=h-1,p=h;if(1===a[d]&&1===a[p]){var b=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(b[1]=t[d].add(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].add(t[p].neg())):(b[1]=t[d].toJ().mixedAdd(t[p]),b[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[d],r[p]);u=Math.max(v[0].length,u),f[d]=new Array(u),f[p]=new Array(u);for(var m=0;m=0;h--){for(var S=0;h>=0;){var k=!0;for(m=0;m=0&&S++,_=_.dblp(S),h<0)break;for(m=0;m0?A=c[m][x-1>>1]:x<0&&(A=c[m][-x-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},f.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),s=o.redSub(r),a=n.redSub(t),c=i.redMul(s),f=o.redMul(a),u=i.redMul(a),h=s.redMul(o);return this.curve.point(c,f,h,u)},Point.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(f=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(f.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),c=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(c),t=s.redMul(f.redSub(o)),r=s.redMul(c)}}else{var f=i.redAdd(o);a=this.curve._mulC(this.z).redSqr(),c=f.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(f)).redMul(c),t=this.curve._mulC(f).redMul(i.redISub(o)),r=f.redMul(c)}return this.curve.point(e,t,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(t),f=o.redMul(s),u=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(f,u,l,h)},Point.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),s=this.y.redMul(e.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),f=i.redAdd(a),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(u);return this.curve.twisted?(t=n.redMul(f).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(f)):(t=n.redMul(f).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(f)),this.curve.point(h,t,r)},Point.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../../elliptic":201,"../curve":204,"bn.js":82,inherits:238}],204:[function(e,t,r){"use strict";var n=r;n.base=e("./base"),n.short=e("./short"),n.mont=e("./mont"),n.edwards=e("./edwards")},{"./base":202,"./edwards":203,"./mont":205,"./short":206}],205:[function(e,t,r){"use strict";var n=e("../curve"),i=e("bn.js"),o=e("inherits"),s=n.base,a=e("../../elliptic").utils;function c(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(c,s),t.exports=c,c.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},o(Point,s.BasePoint),c.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},c.prototype.point=function(e,t){return new Point(this,e,t)},c.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1]||e.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),s=i.redMul(n),a=t.z.redMul(o.redAdd(s).redSqr()),c=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../../elliptic":201,"../curve":204,"bn.js":82,inherits:238}],206:[function(e,t,r){"use strict";var n=e("../curve"),i=e("../../elliptic"),o=e("bn.js"),s=e("inherits"),a=n.base,c=i.utils.assert;function f(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(r,16),this.z=new o(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(f,a),t.exports=f,f.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?r=i[0]:(r=i[1],c(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(r)}}},f.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),r=new o(2).toRed(t).redInvm(),n=r.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},f.prototype._getEndoBasis=function(e){for(var t,r,n,i,s,a,c,f,u,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=e,d=this.n.clone(),p=new o(1),b=new o(0),y=new o(0),v=new o(1),m=0;0!==l.cmpn(0);){var g=d.div(l);f=d.sub(g.mul(l)),u=y.sub(g.mul(p));var w=v.sub(g.mul(b));if(!n&&f.cmp(h)<0)t=c.neg(),r=p,n=f.neg(),i=u;else if(n&&2==++m)break;c=f,d=l,l=f,y=p,p=u,v=b,b=w}s=f.neg(),a=u;var _=n.sqr().add(i.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},f.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:c.add(f).neg()}},f.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},f.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},f.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Point.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(u,a.BasePoint),f.prototype.jpoint=function(e,t,r){return new u(this,e,t,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=a.redSqr(),u=f.redMul(a),h=n.redMul(f),l=c.redSqr().redIAdd(u).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(u)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},u.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),u=r.redMul(c),h=a.redSqr().redIAdd(f).redISub(u).redISub(u),l=a.redMul(u.redISub(h)).redISub(i.redMul(f)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},u.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":201,"../curve":204,"bn.js":82,inherits:238}],207:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),s=e("../elliptic"),a=s.utils.assert;function c(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":201,"./precomputed/secp256k1":214,"hash.js":223}],208:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("hmac-drbg"),o=e("../../elliptic"),s=o.utils.assert,a=e("./key"),c=e("./signature");function f(e){if(!(this instanceof f))return new f(e);"string"==typeof e&&(s(o.curves.hasOwnProperty(e),"Unknown curve "+e),e=o.curves[e]),e instanceof o.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=f,f.prototype.keyPair=function(e){return new a(this,e)},f.prototype.keyFromPrivate=function(e,t){return a.fromPrivate(this,e,t)},f.prototype.keyFromPublic=function(e,t){return a.fromPublic(this,e,t)},f.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||o.rand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),s=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(s)>0))return a.iaddn(1),this.keyFromPrivate(a)}},f.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},f.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),a=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:f,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(v=v.umod(this.n)).cmpn(0)){var m=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),m^=1),new c({r:y,s:v,recoveryParam:m})}}}}}},f.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,f=s.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},f.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),f=t.r,u=t.s,h=1&r,l=r>>1;if(f.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");f=l?this.curve.pointFromX(f.add(this.curve.n),h):this.curve.pointFromX(f,h);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),b=u.mul(d).umod(o);return this.g.mulAdd(p,f,b)},f.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":201,"./key":209,"./signature":210,"bn.js":82,"hmac-drbg":235}],209:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":201,"bn.js":82}],210:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var c=a(e,r);if(e.length!==c+r.place)return!1;var f=e.slice(r.place,c+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===f[0]&&128&f[1]&&(f=f.slice(1)),this.r=new n(s),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var o=n.concat(r),s=[48];return f(s,o.length),s=s.concat(o),i.encode(s,e)}},{"../../elliptic":201,"bn.js":82}],211:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../../elliptic"),o=i.utils,s=o.assert,a=o.parseBytes,c=e("./key"),f=e("./signature");function u(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof u))return new u(e);e=i.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}t.exports=u,u.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},u.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},u.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,c=1;c0||t.cmpn(-i)>0;){var o,s,a,c=e.andln(3)+n&3,f=t.andln(3)+i&3;3===c&&(c=-1),3===f&&(f=-1),o=0==(1&c)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==f?c:-c,r[0].push(o),s=0==(1&f)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==c?f:-f,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":82,"minimalistic-assert":245,"minimalistic-crypto-utils":246}],216:[function(e,t,r){t.exports={_from:"elliptic@^6.2.3",_id:"elliptic@6.4.1",_inBundle:!1,_integrity:"sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.2.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.2.3",saveSpec:null,fetchSpec:"^6.2.3"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",_shasum:"c2d0b7776911b86722c632c3c06c60f2f819939a",_spec:"elliptic@^6.2.3",_where:"/work/blocktrail-sdk-nodejs/node_modules/secp256k1",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.1"}},{}],217:[function(e,t,r){var Buffer=e("safe-buffer").Buffer,n=e("md5.js");t.exports=function(e,t,r,i){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),t&&(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var f=new n;f.update(c),f.update(e),t&&f.update(t),c=f.digest();var u=0;if(o>0){var h=s.length-o;u=Math.min(o,c.length),c.copy(s,h,0,u),o-=u}if(u0){var l=a.length-i,d=Math.min(i,c.length-u);c.copy(a,l,u,u+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":242,"safe-buffer":298}],218:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,a,c,f;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}if(s(r=this._events[e]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(f=r.slice()).length,c=0;c0&&this._events[e].length>r&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var r,n,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,n=-1,r===t||i(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(a=s;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],219:[function(e,t,r){(function(e){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,f=2147483647,u=36,h=1,l=26,d=38,p=700,b=72,y=128,v="-",m=/^xn--/,g=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=u-h,S=Math.floor,k=String.fromCharCode;function A(e){throw new RangeError(_[e])}function x(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function I(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+x((e=e.replace(w,".")).split("."),t).join(".")}function T(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)}).join("")}function B(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function C(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>E*l>>1;n+=u)e=S(e/E);return S(n+(E+1)*e/(e+d))}function M(e){var t,r,n,i,o,s,a,c,d,p,m,g=[],w=e.length,_=0,E=y,k=b;for((r=e.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),g.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(m=e.charCodeAt(i++))-48<10?m-22:m-65<26?m-65:m-97<26?m-97:u)>=u||c>S((f-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=u)s>S(f/(p=u-d))&&A("overflow"),s*=p;k=C(_-o,t=g.length+1,0==o),S(_/t)>f-E&&A("overflow"),E+=S(_/t),_%=t,g.splice(_++,0,E)}return P(g)}function R(e){var t,r,n,i,o,s,a,c,d,p,m,g,w,_,E,x=[];for(g=(e=T(e)).length,t=y,r=0,o=b,s=0;s=t&&mS((f-r)/(w=n+1))&&A("overflow"),r+=(a-t)*w,t=a,s=0;sf&&A("overflow"),m==t){for(c=r,d=u;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=u)E=c-p,_=u-p,x.push(k(B(p+E%_,0))),c=S(E/_);x.push(k(B(c,0))),o=C(r,w,n==i),r=0,++n}++r,++t}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:P},decode:M,encode:R,toASCII:function(e){return I(e,function(e){return g.test(e)?"xn--"+R(e):e})},toUnicode:function(e){return I(e,function(e){return m.test(e)?M(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return a});else if(i&&o)if(t.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],220:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=Buffer.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(Buffer.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=a,this.end=c,t=4;break;case"utf8":this.fillLast=s,t=4;break;case"base64":this.text=f,this.end=u,t=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(r);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(r+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(r+2)}}(this,e,t);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":298}],221:[function(require,module,exports){var indexOf=require("indexof"),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=i},{inherits:238,"safe-buffer":298,stream:314}],223:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":224,"./hash/hmac":225,"./hash/ripemd":226,"./hash/sha":227,"./hash/utils":234}],224:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":234}],234:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(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}r.inherits=i,r.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),i=0;i>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,f=t;return c+=(f=f+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,f){var u=0,h=t;return u+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,f){return t+n+o+a+f>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:238,"minimalistic-assert":245}],235:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("minimalistic-crypto-utils"),o=e("minimalistic-assert");function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,u=-7,h=r?i-1:0,l=r?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=l,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=l,u-=8);if(0===o)o=1-f;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var s,a,c,f=8*o-i-1,u=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,f-=8);e[r+d-p]|=128*b}},{}],237:[function(e,t,r){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;r>>1,D=[["ary",E],["bind",b],["bindKey",y],["curry",m],["curryRight",g],["flip",k],["partial",w],["partialRight",_],["rearg",S]],U="[object Arguments]",K="[object Array]",H="[object AsyncFunction]",z="[object Boolean]",q="[object Date]",F="[object DOMException]",W="[object Error]",V="[object Function]",G="[object GeneratorFunction]",Y="[object Map]",J="[object Number]",X="[object Null]",Z="[object Object]",$="[object Proxy]",Q="[object RegExp]",ee="[object Set]",te="[object String]",re="[object Symbol]",ne="[object Undefined]",ie="[object WeakMap]",oe="[object WeakSet]",se="[object ArrayBuffer]",ae="[object DataView]",ce="[object Float32Array]",fe="[object Float64Array]",ue="[object Int8Array]",he="[object Int16Array]",le="[object Int32Array]",de="[object Uint8Array]",pe="[object Uint8ClampedArray]",be="[object Uint16Array]",ye="[object Uint32Array]",ve=/\b__p \+= '';/g,me=/\b(__p \+=) '' \+/g,ge=/(__e\(.*?\)|\b__t\)) \+\n'';/g,we=/&(?:amp|lt|gt|quot|#39);/g,_e=/[&<>"']/g,Ee=RegExp(we.source),Se=RegExp(_e.source),ke=/<%-([\s\S]+?)%>/g,Ae=/<%([\s\S]+?)%>/g,xe=/<%=([\s\S]+?)%>/g,Ie=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Te=/^\w*$/,Pe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Be=/[\\^$.*+?()[\]{}|]/g,Ce=RegExp(Be.source),Me=/^\s+|\s+$/g,Re=/^\s+/,Oe=/\s+$/,Le=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ne=/\{\n\/\* \[wrapped with (.+)\] \*/,je=/,? & /,De=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ue=/\\(\\)?/g,Ke=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,He=/\w*$/,ze=/^[-+]0x[0-9a-f]+$/i,qe=/^0b[01]+$/i,Fe=/^\[object .+?Constructor\]$/,We=/^0o[0-7]+$/i,Ve=/^(?:0|[1-9]\d*)$/,Ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ye=/($^)/,Je=/['\n\r\u2028\u2029\\]/g,Xe="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ze="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$e="[\\ud800-\\udfff]",Qe="["+Ze+"]",et="["+Xe+"]",tt="\\d+",rt="[\\u2700-\\u27bf]",nt="[a-z\\xdf-\\xf6\\xf8-\\xff]",it="[^\\ud800-\\udfff"+Ze+tt+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",ot="\\ud83c[\\udffb-\\udfff]",st="[^\\ud800-\\udfff]",at="(?:\\ud83c[\\udde6-\\uddff]){2}",ct="[\\ud800-\\udbff][\\udc00-\\udfff]",ft="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ut="(?:"+nt+"|"+it+")",ht="(?:"+ft+"|"+it+")",lt="(?:"+et+"|"+ot+")"+"?",dt="[\\ufe0e\\ufe0f]?"+lt+("(?:\\u200d(?:"+[st,at,ct].join("|")+")[\\ufe0e\\ufe0f]?"+lt+")*"),pt="(?:"+[rt,at,ct].join("|")+")"+dt,bt="(?:"+[st+et+"?",et,at,ct,$e].join("|")+")",yt=RegExp("['’]","g"),vt=RegExp(et,"g"),mt=RegExp(ot+"(?="+ot+")|"+bt+dt,"g"),gt=RegExp([ft+"?"+nt+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[Qe,ft,"$"].join("|")+")",ht+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[Qe,ft+ut,"$"].join("|")+")",ft+"?"+ut+"+(?:['’](?:d|ll|m|re|s|t|ve))?",ft+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt,pt].join("|"),"g"),wt=RegExp("[\\u200d\\ud800-\\udfff"+Xe+"\\ufe0e\\ufe0f]"),_t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],St=-1,kt={};kt[ce]=kt[fe]=kt[ue]=kt[he]=kt[le]=kt[de]=kt[pe]=kt[be]=kt[ye]=!0,kt[U]=kt[K]=kt[se]=kt[z]=kt[ae]=kt[q]=kt[W]=kt[V]=kt[Y]=kt[J]=kt[Z]=kt[Q]=kt[ee]=kt[te]=kt[ie]=!1;var At={};At[U]=At[K]=At[se]=At[ae]=At[z]=At[q]=At[ce]=At[fe]=At[ue]=At[he]=At[le]=At[Y]=At[J]=At[Z]=At[Q]=At[ee]=At[te]=At[re]=At[de]=At[pe]=At[be]=At[ye]=!0,At[W]=At[V]=At[ie]=!1;var xt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},It=parseFloat,Tt=parseInt,Pt="object"==typeof e&&e&&e.Object===Object&&e,Bt="object"==typeof self&&self&&self.Object===Object&&self,Ct=Pt||Bt||Function("return this")(),Mt="object"==typeof r&&r&&!r.nodeType&&r,Rt=Mt&&"object"==typeof t&&t&&!t.nodeType&&t,Ot=Rt&&Rt.exports===Mt,Lt=Ot&&Pt.process,Nt=function(){try{var e=Rt&&Rt.require&&Rt.require("util").types;return e||Lt&&Lt.binding&&Lt.binding("util")}catch(e){}}(),jt=Nt&&Nt.isArrayBuffer,Dt=Nt&&Nt.isDate,Ut=Nt&&Nt.isMap,Kt=Nt&&Nt.isRegExp,Ht=Nt&&Nt.isSet,zt=Nt&&Nt.isTypedArray;function qt(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Ft(e,t,r,n){for(var i=-1,o=null==e?0:e.length;++i-1}function Xt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n-1;);return r}function mr(e,t){for(var r=e.length;r--&&or(t,e[r],0)>-1;);return r}var gr=ur({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),wr=ur({"&":"&","<":"<",">":">",'"':""","'":"'"});function _r(e){return"\\"+xt[e]}function Er(e){return wt.test(e)}function Sr(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function kr(e,t){return function(r){return e(t(r))}}function Ar(e,t){for(var r=-1,n=e.length,i=0,o=[];++r",""":'"',"'":"'"});var Cr=function e(t){var r,Xe=(t=null==t?Ct:Cr.defaults(Ct.Object(),t,Cr.pick(Ct,Et))).Array,Ze=t.Date,$e=t.Error,Qe=t.Function,et=t.Math,tt=t.Object,rt=t.RegExp,nt=t.String,it=t.TypeError,ot=Xe.prototype,st=Qe.prototype,at=tt.prototype,ct=t["__core-js_shared__"],ft=st.toString,ut=at.hasOwnProperty,ht=0,lt=(r=/[^.]+$/.exec(ct&&ct.keys&&ct.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",dt=at.toString,pt=ft.call(tt),bt=Ct._,mt=rt("^"+ft.call(ut).replace(Be,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Ot?t.Buffer:n,wt=t.Symbol,xt=t.Uint8Array,Pt=Buffer?Buffer.allocUnsafe:n,Bt=kr(tt.getPrototypeOf,tt),Mt=tt.create,Rt=at.propertyIsEnumerable,Lt=ot.splice,Nt=wt?wt.isConcatSpreadable:n,rr=wt?wt.iterator:n,ur=wt?wt.toStringTag:n,Mr=function(){try{var e=Do(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),Rr=t.clearTimeout!==Ct.clearTimeout&&t.clearTimeout,Or=Ze&&Ze.now!==Ct.Date.now&&Ze.now,Lr=t.setTimeout!==Ct.setTimeout&&t.setTimeout,Nr=et.ceil,jr=et.floor,Dr=tt.getOwnPropertySymbols,Ur=Buffer?Buffer.isBuffer:n,Kr=t.isFinite,Hr=ot.join,zr=kr(tt.keys,tt),qr=et.max,Fr=et.min,Wr=Ze.now,Vr=t.parseInt,Gr=et.random,Yr=ot.reverse,Jr=Do(t,"DataView"),Xr=Do(t,"Map"),Zr=Do(t,"Promise"),$r=Do(t,"Set"),Qr=Do(t,"WeakMap"),en=Do(tt,"create"),tn=Qr&&new Qr,rn={},nn=us(Jr),on=us(Xr),sn=us(Zr),an=us($r),cn=us(Qr),fn=wt?wt.prototype:n,un=fn?fn.valueOf:n,hn=fn?fn.toString:n;function ln(e){if(Ia(e)&&!ya(e)&&!(e instanceof yn)){if(e instanceof bn)return e;if(ut.call(e,"__wrapped__"))return hs(e)}return new bn(e)}var dn=function(){function e(){}return function(t){if(!xa(t))return{};if(Mt)return Mt(t);e.prototype=t;var r=new e;return e.prototype=n,r}}();function pn(){}function bn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function yn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=L,this.__views__=[]}function vn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function On(e,t,r,i,o,s){var a,c=t&u,f=t&h,d=t&l;if(r&&(a=o?r(e,i,o,s):r(e)),a!==n)return a;if(!xa(e))return e;var p=ya(e);if(p){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ut.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!c)return to(e,a)}else{var b=Ho(e),y=b==V||b==G;if(wa(e))return Ji(e,c);if(b==Z||b==U||y&&!o){if(a=f||y?{}:qo(e),!c)return f?function(e,t){return ro(e,Ko(e),t)}(e,function(e,t){return e&&ro(t,ic(t),e)}(a,e)):function(e,t){return ro(e,Uo(e),t)}(e,Bn(a,e))}else{if(!At[b])return o?e:{};a=function(e,t,r){var n,i,o,s=e.constructor;switch(t){case se:return Xi(e);case z:case q:return new s(+e);case ae:return function(e,t){var r=t?Xi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case ce:case fe:case ue:case he:case le:case de:case pe:case be:case ye:return Zi(e,r);case Y:return new s;case J:case te:return new s(e);case Q:return(o=new(i=e).constructor(i.source,He.exec(i))).lastIndex=i.lastIndex,o;case ee:return new s;case re:return n=e,un?tt(un.call(n)):{}}}(e,b,c)}}s||(s=new _n);var v=s.get(e);if(v)return v;if(s.set(e,a),Ma(e))return e.forEach(function(n){a.add(On(n,t,r,n,e,s))}),a;if(Ta(e))return e.forEach(function(n,i){a.set(i,On(n,t,r,i,e,s))}),a;var m=p?n:(d?f?Co:Bo:f?ic:nc)(e);return Wt(m||e,function(n,i){m&&(n=e[i=n]),In(a,i,On(n,t,r,i,e,s))}),a}function Ln(e,t,r){var i=r.length;if(null==e)return!i;for(e=tt(e);i--;){var o=r[i],s=t[o],a=e[o];if(a===n&&!(o in e)||!s(a))return!1}return!0}function Nn(e,t,r){if("function"!=typeof e)throw new it(s);return ns(function(){e.apply(n,r)},t)}function jn(e,t,r,n){var o=-1,s=Jt,a=!0,c=e.length,f=[],u=t.length;if(!c)return f;r&&(t=Zt(t,pr(r))),n?(s=Xt,a=!1):t.length>=i&&(s=yr,a=!1,t=new wn(t));e:for(;++o-1},mn.prototype.set=function(e,t){var r=this.__data__,n=Tn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},gn.prototype.clear=function(){this.size=0,this.__data__={hash:new vn,map:new(Xr||mn),string:new vn}},gn.prototype.delete=function(e){var t=No(this,e).delete(e);return this.size-=t?1:0,t},gn.prototype.get=function(e){return No(this,e).get(e)},gn.prototype.has=function(e){return No(this,e).has(e)},gn.prototype.set=function(e,t){var r=No(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(e){return this.__data__.set(e,a),this},wn.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.clear=function(){this.__data__=new mn,this.size=0},_n.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},_n.prototype.get=function(e){return this.__data__.get(e)},_n.prototype.has=function(e){return this.__data__.has(e)},_n.prototype.set=function(e,t){var r=this.__data__;if(r instanceof mn){var n=r.__data__;if(!Xr||n.length0&&r(a)?t>1?qn(a,t-1,r,n,i):$t(i,a):n||(i[i.length]=a)}return i}var Fn=so(),Wn=so(!0);function Vn(e,t){return e&&Fn(e,t,nc)}function Gn(e,t){return e&&Wn(e,t,nc)}function Yn(e,t){return Yt(t,function(t){return Sa(e[t])})}function Jn(e,t){for(var r=0,i=(t=Wi(t,e)).length;null!=e&&rt}function Qn(e,t){return null!=e&&ut.call(e,t)}function ei(e,t){return null!=e&&t in tt(e)}function ti(e,t,r){for(var i=r?Xt:Jt,o=e[0].length,s=e.length,a=s,c=Xe(s),f=1/0,u=[];a--;){var h=e[a];a&&t&&(h=Zt(h,pr(t))),f=Fr(h.length,f),c[a]=!r&&(t||o>=120&&h.length>=120)?new wn(a&&h):n}h=e[0];var l=-1,d=c[0];e:for(;++l=a)return c;var f=r[n];return c*("desc"==f?-1:1)}}return e.index-t.index}(e,t,r)})}function vi(e,t,r){for(var n=-1,i=t.length,o={};++n-1;)a!==e&&Lt.call(a,c,1),Lt.call(e,c,1);return e}function gi(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;Wo(i)?Lt.call(e,i,1):ji(e,i)}}return e}function wi(e,t){return e+jr(Gr()*(t-e+1))}function _i(e,t){var r="";if(!e||t<1||t>M)return r;do{t%2&&(r+=e),(t=jr(t/2))&&(e+=e)}while(t);return r}function Ei(e,t){return is(Qo(e,t,Pc),e+"")}function Si(e){return Sn(lc(e))}function ki(e,t){var r=lc(e);return as(r,Rn(t,0,r.length))}function Ai(e,t,r,i){if(!xa(e))return e;for(var o=-1,s=(t=Wi(t,e)).length,a=s-1,c=e;null!=c&&++oi?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Xe(i);++n>>1,s=e[o];null!==s&&!Oa(s)&&(r?s<=t:s=i){var u=t?null:Eo(e);if(u)return xr(u);a=!1,o=yr,f=new wn}else f=t?[]:c;e:for(;++n=i?e:Pi(e,t,r)}var Yi=Rr||function(e){return Ct.clearTimeout(e)};function Ji(e,t){if(t)return e.slice();var r=e.length,n=Pt?Pt(r):new e.constructor(r);return e.copy(n),n}function Xi(e){var t=new e.constructor(e.byteLength);return new xt(t).set(new xt(e)),t}function Zi(e,t){var r=t?Xi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function $i(e,t){if(e!==t){var r=e!==n,i=null===e,o=e==e,s=Oa(e),a=t!==n,c=null===t,f=t==t,u=Oa(t);if(!c&&!u&&!s&&e>t||s&&a&&f&&!c&&!u||i&&a&&f||!r&&f||!o)return 1;if(!i&&!s&&!u&&e1?r[o-1]:n,a=o>2?r[2]:n;for(s=e.length>3&&"function"==typeof s?(o--,s):n,a&&Vo(r[0],r[1],a)&&(s=o<3?n:s,o=1),t=tt(t);++i-1?o[s?t[a]:a]:n}}function ho(e){return Po(function(t){var r=t.length,i=r,o=bn.prototype.thru;for(e&&t.reverse();i--;){var a=t[i];if("function"!=typeof a)throw new it(s);if(o&&!c&&"wrapper"==Ro(a))var c=new bn([],!0)}for(i=c?i:r;++i1&&m.reverse(),h&&fc))return!1;var u=s.get(e);if(u&&s.get(t))return u==t;var h=-1,l=!0,b=r&p?new wn:n;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(Le,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Wt(D,function(r){var n="_."+r[0];t&r[1]&&!Jt(e,n)&&e.push(n)}),e.sort()}(function(e){var t=e.match(Ne);return t?t[1].split(je):[]}(n),r)))}function ss(e){var t=0,r=0;return function(){var i=Wr(),o=T-(i-r);if(r=i,o>0){if(++t>=I)return arguments[0]}else t=0;return e.apply(n,arguments)}}function as(e,t){var r=-1,i=e.length,o=i-1;for(t=t===n?i:t;++r1?e[t-1]:n;return Cs(e,r="function"==typeof r?(e.pop(),r):n)});function Ds(e){var t=ln(e);return t.__chain__=!0,t}function Us(e,t){return t(e)}var Ks=Po(function(e){var t=e.length,r=t?e[0]:0,i=this.__wrapped__,o=function(t){return Mn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof yn&&Wo(r)?((i=i.slice(r,+r+(t?1:0))).__actions__.push({func:Us,args:[o],thisArg:n}),new bn(i,this.__chain__).thru(function(e){return t&&!e.length&&e.push(n),e})):this.thru(o)});var Hs=no(function(e,t,r){ut.call(e,r)?++e[r]:Cn(e,r,1)});var zs=uo(bs),qs=uo(ys);function Fs(e,t){return(ya(e)?Wt:Dn)(e,Lo(t,3))}function Ws(e,t){return(ya(e)?Vt:Un)(e,Lo(t,3))}var Vs=no(function(e,t,r){ut.call(e,r)?e[r].push(t):Cn(e,r,[t])});var Gs=Ei(function(e,t,r){var n=-1,i="function"==typeof t,o=ma(e)?Xe(e.length):[];return Dn(e,function(e){o[++n]=i?qt(t,e,r):ri(e,t,r)}),o}),Ys=no(function(e,t,r){Cn(e,r,t)});function Js(e,t){return(ya(e)?Zt:hi)(e,Lo(t,3))}var Xs=no(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var Zs=Ei(function(e,t){if(null==e)return[];var r=t.length;return r>1&&Vo(e,t[0],t[1])?t=[]:r>2&&Vo(t[0],t[1],t[2])&&(t=[t[0]]),yi(e,qn(t,1),[])}),$s=Or||function(){return Ct.Date.now()};function Qs(e,t,r){return t=r?n:t,t=e&&null==t?e.length:t,ko(e,E,n,n,n,n,t)}function ea(e,t){var r;if("function"!=typeof t)throw new it(s);return e=Ka(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var ta=Ei(function(e,t,r){var n=b;if(r.length){var i=Ar(r,Oo(ta));n|=w}return ko(e,n,t,r,i)}),ra=Ei(function(e,t,r){var n=b|y;if(r.length){var i=Ar(r,Oo(ra));n|=w}return ko(t,n,e,r,i)});function na(e,t,r){var i,o,a,c,f,u,h=0,l=!1,d=!1,p=!0;if("function"!=typeof e)throw new it(s);function b(t){var r=i,s=o;return i=o=n,h=t,c=e.apply(s,r)}function y(e){var r=e-u;return u===n||r>=t||r<0||d&&e-h>=a}function v(){var e=$s();if(y(e))return m(e);f=ns(v,function(e){var r=t-(e-u);return d?Fr(r,a-(e-h)):r}(e))}function m(e){return f=n,p&&i?b(e):(i=o=n,c)}function g(){var e=$s(),r=y(e);if(i=arguments,o=this,u=e,r){if(f===n)return function(e){return h=e,f=ns(v,t),l?b(e):c}(u);if(d)return f=ns(v,t),b(u)}return f===n&&(f=ns(v,t)),c}return t=za(t)||0,xa(r)&&(l=!!r.leading,a=(d="maxWait"in r)?qr(za(r.maxWait)||0,t):a,p="trailing"in r?!!r.trailing:p),g.cancel=function(){f!==n&&Yi(f),h=0,i=u=o=f=n},g.flush=function(){return f===n?c:m($s())},g}var ia=Ei(function(e,t){return Nn(e,1,t)}),oa=Ei(function(e,t,r){return Nn(e,za(t)||0,r)});function sa(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new it(s);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(sa.Cache||gn),r}function aa(e){if("function"!=typeof e)throw new it(s);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}sa.Cache=gn;var ca=Vi(function(e,t){var r=(t=1==t.length&&ya(t[0])?Zt(t[0],pr(Lo())):Zt(qn(t,1),pr(Lo()))).length;return Ei(function(n){for(var i=-1,o=Fr(n.length,r);++i=t}),ba=ni(function(){return arguments}())?ni:function(e){return Ia(e)&&ut.call(e,"callee")&&!Rt.call(e,"callee")},ya=Xe.isArray,va=jt?pr(jt):function(e){return Ia(e)&&Zn(e)==se};function ma(e){return null!=e&&Aa(e.length)&&!Sa(e)}function ga(e){return Ia(e)&&ma(e)}var wa=Ur||zc,_a=Dt?pr(Dt):function(e){return Ia(e)&&Zn(e)==q};function Ea(e){if(!Ia(e))return!1;var t=Zn(e);return t==W||t==F||"string"==typeof e.message&&"string"==typeof e.name&&!Ba(e)}function Sa(e){if(!xa(e))return!1;var t=Zn(e);return t==V||t==G||t==H||t==$}function ka(e){return"number"==typeof e&&e==Ka(e)}function Aa(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=M}function xa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ia(e){return null!=e&&"object"==typeof e}var Ta=Ut?pr(Ut):function(e){return Ia(e)&&Ho(e)==Y};function Pa(e){return"number"==typeof e||Ia(e)&&Zn(e)==J}function Ba(e){if(!Ia(e)||Zn(e)!=Z)return!1;var t=Bt(e);if(null===t)return!0;var r=ut.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ft.call(r)==pt}var Ca=Kt?pr(Kt):function(e){return Ia(e)&&Zn(e)==Q};var Ma=Ht?pr(Ht):function(e){return Ia(e)&&Ho(e)==ee};function Ra(e){return"string"==typeof e||!ya(e)&&Ia(e)&&Zn(e)==te}function Oa(e){return"symbol"==typeof e||Ia(e)&&Zn(e)==re}var La=zt?pr(zt):function(e){return Ia(e)&&Aa(e.length)&&!!kt[Zn(e)]};var Na=go(ui),ja=go(function(e,t){return e<=t});function Da(e){if(!e)return[];if(ma(e))return Ra(e)?Pr(e):to(e);if(rr&&e[rr])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[rr]());var t=Ho(e);return(t==Y?Sr:t==ee?xr:lc)(e)}function Ua(e){return e?(e=za(e))===C||e===-C?(e<0?-1:1)*R:e==e?e:0:0===e?e:0}function Ka(e){var t=Ua(e),r=t%1;return t==t?r?t-r:t:0}function Ha(e){return e?Rn(Ka(e),0,L):0}function za(e){if("number"==typeof e)return e;if(Oa(e))return O;if(xa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=xa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Me,"");var r=qe.test(e);return r||We.test(e)?Tt(e.slice(2),r?2:8):ze.test(e)?O:+e}function qa(e){return ro(e,ic(e))}function Fa(e){return null==e?"":Li(e)}var Wa=io(function(e,t){if(Xo(t)||ma(t))ro(t,nc(t),e);else for(var r in t)ut.call(t,r)&&In(e,r,t[r])}),Va=io(function(e,t){ro(t,ic(t),e)}),Ga=io(function(e,t,r,n){ro(t,ic(t),e,n)}),Ya=io(function(e,t,r,n){ro(t,nc(t),e,n)}),Ja=Po(Mn);var Xa=Ei(function(e,t){e=tt(e);var r=-1,i=t.length,o=i>2?t[2]:n;for(o&&Vo(t[0],t[1],o)&&(i=1);++r1),t}),ro(e,Co(e),r),n&&(r=On(r,u|h|l,Io));for(var i=t.length;i--;)ji(r,t[i]);return r});var cc=Po(function(e,t){return null==e?{}:function(e,t){return vi(e,t,function(t,r){return Qa(e,r)})}(e,t)});function fc(e,t){if(null==e)return{};var r=Zt(Co(e),function(e){return[e]});return t=Lo(t),vi(e,r,function(e,r){return t(e,r[0])})}var uc=So(nc),hc=So(ic);function lc(e){return null==e?[]:br(e,nc(e))}var dc=co(function(e,t,r){return t=t.toLowerCase(),e+(r?pc(t):t)});function pc(e){return Ec(Fa(e).toLowerCase())}function bc(e){return(e=Fa(e))&&e.replace(Ge,gr).replace(vt,"")}var yc=co(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),vc=co(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),mc=ao("toLowerCase");var gc=co(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()});var wc=co(function(e,t,r){return e+(r?" ":"")+Ec(t)});var _c=co(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),Ec=ao("toUpperCase");function Sc(e,t,r){return e=Fa(e),(t=r?n:t)===n?function(e){return _t.test(e)}(e)?function(e){return e.match(gt)||[]}(e):function(e){return e.match(De)||[]}(e):e.match(t)||[]}var kc=Ei(function(e,t){try{return qt(e,n,t)}catch(e){return Ea(e)?e:new $e(e)}}),Ac=Po(function(e,t){return Wt(t,function(t){t=fs(t),Cn(e,t,ta(e[t],e))}),e});function xc(e){return function(){return e}}var Ic=ho(),Tc=ho(!0);function Pc(e){return e}function Bc(e){return ai("function"==typeof e?e:On(e,u))}var Cc=Ei(function(e,t){return function(r){return ri(r,e,t)}}),Mc=Ei(function(e,t){return function(r){return ri(e,r,t)}});function Rc(e,t,r){var n=nc(t),i=Yn(t,n);null!=r||xa(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Yn(t,nc(t)));var o=!(xa(r)&&"chain"in r&&!r.chain),s=Sa(e);return Wt(i,function(r){var n=t[r];e[r]=n,s&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=to(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,$t([this.value()],arguments))})}),e}function Oc(){}var Lc=yo(Zt),Nc=yo(Gt),jc=yo(tr);function Dc(e){return Go(e)?fr(fs(e)):function(e){return function(t){return Jn(t,e)}}(e)}var Uc=mo(),Kc=mo(!0);function Hc(){return[]}function zc(){return!1}var qc=bo(function(e,t){return e+t},0),Fc=_o("ceil"),Wc=bo(function(e,t){return e/t},1),Vc=_o("floor");var Gc,Yc=bo(function(e,t){return e*t},1),Jc=_o("round"),Xc=bo(function(e,t){return e-t},0);return ln.after=function(e,t){if("function"!=typeof t)throw new it(s);return e=Ka(e),function(){if(--e<1)return t.apply(this,arguments)}},ln.ary=Qs,ln.assign=Wa,ln.assignIn=Va,ln.assignInWith=Ga,ln.assignWith=Ya,ln.at=Ja,ln.before=ea,ln.bind=ta,ln.bindAll=Ac,ln.bindKey=ra,ln.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ya(e)?e:[e]},ln.chain=Ds,ln.chunk=function(e,t,r){t=(r?Vo(e,t,r):t===n)?1:qr(Ka(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,s=0,a=Xe(Nr(i/t));oo?0:o+r),(i=i===n||i>o?o:Ka(i))<0&&(i+=o),i=r>i?0:Ha(i);r>>0)?(e=Fa(e))&&("string"==typeof t||null!=t&&!Ca(t))&&!(t=Li(t))&&Er(e)?Gi(Pr(e),0,r):e.split(t,r):[]},ln.spread=function(e,t){if("function"!=typeof e)throw new it(s);return t=null==t?0:qr(Ka(t),0),Ei(function(r){var n=r[t],i=Gi(r,0,t);return n&&$t(i,n),qt(e,this,i)})},ln.tail=function(e){var t=null==e?0:e.length;return t?Pi(e,1,t):[]},ln.take=function(e,t,r){return e&&e.length?Pi(e,0,(t=r||t===n?1:Ka(t))<0?0:t):[]},ln.takeRight=function(e,t,r){var i=null==e?0:e.length;return i?Pi(e,(t=i-(t=r||t===n?1:Ka(t)))<0?0:t,i):[]},ln.takeRightWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3),!1,!0):[]},ln.takeWhile=function(e,t){return e&&e.length?Ui(e,Lo(t,3)):[]},ln.tap=function(e,t){return t(e),e},ln.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new it(s);return xa(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),na(e,t,{leading:n,maxWait:t,trailing:i})},ln.thru=Us,ln.toArray=Da,ln.toPairs=uc,ln.toPairsIn=hc,ln.toPath=function(e){return ya(e)?Zt(e,fs):Oa(e)?[e]:to(cs(Fa(e)))},ln.toPlainObject=qa,ln.transform=function(e,t,r){var n=ya(e),i=n||wa(e)||La(e);if(t=Lo(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:xa(e)&&Sa(o)?dn(Bt(e)):{}}return(i?Wt:Vn)(e,function(e,n,i){return t(r,e,n,i)}),r},ln.unary=function(e){return Qs(e,1)},ln.union=Is,ln.unionBy=Ts,ln.unionWith=Ps,ln.uniq=function(e){return e&&e.length?Ni(e):[]},ln.uniqBy=function(e,t){return e&&e.length?Ni(e,Lo(t,2)):[]},ln.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?Ni(e,n,t):[]},ln.unset=function(e,t){return null==e||ji(e,t)},ln.unzip=Bs,ln.unzipWith=Cs,ln.update=function(e,t,r){return null==e?e:Di(e,t,Fi(r))},ln.updateWith=function(e,t,r,i){return i="function"==typeof i?i:n,null==e?e:Di(e,t,Fi(r),i)},ln.values=lc,ln.valuesIn=function(e){return null==e?[]:br(e,ic(e))},ln.without=Ms,ln.words=Sc,ln.wrap=function(e,t){return fa(Fi(t),e)},ln.xor=Rs,ln.xorBy=Os,ln.xorWith=Ls,ln.zip=Ns,ln.zipObject=function(e,t){return zi(e||[],t||[],In)},ln.zipObjectDeep=function(e,t){return zi(e||[],t||[],Ai)},ln.zipWith=js,ln.entries=uc,ln.entriesIn=hc,ln.extend=Va,ln.extendWith=Ga,Rc(ln,ln),ln.add=qc,ln.attempt=kc,ln.camelCase=dc,ln.capitalize=pc,ln.ceil=Fc,ln.clamp=function(e,t,r){return r===n&&(r=t,t=n),r!==n&&(r=(r=za(r))==r?r:0),t!==n&&(t=(t=za(t))==t?t:0),Rn(za(e),t,r)},ln.clone=function(e){return On(e,l)},ln.cloneDeep=function(e){return On(e,u|l)},ln.cloneDeepWith=function(e,t){return On(e,u|l,t="function"==typeof t?t:n)},ln.cloneWith=function(e,t){return On(e,l,t="function"==typeof t?t:n)},ln.conformsTo=function(e,t){return null==t||Ln(e,t,nc(t))},ln.deburr=bc,ln.defaultTo=function(e,t){return null==e||e!=e?t:e},ln.divide=Wc,ln.endsWith=function(e,t,r){e=Fa(e),t=Li(t);var i=e.length,o=r=r===n?i:Rn(Ka(r),0,i);return(r-=t.length)>=0&&e.slice(r,o)==t},ln.eq=la,ln.escape=function(e){return(e=Fa(e))&&Se.test(e)?e.replace(_e,wr):e},ln.escapeRegExp=function(e){return(e=Fa(e))&&Ce.test(e)?e.replace(Be,"\\$&"):e},ln.every=function(e,t,r){var i=ya(e)?Gt:Kn;return r&&Vo(e,t,r)&&(t=n),i(e,Lo(t,3))},ln.find=zs,ln.findIndex=bs,ln.findKey=function(e,t){return nr(e,Lo(t,3),Vn)},ln.findLast=qs,ln.findLastIndex=ys,ln.findLastKey=function(e,t){return nr(e,Lo(t,3),Gn)},ln.floor=Vc,ln.forEach=Fs,ln.forEachRight=Ws,ln.forIn=function(e,t){return null==e?e:Fn(e,Lo(t,3),ic)},ln.forInRight=function(e,t){return null==e?e:Wn(e,Lo(t,3),ic)},ln.forOwn=function(e,t){return e&&Vn(e,Lo(t,3))},ln.forOwnRight=function(e,t){return e&&Gn(e,Lo(t,3))},ln.get=$a,ln.gt=da,ln.gte=pa,ln.has=function(e,t){return null!=e&&zo(e,t,Qn)},ln.hasIn=Qa,ln.head=ms,ln.identity=Pc,ln.includes=function(e,t,r,n){e=ma(e)?e:lc(e),r=r&&!n?Ka(r):0;var i=e.length;return r<0&&(r=qr(i+r,0)),Ra(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&or(e,t,r)>-1},ln.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:Ka(r);return i<0&&(i=qr(n+i,0)),or(e,t,i)},ln.inRange=function(e,t,r){return t=Ua(t),r===n?(r=t,t=0):r=Ua(r),function(e,t,r){return e>=Fr(t,r)&&e=-M&&e<=M},ln.isSet=Ma,ln.isString=Ra,ln.isSymbol=Oa,ln.isTypedArray=La,ln.isUndefined=function(e){return e===n},ln.isWeakMap=function(e){return Ia(e)&&Ho(e)==ie},ln.isWeakSet=function(e){return Ia(e)&&Zn(e)==oe},ln.join=function(e,t){return null==e?"":Hr.call(e,t)},ln.kebabCase=yc,ln.last=Es,ln.lastIndexOf=function(e,t,r){var i=null==e?0:e.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=Ka(r))<0?qr(i+o,0):Fr(o,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,o):ir(e,ar,o,!0)},ln.lowerCase=vc,ln.lowerFirst=mc,ln.lt=Na,ln.lte=ja,ln.max=function(e){return e&&e.length?Hn(e,Pc,$n):n},ln.maxBy=function(e,t){return e&&e.length?Hn(e,Lo(t,2),$n):n},ln.mean=function(e){return cr(e,Pc)},ln.meanBy=function(e,t){return cr(e,Lo(t,2))},ln.min=function(e){return e&&e.length?Hn(e,Pc,ui):n},ln.minBy=function(e,t){return e&&e.length?Hn(e,Lo(t,2),ui):n},ln.stubArray=Hc,ln.stubFalse=zc,ln.stubObject=function(){return{}},ln.stubString=function(){return""},ln.stubTrue=function(){return!0},ln.multiply=Yc,ln.nth=function(e,t){return e&&e.length?bi(e,Ka(t)):n},ln.noConflict=function(){return Ct._===this&&(Ct._=bt),this},ln.noop=Oc,ln.now=$s,ln.pad=function(e,t,r){e=Fa(e);var n=(t=Ka(t))?Tr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return vo(jr(i),r)+e+vo(Nr(i),r)},ln.padEnd=function(e,t,r){e=Fa(e);var n=(t=Ka(t))?Tr(e):0;return t&&nt){var i=e;e=t,t=i}if(r||e%1||t%1){var o=Gr();return Fr(e+o*(t-e+It("1e-"+((o+"").length-1))),t)}return wi(e,t)},ln.reduce=function(e,t,r){var n=ya(e)?Qt:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Dn)},ln.reduceRight=function(e,t,r){var n=ya(e)?er:hr,i=arguments.length<3;return n(e,Lo(t,4),r,i,Un)},ln.repeat=function(e,t,r){return t=(r?Vo(e,t,r):t===n)?1:Ka(t),_i(Fa(e),t)},ln.replace=function(){var e=arguments,t=Fa(e[0]);return e.length<3?t:t.replace(e[1],e[2])},ln.result=function(e,t,r){var i=-1,o=(t=Wi(t,e)).length;for(o||(o=1,e=n);++iM)return[];var r=L,n=Fr(e,L);t=Lo(t),e-=L;for(var i=dr(n,t);++r=s)return e;var c=r-Tr(i);if(c<1)return i;var f=a?Gi(a,0,c).join(""):e.slice(0,c);if(o===n)return f+i;if(a&&(c+=f.length-c),Ca(o)){if(e.slice(c).search(o)){var u,h=f;for(o.global||(o=rt(o.source,Fa(He.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var l=u.index;f=f.slice(0,l===n?c:l)}}else if(e.indexOf(Li(o),c)!=c){var d=f.lastIndexOf(o);d>-1&&(f=f.slice(0,d))}return f+i},ln.unescape=function(e){return(e=Fa(e))&&Ee.test(e)?e.replace(we,Br):e},ln.uniqueId=function(e){var t=++ht;return Fa(e)+t},ln.upperCase=_c,ln.upperFirst=Ec,ln.each=Fs,ln.eachRight=Ws,ln.first=ms,Rc(ln,(Gc={},Vn(ln,function(e,t){ut.call(ln.prototype,t)||(Gc[t]=e)}),Gc),{chain:!1}),ln.VERSION="4.17.11",Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){ln[e].placeholder=ln}),Wt(["drop","take"],function(e,t){yn.prototype[e]=function(r){r=r===n?1:qr(Ka(r),0);var i=this.__filtered__&&!t?new yn(this):this.clone();return i.__filtered__?i.__takeCount__=Fr(r,i.__takeCount__):i.__views__.push({size:Fr(r,L),type:e+(i.__dir__<0?"Right":"")}),i},yn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Wt(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r==P||3==r;yn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Lo(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),Wt(["head","last"],function(e,t){var r="take"+(t?"Right":"");yn.prototype[e]=function(){return this[r](1).value()[0]}}),Wt(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");yn.prototype[e]=function(){return this.__filtered__?new yn(this):this[r](1)}}),yn.prototype.compact=function(){return this.filter(Pc)},yn.prototype.find=function(e){return this.filter(e).head()},yn.prototype.findLast=function(e){return this.reverse().find(e)},yn.prototype.invokeMap=Ei(function(e,t){return"function"==typeof e?new yn(this):this.map(function(r){return ri(r,e,t)})}),yn.prototype.reject=function(e){return this.filter(aa(Lo(e)))},yn.prototype.slice=function(e,t){e=Ka(e);var r=this;return r.__filtered__&&(e>0||t<0)?new yn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==n&&(r=(t=Ka(t))<0?r.dropRight(-t):r.take(t-e)),r)},yn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},yn.prototype.toArray=function(){return this.take(L)},Vn(yn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),o=ln[i?"take"+("last"==t?"Right":""):t],s=i||/^find/.test(t);o&&(ln.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof yn,f=a[0],u=c||ya(t),h=function(e){var t=o.apply(ln,$t([e],a));return i&&l?t[0]:t};u&&r&&"function"==typeof f&&1!=f.length&&(c=u=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=c&&!d;if(!s&&u){t=b?t:new yn(this);var y=e.apply(t,a);return y.__actions__.push({func:Us,args:[h],thisArg:n}),new bn(y,l)}return p&&b?e.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ot[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);ln.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(ya(i)?i:[],e)}return this[r](function(r){return t.apply(ya(r)?r:[],e)})}}),Vn(yn.prototype,function(e,t){var r=ln[t];if(r){var n=r.name+"";(rn[n]||(rn[n]=[])).push({name:t,func:r})}}),rn[lo(n,y).name]=[{name:"wrapper",func:n}],yn.prototype.clone=function(){var e=new yn(this.__wrapped__);return e.__actions__=to(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=to(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=to(this.__views__),e},yn.prototype.reverse=function(){if(this.__filtered__){var e=new yn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},yn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=ya(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},ln.prototype.plant=function(e){for(var t,r=this;r instanceof pn;){var i=hs(r);i.__index__=0,i.__values__=n,t?o.__wrapped__=i:t=i;var o=i;r=r.__wrapped__}return o.__wrapped__=e,t},ln.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof yn){var t=e;return this.__actions__.length&&(t=new yn(this)),(t=t.reverse()).__actions__.push({func:Us,args:[xs],thisArg:n}),new bn(t,this.__chain__)}return this.thru(xs)},ln.prototype.toJSON=ln.prototype.valueOf=ln.prototype.value=function(){return Ki(this.__wrapped__,this.__actions__)},ln.prototype.first=ln.prototype.head,rr&&(ln.prototype[rr]=function(){return this}),ln}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Ct._=Cr,define(function(){return Cr})):Rt?((Rt.exports=Cr)._=Cr,Mt._=Cr):Ct._=Cr}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],242:[function(e,t,r){"use strict";var n=e("inherits"),i=e("hash-base"),Buffer=e("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(e,t){return e<>>32-t}function c(e,t,r,n,i,o,s){return a(e+(t&r|~t&n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return a(e+(t&n|r&~n)+i+o|0,s)+t|0}function u(e,t,r,n,i,o,s){return a(e+(t^r^n)+i+o|0,s)+t|0}function h(e,t,r,n,i,o,s){return a(e+(r^(t|~n))+i+o|0,s)+t|0}n(s,i),s.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=u(n=u(n=u(n=u(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),s,r,e[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),s,r,e[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),s,r,e[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),s,r,e[15],1236535329,22),i=f(i,s=f(s,r=f(r,n,i,s,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),s,r,e[0],3921069994,20),i=f(i,s=f(s,r=f(r,n,i,s,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),s,r,e[4],3889429448,20),i=f(i,s=f(s,r=f(r,n,i,s,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),s,r,e[8],1163531501,20),i=f(i,s=f(s,r=f(r,n,i,s,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),s,r,e[12],2368359562,20),i=u(i,s=u(s,r=u(r,n,i,s,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),s,r,e[14],4259657740,23),i=u(i,s=u(s,r=u(r,n,i,s,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),s,r,e[10],3200236656,23),i=u(i,s=u(s,r=u(r,n,i,s,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),s,r,e[6],76029189,23),i=u(i,s=u(s,r=u(r,n,i,s,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),s,r,e[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),s,r,e[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),s,r,e[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),s,r,e[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},t.exports=s},{"hash-base":222,inherits:238,"safe-buffer":298}],243:[function(e,t,r){(function(Buffer){t.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var r=e.length,n=e.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),s=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var a=e.subn(1),c=0;!a.testn(c);c++);for(var f=e.shrn(c),u=a.toRed(o);t>0;t--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(f);if(0!==l.cmp(s)&&0!==l.cmp(u)){for(var d=1;d0;t--){var u=this._randrange(new n(2),s),h=e.gcd(u);if(0!==h.cmpn(1))return h;var l=u.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(f)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},{}],247:[function(e,t,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(e,t,r){if(!(e0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===f&&!1===isNaN(e))return t.long?c(r=e,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],248:[function(e,t,r){(function(Buffer){var t=e("create-hmac"),n=Math.pow(2,30)-1;function i(e,r,i,o,s){if("number"!=typeof i)throw new TypeError("Iterations not a number");if(i<0)throw new TypeError("Bad iterations");if("number"!=typeof o)throw new TypeError("Key length not a number");if(o<0||o>n)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(e)||(e=new Buffer(e,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,f,u=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=u;d++){l.writeUInt32BE(d,r.length);var p=t(s,e).update(l).digest();a||(a=p.length,f=new Buffer(a),c=o-((u=Math.ceil(o/a))-1)*a),p.copy(f,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(t).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?f(new s(t),l):a(t,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===u)return function(e,t){var r=e.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==t[0])throw new Error("decryption error");var a=t.slice(1,s+1),f=t.slice(s+1),u=o(a,i(f,s)),h=o(f,i(u,r-s-1));if(function(e,t){e=Buffer.from(e),t=Buffer.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var s=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,h,r);if(3===u)return h;throw new Error("unknown padding")}},{"./mgf":252,"./withPublic":275,"./xor":276,"bn.js":82,"browserify-rsa":267,"create-hash":119,"parse-asn1":272,"safe-buffer":298}],274:[function(e,t,r){var n=e("parse-asn1"),i=e("randombytes"),o=e("create-hash"),s=e("./mgf"),a=e("./xor"),c=e("bn.js"),f=e("./withPublic"),u=e("browserify-rsa"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t,r){var h;h=e.padding?e.padding:r?1:4;var l,d=n(e);if(4===h)l=function(e,t){var r=e.modulus.byteLength(),n=t.length,f=o("sha1").update(Buffer.alloc(0)).digest(),u=f.length,h=2*u;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-u-1,p=i(u),b=a(Buffer.concat([f,l,Buffer.alloc(1,1),t],d),s(p,d)),y=a(p,s(b,u));return new c(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,t);else if(1===h)l=function(e,t,r){var n,o=t.length,s=e.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(e){var t,r=Buffer.allocUnsafe(e),n=0,o=i(2*e),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?u(l,d):f(l,d)}},{"./mgf":252,"./withPublic":275,"./xor":276,"bn.js":82,"browserify-rsa":267,"create-hash":119,"parse-asn1":272,randombytes:282,"safe-buffer":298}],275:[function(e,t,r){var n=e("bn.js"),Buffer=e("safe-buffer").Buffer;t.exports=function(e,t){return Buffer.from(e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed().toArray())}},{"bn.js":82,"safe-buffer":298}],276:[function(e,t,r){t.exports=function(e,t){for(var r=e.length,n=-1;++ne.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":39}],278:[function(e,t,r){(function(e,n){!function(e){if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof r)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=e}else Q=e()}(function(){"use strict";var t=!1;try{throw new Error}catch(e){t=!!e.stack}var r,i=S(),o=function(){},s=function(){var t={task:void 0,next:null},r=t,i=!1,o=void 0,a=!1;function c(){for(;t.next;){var e=(t=t.next).task;t.task=void 0;var r=t.domain;r&&(t.domain=void 0,r.enter());try{e()}catch(e){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),e;setTimeout(function(){throw e},0)}r&&r.exit()}i=!1}if(s=function(t){r=r.next={task:t,domain:a&&e.domain,next:null},i||(i=!0,o())},void 0!==e&&e.nextTick)a=!0,o=function(){e.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var f=new MessageChannel;f.port1.onmessage=function(){o=u,f.port1.onmessage=c,c()};var u=function(){f.port2.postMessage(0)};o=function(){setTimeout(c,0),u()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(e){return function(){return a.apply(e,arguments)}}var f,u=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(t)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=_(e[0].indexOf("@")>0?e[1]:e[2]);if(!n)return;return r=n[0],n[1]}}function k(e){return C(e)?e:M(e)?(t=e,r=A(),s(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):H(e);var t,r}function A(){var e,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(t,i,o){var a=u(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){e.promiseDispatch.apply(e,a)})},o.valueOf=function(){if(r)return o;var t=B(e);return C(t)&&(e=t),t},o.inspect=function(){return e?e.inspect():{state:"pending"}},k.longStackSupport&&t)try{throw new Error}catch(e){o.stack=e.stack.substring(e.stack.indexOf("\n")+1)}function a(t){e=t,o.source=t,h(r,function(e,r){s(function(){t.promiseDispatch.apply(t,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(t){e||a(k(t))},i.fulfill=function(t){e||a(H(t))},i.reject=function(t){e||a(K(t))},i.notify=function(t){e||h(n,function(e,r){s(function(){r(t)})},void 0)},i}function x(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=A();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function I(e){return x(function(t,r){for(var n=0,i=e.length;n2?e.resolve(u(arguments,1)):e.resolve(r)}},k.Promise=x,k.promise=x,x.race=I,x.all=F,x.reject=K,x.resolve=k,k.passByCopy=function(e){return e},T.prototype.passByCopy=function(){return this},k.join=function(e,t){return k(e).join(t)},T.prototype.join=function(e){return k([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},k.race=I,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(e,t,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(t){o||(o=!0,i.resolve(function(t){try{return"function"==typeof e?e(t):t}catch(e){return K(e)}}(t)))},"when",[function(e){o||(o=!0,i.resolve(function(e){if("function"==typeof t){w(e,n);try{return t(e)}catch(e){return K(e)}}return K(e)}(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,n=!1;try{t=function(e){return"function"==typeof r?r(e):e}(e)}catch(e){if(n=!0,!k.onerror)throw e;k.onerror(e)}n||i.notify(t)}]),i.promise},k.when=P,T.prototype.thenResolve=function(e){return this.then(function(){return e})},k.thenResolve=function(e,t){return k(e).thenResolve(t)},T.prototype.thenReject=function(e){return this.then(function(){throw e})},k.thenReject=function(e,t){return k(e).thenReject(t)},k.nearer=B,k.isPromise=C,k.isPromiseAlike=M,k.isPending=function(e){return C(e)&&"pending"===e.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(e){return!C(e)||"fulfilled"===e.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(e){return C(e)&&"rejected"===e.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,N=[],j=[],D=!0;function U(){N.length=0,j.length=0,D||(D=!0)}function K(e){var t=T({when:function(t){return t&&function(e){if(D){var t=l(j,e);-1!==t&&(j.splice(t,1),N.splice(t,1))}}(this),t?t(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return function(e,t){D&&(j.push(e),t&&void 0!==t.stack?N.push(t.stack):N.push("(no stack) "+t))}(t,e),t}function H(e){return T({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},delete:function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return y(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function z(e,t,r){return k(e).spread(t,r)}function q(e,t,r){return k(e).dispatch(t,r)}function F(e){return P(e,function(e){var t=0,r=A();return h(e,function(n,i,o){var s;C(i)&&"fulfilled"===(s=i.inspect()).state?e[o]=s.value:(++t,P(i,function(n){e[o]=n,0==--t&&r.resolve(e)},r.reject,function(e){r.notify({index:o,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function W(e){return P(e,function(e){return e=d(e,k),P(F(d(e,function(e){return P(e,o,o)})),function(){return e})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return N.slice()},k.stopUnhandledRejectionTracking=function(){U(),D=!1},U(),k.reject=K,k.fulfill=H,k.master=function(e){return T({isDef:function(){}},function(t,r){return q(e,t,r)},function(){return k(e).inspect()})},k.spread=z,T.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},k.async=function(e){return function(){function t(e,t){var o;if("undefined"==typeof StopIteration){try{o=r[e](t)}catch(e){return K(e)}return o.done?o.value:P(o.value,n,i)}try{o=r[e](t)}catch(e){return function(e){return"[object StopIteration]"===v(e)||e instanceof f}(e)?e.value:K(e)}return P(o,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}},k.spawn=function(e){k.done(k.async(e)())},k.return=function(e){throw new f(e)},k.promised=function(e){return function(){return z([this,F(arguments)],function(t,r){return e.apply(t,r)})}},k.dispatch=q,T.prototype.dispatch=function(e,t){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},k.get=function(e,t){return k(e).dispatch("get",[t])},T.prototype.get=function(e){return this.dispatch("get",[e])},k.set=function(e,t,r){return k(e).dispatch("set",[t,r])},T.prototype.set=function(e,t){return this.dispatch("set",[e,t])},k.del=k.delete=function(e,t){return k(e).dispatch("delete",[t])},T.prototype.del=T.prototype.delete=function(e){return this.dispatch("delete",[e])},k.mapply=k.post=function(e,t,r){return k(e).dispatch("post",[t,r])},T.prototype.mapply=T.prototype.post=function(e,t){return this.dispatch("post",[e,t])},k.send=k.mcall=k.invoke=function(e,t){return k(e).dispatch("post",[t,u(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(e){return this.dispatch("post",[e,u(arguments,1)])},k.fapply=function(e,t){return k(e).dispatch("apply",[void 0,t])},T.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},k.try=k.fcall=function(e){return k(e).dispatch("apply",[void 0,u(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,u(arguments)])},k.fbind=function(e){var t=k(e),r=u(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(u(arguments))])}},T.prototype.fbind=function(){var e=this,t=u(arguments);return function(){return e.dispatch("apply",[this,t.concat(u(arguments))])}},k.keys=function(e){return k(e).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(e){return k(e).allSettled()},T.prototype.allSettled=function(){return this.then(function(e){return F(d(e,function(e){function t(){return e.inspect()}return(e=k(e)).then(t,t)}))})},k.fail=k.catch=function(e,t){return k(e).then(void 0,t)},T.prototype.fail=T.prototype.catch=function(e){return this.then(void 0,e)},k.progress=function(e,t){return k(e).then(void 0,void 0,t)},T.prototype.progress=function(e){return this.then(void 0,void 0,e)},k.fin=k.finally=function(e,t){return k(e).finally(t)},T.prototype.fin=T.prototype.finally=function(e){return e=k(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},k.done=function(e,t,r,n){return k(e).done(t,r,n)},T.prototype.done=function(t,r,n){var i=function(e){s(function(){if(w(e,o),!k.onerror)throw e;k.onerror(e)})},o=t||r||n?this.then(t,r,n):this;"object"==typeof e&&e&&e.domain&&(i=e.domain.bind(i)),o.then(void 0,i)},k.timeout=function(e,t,r){return k(e).timeout(t,r)},T.prototype.timeout=function(e,t){var r=A(),n=setTimeout(function(){r.reject(new Error(t||"Timed out after "+e+" ms"))},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},k.delay=function(e,t){return void 0===t&&(t=e,e=void 0),k(e).delay(t)},T.prototype.delay=function(e){return this.then(function(t){var r=A();return setTimeout(function(){r.resolve(t)},e),r.promise})},k.nfapply=function(e,t){return k(e).nfapply(t)},T.prototype.nfapply=function(e){var t=A(),r=u(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},k.nfcall=function(e){var t=u(arguments,1);return k(e).nfapply(t)},T.prototype.nfcall=function(){var e=u(arguments),t=A();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},k.nfbind=k.denodeify=function(e){var t=u(arguments,1);return function(){var r=t.concat(u(arguments)),n=A();return r.push(n.makeNodeResolver()),k(e).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var e=u(arguments);return e.unshift(this),k.denodeify.apply(void 0,e)},k.nbind=function(e,t){var r=u(arguments,2);return function(){var n=r.concat(u(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return e.apply(t,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var e=u(arguments,0);return e.unshift(this),k.nbind.apply(void 0,e)},k.nmapply=k.npost=function(e,t,r){return k(e).npost(t,r)},T.prototype.nmapply=T.prototype.npost=function(e,t){var r=u(t||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[e,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(e,t){var r=u(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(e).dispatch("post",[t,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(e){var t=u(arguments,1),r=A();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},k.nodeify=function(e,t){return k(e).nodeify(t)},T.prototype.nodeify=function(e){if(!e)return this;this.then(function(t){s(function(){e(null,t)})},function(t){s(function(){e(t)})})};var V=S();return k})}).call(this,e("_process"),e("timers").setImmediate)},{_process:250,timers:325}],279:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var f=e.length;c>0&&f>c&&(f=c);for(var u=0;u=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],280:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n65536)throw new Error("requested too many random bytes");var o=new n.Uint8Array(e);e>0&&i.getRandomValues(o);var s=Buffer.from(o.buffer);if("function"==typeof t)return r.nextTick(function(){t(null,s)});return s}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:250,"safe-buffer":298}],283:[function(e,t,r){(function(t,n){"use strict";function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=e("safe-buffer"),s=e("randombytes"),Buffer=o.Buffer,a=o.kMaxLength,c=n.crypto||n.msCrypto,f=Math.pow(2,32)-1;function u(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>a||e>t)throw new RangeError("offset out of range")}function h(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>a)throw new RangeError("buffer too small")}function l(e,r,n,i){if(t.browser){var o=e.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void t.nextTick(function(){i(null,e)}):e}if(!i)return s(n).copy(e,r),e;s(n,function(t,n){if(t)return i(t);n.copy(e,r),i(null,e)})}c&&c.getRandomValues||!t.browser?(r.randomFill=function(e,t,r,i){if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof t)i=t,t=0,r=e.length;else if("function"==typeof r)i=r,r=e.length-t;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return u(t,e.length),h(r,t,e.length),l(e,t,r,i)},r.randomFillSync=function(e,t,r){void 0===t&&(t=0);if(!(Buffer.isBuffer(e)||e instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');u(t,e.length),void 0===r&&(r=e.length-t);return h(r,t,e.length),l(e,t,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:250,randombytes:282,"safe-buffer":298}],284:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":285}],285:[function(e,t,r){"use strict";var n=e("process-nextick-args"),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=h;var o=e("core-util-is");o.inherits=e("inherits");var s=e("./_stream_readable"),a=e("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),f=0;f0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?w(e,s,t,!1):A(e,s)):w(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=_?e=_:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(l("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(k,e):k(e))}function k(e){l("emit readable"),e.emit("readable"),P(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(x,e,t))}function x(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function C(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return l("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?C(this):S(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&C(this),null;var n,i=t.needReadable;return l("need readable",i),(0===t.length||t.length-e0?B(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&C(this)),null!==n&&this.emit("data",n),n},m.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},m.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,t);var c=(!t||!1!==t.end)&&e!==r.stdout&&e!==r.stderr?u:g;function f(t,r){l("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),e.removeListener("close",v),e.removeListener("finish",m),e.removeListener("drain",h),e.removeListener("error",y),e.removeListener("unpipe",f),n.removeListener("end",u),n.removeListener("end",g),n.removeListener("data",b),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||h())}function u(){l("onend"),e.end()}o.endEmitted?i.nextTick(c):n.once("end",c),e.on("unpipe",f);var h=function(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,P(e))}}(n);e.on("drain",h);var d=!1;var p=!1;function b(t){l("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==R(o.pipes,e))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(t){l("onerror",t),g(),e.removeListener("error",y),0===a(e,"error")&&e.emit("error",t)}function v(){e.removeListener("finish",m),g()}function m(){l("onfinish"),e.removeListener("close",v),g()}function g(){l("unpipe"),n.unpipe(e)}return n.on("data",b),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",v),e.once("finish",m),e.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),e},m.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=y;var f=e("core-util-is");f.inherits=e("inherits");var u={deprecate:e("util-deprecate")},h=e("./internal/streams/stream"),Buffer=e("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=e("./internal/streams/destroy");function b(){}function y(t,r){a=a||e("./_stream_duplex"),t=t||{};var n=r instanceof a;this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,f=t.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(f||0===f)?f:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===t.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?c(g,e,r,s,i):g(e,r,s,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(t){if(a=a||e("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(t);this._writableState=new y(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function m(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function g(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,m(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,u=r.encoding,h=r.callback;if(m(e,t,!1,t.objectMode?1:f.length,f,u,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}f.inherits(v,h),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:u.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===v&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=e,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(e)&&(e=function(e){return Buffer.from(e)}(e)),"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(a||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("timers").setImmediate)},{"./_stream_duplex":285,"./internal/streams/destroy":291,"./internal/streams/stream":292,_process:250,"core-util-is":117,inherits:238,"process-nextick-args":249,"safe-buffer":298,timers:325,"util-deprecate":333}],290:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("util");t.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,t.copy(r,n),s+=o.data.length,o=o.next;return i},e}(),n&&n.inspect&&n.inspect.custom&&(t.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":298,util:84}],291:[function(e,t,r){"use strict";var n=e("process-nextick-args");function i(e,t){e.emit("error",t)}t.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":249}],292:[function(e,t,r){t.exports=e("events").EventEmitter},{events:218}],293:[function(e,t,r){t.exports=e("./readable").PassThrough},{"./readable":294}],294:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":285,"./lib/_stream_passthrough.js":286,"./lib/_stream_readable.js":287,"./lib/_stream_transform.js":288,"./lib/_stream_writable.js":289}],295:[function(e,t,r){t.exports=e("./readable").Transform},{"./readable":294}],296:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":289}],297:[function(e,t,r){"use strict";var Buffer=e("buffer").Buffer,n=e("inherits"),i=e("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],u=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(e,t){return e<>>32-t}function p(e,t,r,n,i,o,s,a){return d(e+(t^r^n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return d(e+(t&r|~t&n)+o+s|0,a)+i|0}function y(e,t,r,n,i,o,s,a){return d(e+((t|~r)^n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return d(e+(t&n|r&~n)+o+s|0,a)+i|0}function m(e,t,r,n,i,o,s,a){return d(e+(t^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,g=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=p(r,n,i,l,g,e[s[A]],u[0],c[A]),I=m(w,_,E,S,k,e[a[A]],h[0],f[A])):A<32?(x=b(r,n,i,l,g,e[s[A]],u[1],c[A]),I=v(w,_,E,S,k,e[a[A]],h[1],f[A])):A<48?(x=y(r,n,i,l,g,e[s[A]],u[2],c[A]),I=y(w,_,E,S,k,e[a[A]],h[2],f[A])):A<64?(x=v(r,n,i,l,g,e[s[A]],u[3],c[A]),I=b(w,_,E,S,k,e[a[A]],h[3],f[A])):(x=m(r,n,i,l,g,e[s[A]],u[4],c[A]),I=p(w,_,E,S,k,e[a[A]],h[4],f[A])),r=g,g=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=I}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+g+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},t.exports=l},{buffer:111,"hash-base":222,inherits:238}],298:[function(e,t,r){var n=e("buffer"),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?t.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:111}],299:[function(e,t,r){"use strict";t.exports=e("./lib")(e("./lib/elliptic"))},{"./lib":303,"./lib/elliptic":302}],300:[function(e,t,r){(function(Buffer){"use strict";var e=Object.prototype.toString;r.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},r.isBoolean=function(t,r){if("[object Boolean]"!==e.call(t))throw TypeError(r)},r.isBuffer=function(e,t){if(!Buffer.isBuffer(e))throw TypeError(t)},r.isFunction=function(t,r){if("[object Function]"!==e.call(t))throw TypeError(r)},r.isNumber=function(t,r){if("[object Number]"!==e.call(t))throw TypeError(r)},r.isObject=function(t,r){if("[object Object]"!==e.call(t))throw TypeError(r)},r.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},r.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},r.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},r.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":239}],301:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(e,t,r){var n=Buffer.from(r?i:o);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},r.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[i]&&!(128&t[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),e.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(t.slice(i),o.slice(a))},r.signatureImport=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(e);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(e){return}return i.r.copy(t,32-i.r.length),i.s.copy(r,32-i.s.length),{r:t,s:r}},r.signatureImportLax=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var o=e[i++];if(!(128&o&&(i+=o-128)>n)&&2===e[i++]){var s=e[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+e[i]}if(!(s>n-i)){var a=i;if(i+=s,2===e[i++]){var c=e[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+e[i]}if(!(c>n-i)){var f=i;for(i+=c;s>0&&0===e[a];s-=1,a+=1);if(!(s>32)){var u=e.slice(a,a+s);for(u.copy(t,32-u.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var h=e.slice(f,f+c);return h.copy(r,32-h.length),{r:t,s:r}}}}}}}}}},{bip66:38,"safe-buffer":298}],302:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=e("create-hash"),i=e("bn.js"),o=e("elliptic").ec,s=e("../messages.json"),a=new o("secp256k1"),c=a.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new i(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new i(t),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}r.privateKeyVerify=function(e){var t=new i(e);return t.cmp(c.n)<0&&!t.isZero()},r.privateKeyExport=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.privateKeyNegate=function(e){var t=new i(e);return t.isZero()?Buffer.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(e){var t=new i(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(e,t){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(e,t){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(e).getPublic(t,!0))},r.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(t,!0))},r.publicKeyVerify=function(e){return null!==f(e)},r.publicKeyTweakAdd=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(c.g.mul(t).add(n.pub).encode(!0,r))},r.publicKeyTweakMul=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(c.n)>=0||t.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(t).encode(!0,r))},r.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(e);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new i(t).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},r.signatureImport=function(e){var t=new i(e.r);t.cmp(c.n)>=0&&(t=new i(0));var r=new i(e.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([t.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(e,t,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(e,t,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var f=new i(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var u=a.sign(e,t,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([u.r.toArrayLike(Buffer,"be",32),u.s.toArrayLike(Buffer,"be",32)]),recovery:u.recoveryParam}},r.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},o=new i(n.r),u=new i(n.s);if(o.cmp(c.n)>=0||u.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===u.cmp(a.nh)||o.isZero()||u.isZero())return!1;var h=f(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(e,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(e,t,r,n){var o={r:t.slice(0,32),s:t.slice(32,64)},f=new i(o.r),u=new i(o.s);if(f.cmp(c.n)>=0||u.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||u.isZero())throw new Error;var h=a.recoverPubKey(e,o,r);return Buffer.from(h.encode(!0,n))}catch(e){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(e,t){var i=r.ecdhUnsafe(e,t,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(e,t,r){var n=f(e);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(t);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":304,"bn.js":82,"create-hash":119,elliptic:201,"safe-buffer":298}],303:[function(e,t,r){"use strict";var n=e("./assert"),i=e("./der"),o=e("./messages.json");function s(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}t.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=e.privateKeyExport(t,r);return i.privateKeyExport(t,a,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=n},{"safe-buffer":298}],306:[function(e,t,r){(r=t.exports=function(e){e=e.toLowerCase();var t=r[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t}).sha=e("./sha"),r.sha1=e("./sha1"),r.sha224=e("./sha224"),r.sha256=e("./sha256"),r.sha384=e("./sha384"),r.sha512=e("./sha512")},{"./sha":307,"./sha1":308,"./sha224":309,"./sha256":310,"./sha384":311,"./sha512":312}],307:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((t=n)<<5|t>>>27)+f(d,i,s,a)+u+r[l]+o[d];u=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":305,inherits:238,"safe-buffer":298}],308:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function u(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=(t=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+u(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},t.exports=a},{"./hash":305,inherits:238,"safe-buffer":298}],309:[function(e,t,r){var n=e("inherits"),i=e("./sha256"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},t.exports=a},{"./hash":305,"./sha256":310,inherits:238,"safe-buffer":298}],310:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function l(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,v=0;v<16;++v)r[v]=e.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((t=r[v-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var m=0;m<64;++m){var g=y+h(d)+c(d,p,b)+o[m]+r[m]|0,w=u(n)+f(n,i,s)|0;y=b,b=p,p=d,d=a+g|0,a=s,s=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},t.exports=a},{"./hash":305,inherits:238,"safe-buffer":298}],311:[function(e,t,r){var n=e("inherits"),i=e("./sha512"),o=e("./hash"),Buffer=e("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var e=Buffer.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},t.exports=a},{"./hash":305,"./sha512":312,inherits:238,"safe-buffer":298}],312:[function(e,t,r){var n=e("inherits"),i=e("./hash"),Buffer=e("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function u(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function l(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function y(e,t){return e>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,m=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)t[T]=e.readInt32BE(4*T),t[T+1]=e.readInt32BE(4*T+4);for(;T<160;T+=2){var P=t[T-30],B=t[T-30+1],C=l(P,B),M=d(B,P),R=p(P=t[T-4],B=t[T-4+1]),O=b(B,P),L=t[T-14],N=t[T-14+1],j=t[T-32],D=t[T-32+1],U=M+N|0,K=C+L+y(U,M)|0;K=(K=K+R+y(U=U+O|0,O)|0)+j+y(U=U+D|0,D)|0,t[T]=K,t[T+1]=U}for(var H=0;H<160;H+=2){K=t[H],U=t[H+1];var z=f(r,n,i),q=f(w,_,E),F=u(r,w),W=u(w,r),V=h(a,k),G=h(k,a),Y=o[H],J=o[H+1],X=c(a,v,m),Z=c(k,A,x),$=I+G|0,Q=g+V+y($,I)|0;Q=(Q=(Q=Q+X+y($=$+Z|0,Z)|0)+Y+y($=$+J|0,J)|0)+K+y($=$+U|0,U)|0;var ee=W+q|0,te=F+z+y(ee,W)|0;g=m,I=x,m=v,x=A,v=a,A=k,a=s+Q+y(k=S+$|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=Q+te+y(w=$+ee|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+v+y(this._fl,A)|0,this._gh=this._gh+m+y(this._gl,x)|0,this._hh=this._hh+g+y(this._hl,I)|0},a.prototype._hash=function(){var e=Buffer.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},t.exports=a},{"./hash":305,inherits:238,"safe-buffer":298}],313:[function(e,t,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message},this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message},this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message},this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message},this.message=e}}};function i(e,t,r){if(4!==t.length)throw new n.exception.invalid("invalid aes block size");var i=e.c[r],o=t[0]^i[0],s=t[r?3:1]^i[1],a=t[2]^i[2];t=t[r?1:3]^i[3];var c,f,u,h,l=i.length/4-2,d=4,p=[0,0,0,0];e=(c=e.j[r])[0];var b=c[1],y=c[2],v=c[3],m=c[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^v[255&t]^i[d],f=e[s>>>24]^b[a>>16&255]^y[t>>8&255]^v[255&o]^i[d+1],u=e[a>>>24]^b[t>>16&255]^y[o>>8&255]^v[255&s]^i[d+2],t=e[t>>>24]^b[o>>16&255]^y[s>>8&255]^v[255&a]^i[d+3],d+=4,o=c,s=f,a=u;for(h=0;4>h;h++)p[r?3&-h:h]=m[o>>>24]<<24^m[s>>16&255]<<16^m[a>>8&255]<<8^m[255&t]^i[d++],c=o,o=s,s=a,a=t,t=c;return p}n.cipher.aes=function(e){this.j[0][0][0]||this.m();var t,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(t=e.length)&&6!==t&&8!==t)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=e.slice(0),o=[]],e=t;e<4*t+28;e++)r=i[e-1],(0==e%t||8===t&&4==e%t)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==e%t&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[e]=i[e-t]^r;for(t=0;e;t++,e--)r=i[3&t?e:e-4],o[t]=4>=e||4>t?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(e){return i(this,e,0)},decrypt:function(e){return i(this,e,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var e,t,r,n,i,o,s,a=this.j[0],c=this.j[1],f=a[4],u=c[4],h=[],l=[];for(e=0;256>e;e++)l[(h[e]=e<<1^283*(e>>7))^e]=e;for(t=r=0;!f[t];t^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,f[t]=o,u[o]=t,s=16843009*(i=h[e=h[n=h[t]]])^65537*e^257*n^16843008*t,i=257*h[o]^16843008*o,e=0;4>e;e++)a[e][t]=i=i<<24^i>>>8,c[e][o]=s=s<<24^s>>>8;for(e=0;5>e;e++)a[e]=a[e].slice(0),c[e]=c[e].slice(0)}},n.bitArray={bitSlice:function(e,t,r){return e=n.bitArray.v(e.slice(t/32),32-(31&t)).slice(1),void 0===r?e:n.bitArray.clamp(e,r-t)},extract:function(e,t,r){var n=Math.floor(-t-r&31);return(-32&(t+r-1^t)?e[t/32|0]<<32-n^e[t/32+1|0]>>>n:e[t/32|0]>>>n)&(1<>t-1,1)),e},partial:function(e,t,r){return 32===e?t:(r?0|t:t<<32-e)+1099511627776*e},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(e,t){if(n.bitArray.bitLength(e)!==n.bitArray.bitLength(t))return!1;var r,i=0;for(r=0;r>>t),r=e[o]<<32-t;return o=e.length?e[e.length-1]:0,e=n.bitArray.getPartial(o),i.push(n.bitArray.partial(t+e&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return e}},n.codec.utf8String={fromBits:function(e){var t,r,i="",o=n.bitArray.bitLength(e);for(t=0;t>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(e){e=unescape(encodeURIComponent(e));var t,r=[],i=0;for(t=0;tn;i++){for(r=!0,t=2;t*t<=i;t++)if(0==i%t){r=!1;break}r&&(8>n&&(this.i[n]=e(Math.pow(i,.5))),this.c[n]=e(Math.pow(i,1/3)),n++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?r=e[t]:(r=e[t+1&15],n=e[t+14&15],r=e[15&t]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+e[15&t]+e[t+9&15]|0),r=r+d+(u>>>6^u>>>11^u>>>25^u<<26^u<<21^u<<7)+(l^u&(h^l))+o[t],d=l,l=h,h=u,u=f+r|0,f=c,c=a,s=r+((a=s)&c^f&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+f|0,i[4]=i[4]+u|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(e){this.c[0]||this.m(),e?(this.f=e.f.slice(0),this.b=e.b.slice(0),this.a=e.a):this.reset()},n.hash.sha512.hash=function(e){return(new n.hash.sha512).update(e).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(e){"string"==typeof e&&(e=n.codec.utf8String.toBits(e));var t,r=this.b=n.bitArray.concat(this.b,e);if(t=this.a,9007199254740991<(e=this.a=t+n.bitArray.bitLength(e)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(t=1024+t-(1024+t&1023);t<=e;t+=1024)this.g(r.splice(0,32));return this},finalize:function(){var e,t=this.b,r=this.f;for(e=(t=n.bitArray.concat(t,[n.bitArray.partial(1,1)])).length+4;31&e;e++)t.push(0);for(t.push(0),t.push(0),t.push(Math.floor(this.a/4294967296)),t.push(0|this.a);t.length;)this.g(t.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function e(e){return 4294967296*(e-Math.floor(e))|0}function t(e){return 1099511627776*(e-Math.floor(e))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=e(Math.pow(o,.5)),this.i[2*i+1]=t(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=e(Math.pow(o,1/3)),this.c[2*i+1]=t(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(e){var t,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],f=i[3],u=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],m=i[12],g=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=e[E]}else n=e;E=s;var S=a,k=c,A=f,x=u,I=h,T=l,P=d,B=p,C=b,M=y,R=v,O=m,L=g,N=w,j=_;for(e=0;80>e;e++){if(16>e)t=n[2*e],r=n[2*e+1];else{r=n[2*(e-15)],t=((U=n[2*(e-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(e-2)];var U=((K=n[2*(e-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(e-7)],z=n[2*(e-16)],q=n[2*(e-16)+1];t=t+H+((r=D+n[2*(e-7)+1])>>>0>>0?1:0),t+=U+((r+=K)>>>0>>0?1:0),t+=z+((r+=q)>>>0>>0?1:0)}n[2*e]=t|=0,n[2*e+1]=r|=0;H=B&M^~B&O;var F=C&R^~C&L,W=(K=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*e]),G=o[2*e+1];D=(D=(D=(D=N+((C<<18|B>>>14)^(C<<14|B>>>18)^(B<<23|C>>>9))+((U=j+((B<<18|C>>>14)^(B<<14|C>>>18)^(C<<23|B>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(t+((U=U+r|0)>>>0>>0?1:0));t=z+K+((r=q+W)>>>0>>0?1:0),N=O,j=L,O=M,L=R,M=B,R=C,B=T+D+((C=P+U|0)>>>0

>>0?1:0)|0,T=x,P=I,x=k,I=A,k=E,A=S,E=D+t+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,f=i[3]=f+A|0,i[2]=c+k+(f>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=u+x+(h>>>0>>0?1:0)|0,d=i[7]=d+P|0,i[6]=l+T+(d>>>0

>>0?1:0)|0,b=i[9]=b+C|0,i[8]=p+B+(b>>>0>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+M+(v>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=m+O+(g>>>0>>0?1:0)|0,_=i[15]=_+j|0,i[14]=w+N+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(e,t,r,i,o){var s=t.slice(0);return t=n.bitArray,i=i||[],e=n.mode.gcm.s(!0,e,s,i,r,o||128),t.concat(e.data,e.tag)},decrypt:function(e,t,r,i,o){var s=t.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(t=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(t=s,s=[]),e=n.mode.gcm.s(!1,e,s,i,r,o),!a.equal(e.tag,t))throw new n.exception.corrupt("gcm: tag doesn't match");return e.data},A:function(e,t){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=t.slice(0),r=0;128>r;r++){for((i=0!=(e[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(e,t,r){var i,o=r.length;for(t=t.slice(0),i=0;io&&(e=t.hash(e)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),e=new(o=o||n.misc.hmac)(e);var s,a,c,f,u=[],h=n.bitArray;for(f=1;32*u.length<(i||1);f++){for(o=s=e.encrypt(h.concat(t,[f])),a=1;a>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}r.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":298}],316:[function(e,t,r){t.exports=function(t){return t.signer=t.signer||e("./lib/signer-hmac-only"),e("./lib/index")(t)}},{"./lib/index":317,"./lib/signer-hmac-only":318}],317:[function(e,t,r){var n=e("util").format;function i(e,t){return e.get?e.get(t):e.getHeader(t)}function o(e){this.name="MissingHeaderError",this.message=e,this.stack=(new Error).stack}function s(e){this.name="InvalidAlgorithmError",this.message=e,this.stack=(new Error).stack}o.prototype=new Error,s.prototype=new Error;var a={"rsa-sha1":!0,"rsa-sha256":!0,"rsa-sha512":!0,"dsa-sha1":!0,"hmac-sha1":!0,"hmac-sha256":!0,"hmac-sha512":!0},c='Signature keyId="%s",algorithm="%s",headers="%s",signature="%s"';function f(e){var t=e.match(/^(?:(.*?):\/\/?)?\/?(?:[^\/\.]+\.)*?([^\/\.]+)\.?([^\/]*)(?:([^?]*)?(?:\?(‌​[^#]*))?)?(.*)?/);return!!t&&t[4]+(t[6]||"")}function u(e){return parseInt(e,10)<10&&(e="0"+e),e}function h(e,t){var r,h;if(t.headers||(t.headers=["date"]),i(e,"Date")||-1===t.headers.indexOf("date")||e.set("Date",["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][(r=new Date).getUTCDay()]+", "+u(r.getUTCDate())+" "+["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.getUTCMonth()]+" "+r.getUTCFullYear()+" "+u(r.getUTCHours())+":"+u(r.getUTCMinutes())+":"+u(r.getUTCSeconds())+" GMT"),t.algorithm||(t.algorithm="rsa-sha256"),t.httpVersion||(t.httpVersion="1.1"),t.algorithm=t.algorithm.toLowerCase(),!a[t.algorithm])throw new s(t.algorithm+" is not supported");var l,d="";for(h=0;h=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||u.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=u.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&t.setRequestHeader(s,this.header[s]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},u.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(e){c.prototype[e.toLowerCase()]=function(t,r){var n=new u.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,u.get=function(e,t,r){var n=u("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},u.head=function(e,t,r){var n=u("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},u.options=function(e,t,r){var n=u("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.del=m,u.delete=m,u.patch=function(e,t,r){var n=u("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.post=function(e,t,r){var n=u("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},u.put=function(e,t,r){var n=u("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},{"./agent-base":319,"./is-object":321,"./request-base":322,"./response-base":323,"component-emitter":116}],321:[function(e,t,r){"use strict";t.exports=function(e){return null!==e&&"object"==typeof e}},{}],322:[function(e,t,r){"use strict";var n=e("./is-object");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(e){return this._parser=e,this},i.prototype.responseType=function(e){return this._responseType=e,this},i.prototype.serialize=function(e){return this._serializer=e,this},i.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},i.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~o.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(e,t){r.end(function(r,n){r?t(r):e(n)})})}return this._fullfilledPromise.then(e,t)},i.prototype.catch=function(e){return this.then(void 0,e)},i.prototype.use=function(e){return e(this),this},i.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},i.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},i.prototype.get=function(e){return this._header[e.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(e,t){if(n(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},i.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},i.prototype.field=function(e,t){if(null===e||void 0===e)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var i in t)this.field(e,t[i]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},i.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},i.prototype.redirects=function(e){return this._maxRedirects=e,this},i.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(e){var t=n(e),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&n(this._data))for(var i in e)this._data[i]=e[i];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},i.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":321}],323:[function(e,t,r){"use strict";var n=e("./utils");function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.get=function(e){return this.header[e.toLowerCase()]},i.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=n.type(t);var r=n.params(t);for(var i in r)this[i]=r[i];this.links={};try{e.link&&(this.links=n.parseLinks(e.link))}catch(e){}},i.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.created=201==e,this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e,this.unprocessableEntity=422==e}},{"./utils":324}],324:[function(e,t,r){"use strict";r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e},{})},r.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},{}],325:[function(e,t,r){(function(t,n){var i=e("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function f(e,t){this._id=e,this._clearFn=t}r.setTimeout=function(){return new f(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new f(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(e){e.close()},f.prototype.unref=f.prototype.ref=function(){},f.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},r.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},r._unrefActive=r.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r.setImmediate="function"==typeof t?t:function(e){var t=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[t]=!0,i(function(){a[t]&&(n?e.apply(null,n):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":250,timers:325}],326:[function(e,t,r){var n=e("./native");function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function a(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function c(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+a(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(e,t,r){r=r||o(t),this.message=c(e,t,r),s(this,f),this.__type=e,this.__value=t,this.__valueTypeName=r}function u(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),c('property "'+a(r)+o+a(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',s(this,f),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,u.prototype=Object.create(Error.prototype),u.prototype.constructor=f,t.exports={TfTypeError:f,TfPropertyTypeError:u,tfCustomError:function(e,t){return new f(e,{},t)},tfSubError:function(e,t,r){return e instanceof u?(t=t+"."+e.__property,e=new u(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof f&&(e=new u(e.__type,t,r,e.__value,e.__valueTypeName)),s(e),e},tfJSON:a,getValueTypeName:o}},{"./native":329}],327:[function(e,t,r){(function(Buffer){var r=e("./native"),n=e("./errors");function i(e){return Buffer.isBuffer(e)}function o(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function s(e,t){var r=e.toJSON();function i(i){if(!e(i))return!1;if(i.length===t)return!0;throw n.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var a=s.bind(null,r.Array),c=s.bind(null,i),f=s.bind(null,o),u=s.bind(null,r.String);var h=Math.pow(2,53)-1;var l={ArrayN:a,Buffer:i,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:o,HexN:f,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-h&&e<=h&&Math.floor(e)===e},Range:function(e,t,n){function i(r,i){return n(r,i)&&r>e&&r>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=h&&Math.floor(e)===e}};for(var d in l)l[d].toJSON=function(e){return e}.bind(null,d);t.exports=l}).call(this,{isBuffer:e("../is-buffer/index.js")})},{"../is-buffer/index.js":239,"./errors":326,"./native":329}],328:[function(e,t,r){var n=e("./errors"),i=e("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,f=n.getValueTypeName,u={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==t.minLength&&r.lengtht.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every(function(t,r){try{return l(e,t,n)}catch(e){throw c(e,r)}})))))}return e=h(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=h(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&l(t,o,n)}catch(e){throw c(e,o,"key")}try{var s=r[o];l(e,s,n)}catch(e){throw c(e,o)}}return!0}return e=h(e),t&&(t=h(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=h(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t){l(t[n],e[n],r)}}catch(e){throw c(e,n)}if(r)for(n in e)if(!t[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.some(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.every(function(e){try{return l(e,t,r)}catch(e){return!1}})}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===f(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return!i.Nil(t)&&(!i.Nil(t.length)&&((!r||t.length===e.length)&&e.every(function(e,n){try{return l(e,t[n],r)}catch(e){throw c(e,n)}})))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function h(e){if(i.String(e))return"?"===e[0]?u.maybe(e.slice(1)):i[e]||u.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return u.arrayOf(e[0])}return u.object(e)}return i.Function(e)?e:u.value(e)}function l(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return l(h(e),t,r)}for(var d in u.oneOf=u.anyOf,i)l[d]=i[d];for(d in u)l[d]=u[d];var p=e("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,t.exports=l},{"./errors":326,"./extra":327,"./native":329}],329:[function(e,t,r){var n={Array:function(e){return null!==e&&void 0!==e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return void 0===e||null===e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(e){return e}.bind(null,i);t.exports=n},{}],330:[function(e,t,r){!function(e){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,f=21,u=28,h=f*u,l=c*h,d=function(e,t){this.codepoint=e,this.feature=t},p={},b=[],y=0;y<=255;++y)b[y]=0;var v=[function(e,t,n){return t<60||13311>8&255]>n&&(p[t]=i),i},function(e,t,r){return r?e(t,r):new d(t,null)},function(e,t,r){var n;if(t=55296&&e<=56319},d.isLowSurrogate=function(e){return e>=56320&&e<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var e=this.codepoint-65536;return String.fromCharCode(Math.floor(e/1024)+55296,e%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(e){if(this.prepFeature(),!this.feature[2])return null;var t=this.feature[2][e.codepoint];return t?d.fromCharCode(t):null};var m=function(e){this.str=e,this.cursor=0};m.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=e)break}this.resBuf.splice(r,0,t)}while(0!==e);return this.resBuf.shift()};var _=function(e){this.it=e,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var e=this.it.next();if(!e){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=e.getCanonicalClass(),this.procBuf.push(e);else{var t=this.procBuf[0].getComposite(e),r=e.getCanonicalClass();t&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(f),h=["%","/","?",";","#"].concat(u),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=e("querystring");function g(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?R+="x":R+=M[O];if(!R.match(d)){var N=B.slice(0,I),j=B.slice(I+1),D=M.match(p);D&&(N.push(D[1]),j.unshift(D[2])),j.length&&(g="/"+j.join(".")+g),this.hostname=N.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),P||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+U,this.href+=this.host,P&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[E])for(I=0,C=u.length;I0)&&r.host.split("@"))&&(r.auth=P.shift(),r.host=r.hostname=P.shift());return r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||e.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),I++):I&&(S.splice(T,1),I--);if(!_&&!E)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var P,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(P=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=P.shift(),r.host=r.hostname=P.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":332,punycode:219,querystring:281}],332:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],333:[function(e,t,r){(function(e){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],334:[function(e,t,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],335:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{"./support/isBuffer":334,_process:250,dup:26,inherits:238}],336:[function(e,t,r){"use strict";var Buffer=e("safe-buffer").Buffer,n=9007199254740991;function i(e){if(e<0||e>n||e%1!=0)throw new RangeError("value out of range")}function o(e){return i(e),e<253?1:e<=65535?3:e<=4294967295?5:9}t.exports={encode:function e(t,r,n){if(i(t),r||(r=Buffer.allocUnsafe(o(t))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),t<253?(r.writeUInt8(t,n),e.bytes=1):t<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(t,n+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(t,n+1),e.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(t>>>0,n+1),r.writeUInt32LE(t/4294967296|0,n+5),e.bytes=9),r},decode:function e(t,r){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=t.readUInt8(r);if(n<253)return e.bytes=1,n;if(253===n)return e.bytes=3,t.readUInt16LE(r+1);if(254===n)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var o=t.readUInt32LE(r+1),s=4294967296*t.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":298}],337:[function(e,t,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;t.exports=function(e,t){for(var r,a=Object.keys(o),c=0,f=a.length;c0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof u?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof u?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof u?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),u=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new c(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,u,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,u=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[u.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:u},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=m.AES.encrypt(t.secret,t.passphrase).toString(m.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=m.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(m.format.OpenSSL),t.recoverySecret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=m.AES.encrypt(t.secret,t.recoverySecret).toString(m.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:c.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var u=i.defer();u.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),u.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),u.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof e?c.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){c[t]=e[t]});var u={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(u.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(u.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",u,c,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:270,bip39:34,"bitcoinjs-lib":49,"bitcoinjs-message":78,buffer:110,"crypto-js":159,lodash:261,q:299,randombytes:303}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},c=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),c=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(t,e).toString(i.enc.Utf8)},u=function(t,e){return a(c(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(u(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=u,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:23,bip39:34,buffer:110,"crypto-js":159,q:299,util:242}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function c(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function u(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,c,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,bip39:34,buffer:110}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:23,buffer:110}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:110}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),c=t("create-hash"),u=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var u=o.parse(e,!0),f=p.qs(i.defaults({},r||{},u.query||{},this.params||{}));this.path="".concat(this.endpoint,u.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=u(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:270,"create-hash":118,debug:185,lodash:261,q:299,querystring:302,superagent:343,"superagent-http-signature/index-hmac-only":339,url:354}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:261,q:299}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:27,lodash:261,q:299}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:261,q:299,superagent:343}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":49,lodash:261,q:299,superagent:343}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){u+=a.getLengthForVarInt(t)+t}),u+=a.getLengthForVarInt(s.length)),[c,u]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var c=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var u=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(u)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var u=n.script.types,f=[u.MULTISIG,u.P2PKH,u.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,"bitcoinjs-lib":49,buffer:110}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:27,lodash:261,q:299}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:270}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),c=t("./blocktrail"),u=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,c,u,f,h,l,d,p,y,m,v,g,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!g,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(u,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=u,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=m,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function m(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(u.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new c.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=u.AES.encrypt(e.secret,t).toString(u.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),u=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&u===b.CHAIN_BTC_SEGWIT?(e=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=c);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new c.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new c.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var u=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!u&&!f)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,u){var f=this;"function"==typeof e?(u=e,e=null):"function"==typeof r?(u=r,r=!1):"function"==typeof n?(u=n,n=!0):"function"==typeof o?(u=o,o=null):"function"==typeof s?(u=s,s=null):"function"==typeof a&&(u=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(u),f.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(m,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var u=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(u.address,e,r).toString("hex"),delete a.address}catch(t){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,u,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof u?(h=u,u=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,u=u||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,u,f).spread(function(t,n,f){var d,y,m=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*c.DUST&&r!==f)return e(new c.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=c.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?m.splice(r.random(0,m.length),0,n):m.push(n)}t()},function(t){m.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new c.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var c=i.defer();return c.promise.nodeify(s),c.reject(t),c.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u=i.defer();return u.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){u.resolve(t)},function(t){t.requires_2fa?u.reject(new c.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?u.reject(new c.WalletInvalid2FAError):u.reject(t)}),u.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*c.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var u=s.script.decompile(a),f=u[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=u[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+c),u.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),u.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(c)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(c)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!g(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),c=!t&&i&&!r;if((a&&o&&_(i,r)||c)&&m(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=m,l.ok=v,l.equal=function(t,e,r){t!=e&&m(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&m(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){g(t,e,!1)||m(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){g(t,e,!0)||m(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){g(t,e,!1)&&m(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){g(e,r,!0)&&m(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&m(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&m(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||m(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":268,"util/":26}],24:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],25:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],26:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var c=e.name?": "+e.name:"";return t.stylize("[Function"+c+"]","special")}if(g(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var u,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return g(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?g(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),M(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=b(r)?f(t,c.value,null):f(t,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function m(t){return"string"==typeof t}function v(t){return void 0===t}function g(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":25,_process:270,inherits:24}],27:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(t){return"[object Array]"===a.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}u(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var m=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(m),o.filterSeries=p(m),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var g=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(g),o.detectSeries=p(g),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,u(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),u(r,function(r){var n=c(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};u(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(u(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){c(t)||(t=[t]),u(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;u(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&u(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],28:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],d=0,p=u-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=u-i;b!==u&&0===h[b];)b++;for(var y=c.repeat(r);b>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function c(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var u=c(o),f=[],h=0;h=s.length||f.push(d)}if(1!==u)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var u=0;u<6;++u)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return u(t,8,5,!0)},fromWords:function(t){return u(t,5,8,!1)}}},{}],30:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function u(t){return a.charAt(t)}function f(t,e){var r=c[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,f=o[u-1];if(0!=f){var h=f*(1<1?o[u-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(u,v),v.subTo(o,o);o.t=0;){var g=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,g,r,m,0,u))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=u(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,m,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=u;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,m=t.t-1,v=!0,g=new BigInteger;for(i=l(t[m])-1;m>=0;){for(i>=c?b=t[m]>>i-c&u:(b=(t[m]&(1<0&&(b|=t[m-1]>>this.DB+i-c)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--m),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(y=o,o=g,g=y),n.mulTo(g,s[b],o)}for(;m>=0&&0==(t[m]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),u=o.slice(s),f=c.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===u,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^m[c>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[c>>16&255]^m[e>>8&255]^v[255&o]^i[p+1],h=t[c>>>24]^y[e>>16&255]^m[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^m[a>>8&255]^v[255&c]^i[p+3],p+=4,o=u,a=f,c=h;for(l=0;4>l;l++)b[r?3&-l:l]=g[o>>>24]<<24^g[a>>16&255]<<16^g[c>>8&255]<<8^g[255&e]^i[p++],u=o,o=a,a=c,c=e,e=u;return b}function c(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],c=this.o[1],u=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],c=this.o[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,u=0;for(e&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),u=i<<32-a):u^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,u,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=u+e|0,u=c,c=a,s=e+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=u.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),c=s.mode.ccm.s(t,c,r,e,o,a),u.concat(c.data,c.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,u=a.bitLength(e),f=a.clamp(e,u-o),h=a.bitSlice(e,u-o);u=(u-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&u>>>8*e;e++);return e<15-c&&(e=15-c),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],c=s.bitArray,u=c.j;if(n=[c.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=c.bitLength(e)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/u),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:c.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,u=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=u(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(c,n(c))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var c=e.slice(0),u=s.bitArray,f=u.bitLength(c);return a=a||128,i=i||[],a<=f?(e=u.bitSlice(c,f-a),c=u.bitSlice(c,0,f-a)):(e=c,c=[]),t=s.mode.gcm.s(o,t,c,i,r,a),u.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,c,u,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,u,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,u,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":321}],39:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],40:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":39}],41:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),c=t("./networks"),u=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){u(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||c.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":50,"./script":51,"./templates":53,"./types":77,bech32:29,bs58check:106,cashaddress:113,"safe-buffer":321,typeforce:351}],42:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),c=t("varuint-bitcoin"),u=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=u.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=c.decode(t,e),e+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":44,"./transaction":75,"./types":77,"buffer-reverse":108,"merkle-lib/fastRoot":263,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],43:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":298,"varuint-bitcoin":357}],44:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":118}],45:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),u=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(c).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(u.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=u.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),c=BigInteger.fromBuffer(t),l=u.n,d=u.G;return f(t,a,function(t){var i=d.multiply(t);return!u.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(c.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=u.n,s=u.G,a=e.r,c=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=c.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!u.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:u}},{"./ecsignature":47,"./types":77,bigi:32,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],46:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),c=t("./types"),u=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(c.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=u.decode(t),n=r.version;if(c.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":41,"./crypto":44,"./ecdsa":45,"./networks":50,"./types":77,bigi:32,ecurve:199,randombytes:303,typeforce:351,wif:359}],47:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":77,bigi:32,bip66:38,buffer:110,typeforce:351}],48:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),c=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),u=t("ecurve"),f=u.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=u.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),u=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,u);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":44,"./ecpair":46,"./networks":50,"./types":77,bigi:32,bs58check:106,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],49:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":41,"./block":42,"./bufferutils":43,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./hdnode":48,"./networks":50,"./script":51,"./transaction":75,"./transaction_builder":76,"bitcoin-ops":39}],50:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],51:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),c=t("bitcoin-ops"),u=t("bitcoin-ops/map"),f=c.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===c.OP_0||t>=c.OP_1&&t<=c.OP_16||t===c.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?c.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?c.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var u=t.slice(r,r+a.number);r+=a.number;var f=d(u);void 0!==f?e.push(f):e.push(u)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==c[t]?c[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return u[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===c.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var m=t("./templates");for(var v in m)e.exports[v]=m[v]},{"./script_number":52,"./templates":53,"./types":77,bip66:38,"bitcoin-ops":39,"bitcoin-ops/map":40,"pushdata-bitcoin":298,"safe-buffer":321,typeforce:351}],52:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":321}],53:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),c=t("./scripthash"),u=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:c.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(u.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(c.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return u.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:u,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":51,"./multisig":54,"./nulldata":57,"./pubkey":58,"./pubkeyhash":61,"./scripthash":64,"./witnesscommitment":67,"./witnesspubkeyhash":69,"./witnessscripthash":72}],54:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":55,"./output":56}],55:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function u(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,t.map(function(t){return t===o.OP_0?c:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(u(t,e))},encodeStack:u}},{"../../script":51,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],56:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function c(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},e.exports={check:c,decode:function(t,e){var r=n.decompile(t);return o(c,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":51,"../types":77,"bitcoin-ops":39,typeforce:351}],58:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":59,"./output":60,dup:54}],59:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":51,typeforce:351}],60:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":51,"bitcoin-ops":39,typeforce:351}],61:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":62,"./output":63,dup:54}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":51,typeforce:351}],63:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],64:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":65,"./output":66,dup:54}],65:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":51,"safe-buffer":321,typeforce:351}],66:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],67:[function(t,e,r){e.exports={output:t("./output")}},{"./output":68}],68:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},e.exports={check:c,decode:function(t){return o(c,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],69:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":70,"./output":71,dup:54}],70:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":51,typeforce:351}],71:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],72:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":73,"./output":74,dup:54}],73:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":65}],74:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],75:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),c=t("typeforce"),u=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:m};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function c(){return n(a())}function u(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(u.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function c(e){i=t.writeUInt32LE(e,i)}function u(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){u(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),u(this.ins.length),this.ins.forEach(function(t){o(t.hash),c(t.index),h(t.script),c(t.sequence)}),u(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;u((e=t.witness).length),e.forEach(h)}),c(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],76:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),c=t("bitcoin-ops"),u=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function m(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,c,u,f,l,d,p,b=!1,v=!1,g=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(g=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(u=e[e.length-1],f=s.classifyOutput(u),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(u)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(u)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(u)))throw new Error("unsupported witness script");a=u,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(c){if(!m(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return g&&(A.redeemScript=c,A.redeemScriptType=l),v&&(A.witnessScript=u,A.witnessScriptType=f),A}function g(t,e,r){u(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,c,l,d,p,b,y,m,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,m=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=g(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(m=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,m=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(c=t.prevOutType,l=t.prevOutScript,!(a=g(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,m=c,v=l}else a=g(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,m=c=h.P2PKH,v=l;if(void 0!==n||E){if(u(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}m===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=m,t.prevOutScript=l,t.prevOutType=c,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||c.OP_0}),n||(e=e.filter(function(t){return t!==c.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(u(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){u(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,u){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!c.verify(f,h.signature)&&(o[u]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=g(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!m(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=e.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!c.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351}],77:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:351}],78:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var u,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(c),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(u=d,f=i("sha256").update(u).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:81,buffer:110,"buffer-equals":107,"create-hash":118,secp256k1:323,"varuint-bitcoin":357}],79:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var u=0;t[u]===n&&u0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===e[c]&&c=0;--u)a+=t[n[u]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],80:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":79}],81:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:80,buffer:110,"create-hash":118}],82:[function(t,e,r){!function(e,r){"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 Buffer;"object"==typeof e?e.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{Buffer="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:t("buffer").Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:u[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,c="le"===e,u=new t(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(v,m),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new g;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],83:[function(t,e,r){var n;function i(t){this.rand=t}if(e.exports=function(t){return n||(n=new i(null)),n.generate(t)},e.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[m++],s=u[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[m++],a=u[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[m++],c=u[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[m++],d=o,p=s,b=a,y=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[m++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[m++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[m++],c=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[m++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[s]=u,n[u]=s;var f=t[s],h=t[f],l=t[h],d=257*t[u]^16843008*u;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(t){this._key=n(t),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/e|0]<<24):e>6&&o%e==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-e]^c}for(var u=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u},c.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},c.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=c},{"safe-buffer":321}],85:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),c=t("./incr32");function u(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var u=this._cipher.encryptBlock(a);this._ghash=new s(u),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,u=Buffer.alloc(8);u.writeUIntBE(a,0,8),n.update(u),t._finID=n.state;var f=Buffer.from(t._finID);return c(f),f}(this,r,u),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(u,i),u.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":84,"./authCipher":85,"./modes":97,"./streamCipher":100,"cipher-base":114,evp_bytestokey:218,inherits:258,"safe-buffer":321}],88:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),c=t("evp_bytestokey");function u(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(u,s),u.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new u(s.module,e,r)}u.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":321}],90:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],91:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":109}],92:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":109,"safe-buffer":321}],93:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,c=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return c}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return u(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(D(t,ArrayBuffer)||t&&D(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||D(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(D(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),c=this.slice(n,i),u=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return g(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function R(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(C,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function D(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":111,buffer:110,ieee754:257}],111:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],112:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),c=t.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=c.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=u(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+u.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:u.scriptType,prefix:e.prefix,hash:Buffer.from(c.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(c(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":112,buffer:110}],114:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:258,"safe-buffer":321,stream:238,string_decoder:239}],115:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:c(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),c=e;c=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-c.length]+c+r:c+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 u=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[u-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):m(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return g[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],139:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),c=s.toRed(r.mont(e.prime2)),u=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=c.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(u).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":138,buffer:110,randombytes:303}],140:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":141}],141:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],142:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],143:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),c=t("./algorithms.json");function u(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new u(t)}function l(t){return new f(t)}Object.keys(c).forEach(function(t){c[t].id=Buffer.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]}),o(u,i.Writable),u.prototype._write=function(t,e,r){this._hash.update(t),r()},u.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},u.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":141,"./sign":144,"./verify":145,"create-hash":118,inherits:258,"readable-stream":319,"safe-buffer":321}],144:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),c=t("./curves.json");function u(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,c,u){var f=o(r);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,c=r.data.g,u=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===c.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(u.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");e=Buffer.concat([u,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],m=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,u[r]=v;v=16843009*m^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[m^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],u=0;u>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,c,u,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var c=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&u]^r[d++],m=n[h>>>24]^i[l>>>16&255]^o[u>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[u>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];u=b,f=y,h=m,l=v}b=(a[u>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[d++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=m,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],152:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),u=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?g:m}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(c)},parse:function(t){var e=c.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=u.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=m.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,m.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":153,"./evpkdf":156}],153:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},u=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,u=t.min(4*c,i);if(c){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],155:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],156:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,c=s.words,u=0;u>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],161:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],c=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],m=t[e+6],v=t[e+7],g=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],M=o[0],T=o[1],I=o[2],P=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=u(T=u(T=u(T=u(T,I=u(I,P=u(P,M=u(M,T,I,P,s,7,a[0]),T,I,c,12,a[1]),M,T,d,17,a[2]),P,M,p,22,a[3]),I=u(I,P=u(P,M=u(M,T,I,P,b,7,a[4]),T,I,y,12,a[5]),M,T,m,17,a[6]),P,M,v,22,a[7]),I=u(I,P=u(P,M=u(M,T,I,P,g,7,a[8]),T,I,w,12,a[9]),M,T,_,17,a[10]),P,M,E,22,a[11]),I=u(I,P=u(P,M=u(M,T,I,P,S,7,a[12]),T,I,k,12,a[13]),M,T,A,17,a[14]),P,M,x,22,a[15]),I=f(I,P=f(P,M=f(M,T,I,P,c,5,a[16]),T,I,m,9,a[17]),M,T,E,14,a[18]),P,M,s,20,a[19]),I=f(I,P=f(P,M=f(M,T,I,P,y,5,a[20]),T,I,_,9,a[21]),M,T,x,14,a[22]),P,M,b,20,a[23]),I=f(I,P=f(P,M=f(M,T,I,P,w,5,a[24]),T,I,A,9,a[25]),M,T,p,14,a[26]),P,M,g,20,a[27]),I=f(I,P=f(P,M=f(M,T,I,P,k,5,a[28]),T,I,d,9,a[29]),M,T,v,14,a[30]),P,M,S,20,a[31]),I=h(I,P=h(P,M=h(M,T,I,P,y,4,a[32]),T,I,g,11,a[33]),M,T,E,16,a[34]),P,M,A,23,a[35]),I=h(I,P=h(P,M=h(M,T,I,P,c,4,a[36]),T,I,b,11,a[37]),M,T,v,16,a[38]),P,M,_,23,a[39]),I=h(I,P=h(P,M=h(M,T,I,P,k,4,a[40]),T,I,s,11,a[41]),M,T,p,16,a[42]),P,M,m,23,a[43]),I=h(I,P=h(P,M=h(M,T,I,P,w,4,a[44]),T,I,S,11,a[45]),M,T,x,16,a[46]),P,M,d,23,a[47]),I=l(I,P=l(P,M=l(M,T,I,P,s,6,a[48]),T,I,v,10,a[49]),M,T,A,15,a[50]),P,M,y,21,a[51]),I=l(I,P=l(P,M=l(M,T,I,P,S,6,a[52]),T,I,p,10,a[53]),M,T,_,15,a[54]),P,M,c,21,a[55]),I=l(I,P=l(P,M=l(M,T,I,P,g,6,a[56]),T,I,x,10,a[57]),M,T,m,15,a[58]),P,M,k,21,a[59]),I=l(I,P=l(P,M=l(M,T,I,P,b,6,a[60]),T,I,E,10,a[61]),M,T,d,15,a[62]),P,M,w,21,a[63]),o[0]=o[0]+M|0,o[1]=o[1]+T|0,o[2]=o[2]+I|0,o[3]=o[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function u(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],162:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],168:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],169:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],170:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],171:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],172:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,c;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),c=o.words,u=s.words,f=r.keySize,h=r.iterations;c.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;n[0]^=u,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=u,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],174:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;i[0]^=u,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=u,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],176:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,M,T=this._hash.words,I=h.words,P=l.words,B=a.words,R=c.words,C=u.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)M=o+t[e+B[r]]|0,M+=r<16?p(s,d,w)+I[0]:r<32?b(s,d,w)+I[1]:r<48?y(s,d,w)+I[2]:r<64?m(s,d,w)+I[3]:v(s,d,w)+I[4],M=(M=g(M|=0,C[r]))+_|0,o=_,_=w,w=g(d,10),d=s,s=M,M=E+t[e+R[r]]|0,M+=r<16?v(S,k,A)+P[0]:r<32?m(S,k,A)+P[1]:r<48?y(S,k,A)+P[2]:r<64?b(S,k,A)+P[3]:p(S,k,A)+P[4],M=(M=g(M|=0,O[r]))+x|0,E=x,x=A,A=g(k,10),k=S,S=M;M=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=M},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function m(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function g(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],177:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|t[e+u];else{var f=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=f<<1|f>>>31}var h=(n<<5|n>>>27)+c+o[u];h+=u<20?1518500249+(i&s|~i&a):u<40?1859775393+(i^s^a):u<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],178:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":153,"./sha256":179}],179:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),c[i]=r(e.pow(n,1/3)),i++),n++}();var u=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)u[d]=0|t[e+d];else{var p=u[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[d-2],m=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[d]=b+u[d-7]+m+u[d-16]}var v=n&i^n&o^i&o,g=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+c[d]+u[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(g+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],180:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],u=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){c[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)u[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var m=h[(l+4)%5],v=h[(l+1)%5],g=v.high,w=v.low;for(d=m.high^(g<<1|w>>>31),p=m.low^(w<<1|g>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[u[_]];A.high=d,A.low=p}var x=h[0],M=r[0];x.high=M.high,x.low=M.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],I=h[_],P=h[(l+1)%5+5*b],B=h[(l+2)%5+5*b];T.high=I.high^~P.high&B.high,T.low=I.low^~P.low&B.low}T=r[0];var R=f[a];T.high^=R.high,T.low^=R.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),u.push(d),u.push(l)}return new i.init(u,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],181:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":153,"./sha512":182,"./x64-core":184}],182:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var t=0;t<80;t++)u[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,m=o.high,v=o.low,g=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,M=l.high,T=l.low,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_,D=E,U=S,K=k,H=A,q=x,z=M,F=T,W=0;W<80;W++){var V=u[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var J=u[W-15],Z=J.high,X=J.low,$=(Z>>>1|X<<31)^(Z>>>8|X<<24)^Z>>>7,Q=(X>>>1|Z<<31)^(X>>>8|Z<<24)^(X>>>7|Z<<25),tt=u[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=u[W-7],st=ot.high,at=ot.low,ct=u[W-16],ut=ct.high,ft=ct.low;G=(G=(G=$+st+((Y=Q+at)>>>0>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ut+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=N&U^~N&H,dt=D&K^~D&q,pt=I&B^I&C^B&C,bt=P&R^P&O^R&O,yt=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),mt=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),vt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),wt=c[W],_t=wt.high,Et=wt.low,St=z+vt+((ht=F+gt)>>>0>>0?1:0),kt=mt+bt;z=H,F=q,H=U,q=K,U=N,K=D,N=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0

>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((D=j+ht|0)>>>0>>0?1:0)|0,L=C,j=O,C=B,O=R,B=I,R=P,I=St+(yt+pt+(kt>>>0>>0?1:0))+((P=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+P,n.high=d+I+(p>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var g=t("./templates");for(var v in g)e.exports[v]=g[v]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),g=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:g};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function g(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,v=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!g(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),v&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,g,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,g=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(g=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,g=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,g=u,v=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,g=u=h.P2PKH,v=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}g===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=g,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!g(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,g="...",v=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",I="[object Array]",x="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",q="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,J=RegExp(Y.source),Z=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[F]=yt[q]=!0,yt[A]=yt[I]=yt[L]=yt[x]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var gt={};gt[A]=gt[I]=gt[L]=gt[x]=gt[T]=gt[j]=gt[D]=gt[N]=gt[U]=gt[H]=gt[P]=gt[C]=gt[R]=gt[O]=gt[K]=gt[z]=gt[F]=gt[q]=!0,gt[M]=gt[B]=gt["[object Map]"]=gt["[object Set]"]=gt["[object WeakMap]"]=!1;var vt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,It=Et[typeof e]&&e&&!e.nodeType&&e,xt=At&&It&&"object"==typeof t&&t;!xt||xt.global!==xt&&xt.window!==xt&&xt.self!==xt||(kt=xt);var Tt=It&&It.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function qt(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!qn(t)){if(t instanceof Le)return t;if(Zt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=xe,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ge(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Jr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function Fr(t,e,i,o,s,p,y,g,v,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,I=!E&&Kr(t),x=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=qt(b,T);if((f-=M.length)=(e=+e)||!ve(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var g=e&u;if(!g&&!Yn(t))throw new It(S);var v=i?i.length:0;if(v||(e&=~(l|d),i=o=null),v-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!g&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],g=(l?t:e)[8],v=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=v)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Zt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Zt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Zr(n)&&(qn(t)||i.nonEnumArgs&&Fn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Zt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=qn(t)?Fe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(qn(t)?qe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(qn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?ze(t,e):sr(t,Rr(e,r,3))}function In(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var xn=Dr(function(t,e,r){Zt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(qn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=xe;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new It(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function g(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),g=n<=0||n>l;g?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return g&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(g=!0,s=t.apply(u,i)),!g||c||o||(i=u=null),s}return g.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},g}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!Fe(t,Yn))throw new It(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new It(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function Fn(t){return Zr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var qn=ye||function(t){return zt(t)&&Zr(t.length)&&$t.call(t)==I||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ve(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Jn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Zn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Jn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Zr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return gr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Zr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Zr(e)&&(qn(t)||je.nonEnumArgs&&Fn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=vn,Oe.chunk=function(t,e,n){e=(n?Jr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Jr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Jr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Zr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return Ir(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Zt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=Fn,Oe.isArray=qn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==x||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Zr(e)&&(qn(t)||ti(t)||Fn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?vr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Zt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Zn(t)&&t!=+t},Oe.isNative=Jn,Oe.isNull=function(t){return null===t},Oe.isNumber=Zn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=Ii,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ve(e))return t;var i=(e-n)/2,o=se(i);return(r=qr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&qr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+qr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Jr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Zr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=gi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Jr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Ze)).imports),i.imports,Ze),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=vi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Jr(t,e,r)&&(e=null);var n=y,i=g;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||qn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=xt[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!qn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[g++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[g++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[g++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[g++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[g++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[g++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[g++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[g++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):g(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},i(I,A),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],g=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,c[r]=v;v=16843009*g^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[g^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],g=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=g,l=v}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],g=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:g}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},g=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=g.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,g.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],g=t[e+6],v=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],I=t[e+15],x=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,x=c(x,T,M,B,s,7,a[0]),T,M,u,12,a[1]),x,T,d,17,a[2]),B,x,p,22,a[3]),M=c(M,B=c(B,x=c(x,T,M,B,b,7,a[4]),T,M,y,12,a[5]),x,T,g,17,a[6]),B,x,v,22,a[7]),M=c(M,B=c(B,x=c(x,T,M,B,m,7,a[8]),T,M,w,12,a[9]),x,T,_,17,a[10]),B,x,E,22,a[11]),M=c(M,B=c(B,x=c(x,T,M,B,S,7,a[12]),T,M,k,12,a[13]),x,T,A,17,a[14]),B,x,I,22,a[15]),M=f(M,B=f(B,x=f(x,T,M,B,u,5,a[16]),T,M,g,9,a[17]),x,T,E,14,a[18]),B,x,s,20,a[19]),M=f(M,B=f(B,x=f(x,T,M,B,y,5,a[20]),T,M,_,9,a[21]),x,T,I,14,a[22]),B,x,b,20,a[23]),M=f(M,B=f(B,x=f(x,T,M,B,w,5,a[24]),T,M,A,9,a[25]),x,T,p,14,a[26]),B,x,m,20,a[27]),M=f(M,B=f(B,x=f(x,T,M,B,k,5,a[28]),T,M,d,9,a[29]),x,T,v,14,a[30]),B,x,S,20,a[31]),M=h(M,B=h(B,x=h(x,T,M,B,y,4,a[32]),T,M,m,11,a[33]),x,T,E,16,a[34]),B,x,A,23,a[35]),M=h(M,B=h(B,x=h(x,T,M,B,u,4,a[36]),T,M,b,11,a[37]),x,T,v,16,a[38]),B,x,_,23,a[39]),M=h(M,B=h(B,x=h(x,T,M,B,k,4,a[40]),T,M,s,11,a[41]),x,T,p,16,a[42]),B,x,g,23,a[43]),M=h(M,B=h(B,x=h(x,T,M,B,w,4,a[44]),T,M,S,11,a[45]),x,T,I,16,a[46]),B,x,d,23,a[47]),M=l(M,B=l(B,x=l(x,T,M,B,s,6,a[48]),T,M,v,10,a[49]),x,T,A,15,a[50]),B,x,y,21,a[51]),M=l(M,B=l(B,x=l(x,T,M,B,S,6,a[52]),T,M,p,10,a[53]),x,T,_,15,a[54]),B,x,u,21,a[55]),M=l(M,B=l(B,x=l(x,T,M,B,m,6,a[56]),T,M,I,10,a[57]),x,T,g,15,a[58]),B,x,k,21,a[59]),M=l(M,B=l(B,x=l(x,T,M,B,b,6,a[60]),T,M,E,10,a[61]),x,T,d,15,a[62]),B,x,w,21,a[63]),o[0]=o[0]+x|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,I,x,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],I=_=T[4];for(r=0;r<80;r+=1)x=o+t[e+P[r]]|0,x+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?g(s,d,w)+M[3]:v(s,d,w)+M[4],x=(x=m(x|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=x,x=E+t[e+C[r]]|0,x+=r<16?v(S,k,A)+B[0]:r<32?g(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],x=(x=m(x|=0,O[r]))+I|0,E=I,I=A,A=m(k,10),k=S,S=x;x=T[1]+d+A|0,T[1]=T[2]+w+I|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=x},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function g(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+g+c[d-16]}var v=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var g=h[(l+4)%5],v=h[(l+1)%5],m=v.high,w=v.low;for(d=g.high^(m<<1|w>>>31),p=g.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var I=h[0],x=r[0];I.high=x.high,I.low=x.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,g=o.high,v=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,I=h.low,x=l.high,T=l.low,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=I,F=x,q=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),gt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),vt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=F+vt+((ht=q+mt)>>>0>>0?1:0),kt=gt+bt;F=K,q=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0

>>0?1:0),y=i.low=y+R,i.high=b+B+(y>>>0>>0?1:0),v=o.low=v+O,o.high=m+C+(v>>>0>>0?1:0),w=s.low=w+j,s.high=g+L+(w>>>0>>0?1:0),E=a.low=E+D,a.high=_+N+(E>>>0>>0?1:0),k=f.low=k+K,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+q,h.high=A+H+(x>>>0>>0?1:0),T=l.low=T+F,l.high=M+z+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],183:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var u=i[o]=[],f=c[o];for(r=0;r<24;r++)u[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^i[c])&f[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":186,_process:270}],186:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,c=t.keys.length-2;c>=0;c-=2){var u=t.keys[c],f=t.keys[c+1];o.expand(s,t.tmp,0),u^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(u,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":189,"./utils":192,inherits:258,"minimalistic-assert":265}],191:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":189,"./des":190,inherits:258,"minimalistic-assert":265}],192:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),e.cmp(c)){if(!e.cmp(u))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":82,"miller-rabin":264,randombytes:303}],196:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],197:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":201,assert:23,bigi:32}],198:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],199:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":197,"./names":200,"./point":201}],200:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),c=new BigInteger(e.h,16),u=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,u,f,a,c)}},{"./curve":197,"./curves.json":198,bigi:32}],201:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),u=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(u.shiftLeft(1)).multiply(t.z).subtract(c).multiply(s).mod(this.curve.p),l=u.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),u=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,u)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=e.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=t.pointFromX(c,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var u=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,u)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:23,bigi:32,"safe-buffer":321}],202:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":217,"./elliptic/curve":205,"./elliptic/curves":208,"./elliptic/ec":209,"./elliptic/eddsa":212,"./elliptic/utils":216,brorand:83}],203:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)c=(c<<1)+n[f];u.push(c)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){var a,c,u,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var m=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(m[1]=e[b].add(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].add(e[y].neg())):(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],g=s(r[b],r[y]);for(d=Math.max(g[0].length,d),l[b]=new Array(d),l[y]=new Array(d),c=0;c=0;a--){for(var k=0;a>=0;){var A=!0;for(c=0;c=0&&k++,E=E.dblp(k),a<0)break;for(c=0;c0?u=h[c][x-1>>1]:x<0&&(u=h[c][-x-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(c);this.zOne?(t=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),e=u.redMul(n.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),t=s.redSub(a).redISub(c).redMul(o),e=u.redMul(n.redSub(c)),r=u.redMul(o))}else n=a.redAdd(c),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(c)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(u,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(e=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(e=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],205:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":203,"./edwards":204,"./mont":206,"./short":207}],206:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),c=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],207:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function c(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(c,s),e.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),m=new i(1),v=0;0!==l.cmpn(0);){var g=d.div(l);u=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&u.cmp(h)<0)e=c.neg(),r=p,n=u.neg(),o=f;else if(n&&2==++v)break;c=u,d=l,l=u,y=p,p=f,m=b,b=w}s=u.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(u,s.BasePoint),c.prototype.jpoint=function(t,e,r){return new u(this,t,e,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),l=c.redSqr().redIAdd(f).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},u.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},u.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],208:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function c(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":205,"./precomputed/secp256k1":215,"./utils":216,"hash.js":244}],209:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),c=o.assert,u=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new u(this,t)},h.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),c=t.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new f({r:y,s:m,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(t).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,u=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=u.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":208,"../utils":216,"./key":210,"./signature":211,"bn.js":82,brorand:83,"hmac-drbg":256}],210:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":216,"bn.js":82}],211:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function c(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var c=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var u=a(t,r);if(!1===u)return!1;if(t.length!==u+r.place)return!1;var f=t.slice(r.place,u+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(c),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=c(e),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,e.length),(n=n.concat(e)).push(2),u(n,r.length);var o=n.concat(r),s=[48];return u(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":216,"bn.js":82}],212:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,c=t("./key"),u=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-c:c,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,c=t.andln(3)+i&3,u=e.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==c?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":82,"minimalistic-assert":265,"minimalistic-crypto-utils":266}],217:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],218:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var u=new n;u.update(c),u.update(t),e&&u.update(e),c=u.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,c.length),c.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,c.length-f);c.copy(a,l,f,f+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":262,"safe-buffer":321}],219:[function(t,e,r){},{}],220:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(u=r.slice()).length,c=0;c0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],221:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,u=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,m="-",v=/^xn--/,g=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function M(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function P(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function B(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function R(t){var e,r,n,i,o,s,a,c,d,p,v,g=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(m))<0&&(r=0),n=0;n=128&&A("not-basic"),g.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||c>S((u-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(u/(p=f-d))&&A("overflow"),s*=p;k=B(_-o,e=g.length+1,0==o),S(_/e)>u-E&&A("overflow"),E+=S(_/e),_%=e,g.splice(_++,0,E)}return I(g)}function C(t){var e,r,n,i,o,s,a,c,d,p,v,g,w,_,E,x=[];for(g=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((u-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;su&&A("overflow"),v==e){for(c=r,d=f;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=c-p,_=f-p,x.push(k(P(p+E%_,0))),c=S(E/_);x.push(k(P(c,0))),o=B(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:I},decode:R,encode:C,toASCII:function(t){return M(t,function(t){return g.test(t)?"xn--"+C(t):t})},toUnicode:function(t){return M(t,function(t){return v.test(t)?R(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],222:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":223}],223:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),u=0;u0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),I(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function B(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function C(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?B(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&B(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?P(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&B(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var c=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:g;function u(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",m),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",u),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(c):n.once("end",c),t.on("unpipe",u);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,I(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==C(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),g(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",v),g()}function v(){l("onfinish"),t.removeListener("close",m),g()}function g(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",m),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;m.WritableState=y;var u=Object.create(t("core-util-is"));u.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?c(g,t,r,s,i):g(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(e){if(a=a||t("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function g(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}u.inherits(m,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var c=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":223,"./internal/streams/destroy":229,"./internal/streams/stream":230,_process:270,"core-util-is":116,inherits:258,"process-nextick-args":231,"safe-buffer":237,timers:348,"util-deprecate":356}],228:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":237,util:219}],229:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":231}],230:[function(t,e,r){e.exports=t("events").EventEmitter},{events:220}],231:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],233:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":234}],234:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":223,"./lib/_stream_passthrough.js":224,"./lib/_stream_readable.js":225,"./lib/_stream_transform.js":226,"./lib/_stream_writable.js":227}],235:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":234}],236:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":227}],237:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],238:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",c),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",u),t.on("error",u),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:220,inherits:258,"readable-stream/duplex.js":222,"readable-stream/passthrough.js":233,"readable-stream/readable.js":234,"readable-stream/transform.js":235,"readable-stream/writable.js":236}],239:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=u,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],240:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{dup:24}],241:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],242:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{"./support/isBuffer":241,_process:270,dup:26,inherits:240}],243:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:258,"readable-stream":319,"safe-buffer":321}],244:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":255}],255:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var c=0,u=e;return c+=(u=u+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,c,u){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,c,u){return e+n+o+a+u>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:258,"minimalistic-assert":265}],256:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*b}},{}],258:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],259:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],260:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],261:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",u=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,m=2,v=4,g=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,M="...",T=800,I=16,P=1,B=2,R=1/0,C=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,N=j-1,D=j>>>1,U=[["ary",S],["bind",y],["bindKey",m],["curry",g],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],K="[object Arguments]",H="[object Array]",q="[object AsyncFunction]",z="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",J="[object Map]",Z="[object Number]",X="[object Null]",$="[object Object]",Q="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ct="[object DataView]",ut="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",mt="[object Uint32Array]",vt=/\b__p \+= '';/g,gt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,Mt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,It=/^\w*$/,Pt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Bt=/[\\^$.*+?()[\]{}|]/g,Rt=RegExp(Bt.source),Ct=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Nt=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Kt=/\\(\\)?/g,Ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,qt=/\w*$/,zt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Jt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Xt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",$t="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qt="[\\ud800-\\udfff]",te="["+$t+"]",ee="["+Xt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+$t+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ce,ue].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ce,ue].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ce,ue,Qt].join("|")+")",me=RegExp("['’]","g"),ve=RegExp(ee,"g"),ge=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Xt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ut]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[mt]=!0,Ae[K]=Ae[H]=Ae[at]=Ae[z]=Ae[ct]=Ae[F]=Ae[V]=Ae[G]=Ae[J]=Ae[Z]=Ae[$]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[K]=xe[H]=xe[at]=xe[ct]=xe[z]=xe[F]=xe[ut]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[J]=xe[Z]=xe[$]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[mt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Me={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Ie=parseInt,Pe="object"==typeof t&&t&&t.Object===Object&&t,Be="object"==typeof self&&self&&self.Object===Object&&self,Re=Pe||Be||Function("return this")(),Ce="object"==typeof r&&r&&!r.nodeType&&r,Oe=Ce&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Ce,je=Le&&Pe.process,Ne=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),De=Ne&&Ne.isArrayBuffer,Ue=Ne&&Ne.isDate,Ke=Ne&&Ne.isMap,He=Ne&&Ne.isRegExp,qe=Ne&&Ne.isSet,ze=Ne&&Ne.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Xe(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Me[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Mr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Re:Or.defaults(Re.Object(),e,Or.pick(Re,Se))).Array,Xt=e.Date,$t=e.Error,Qt=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=Qt.prototype,ae=ee.prototype,ce=e["__core-js_shared__"],ue=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ue.call(ee),be=Re._,ye=re("^"+ue.call(fe).replace(Bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,ge=e.Symbol,_e=e.Uint8Array,Me=Buffer?Buffer.allocUnsafe:n,Pe=xr(ee.getPrototypeOf,ee),Be=ee.create,Ce=ae.propertyIsEnumerable,Oe=oe.splice,je=ge?ge.isConcatSpreadable:n,Ne=ge?ge.iterator:n,nr=ge?ge.toStringTag:n,hr=function(){try{var t=Ko(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Re.clearTimeout&&e.clearTimeout,jr=Xt&&Xt.now!==Re.Date.now&&Xt.now,Nr=e.setTimeout!==Re.setTimeout&&e.setTimeout,Dr=te.ceil,Ur=te.floor,Kr=ee.getOwnPropertySymbols,Hr=Buffer?Buffer.isBuffer:n,qr=e.isFinite,zr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Xt.now,Yr=e.parseInt,Jr=te.random,Zr=oe.reverse,Xr=Ko(e,"DataView"),$r=Ko(e,"Map"),Qr=Ko(e,"Promise"),tn=Ko(e,"Set"),en=Ko(e,"WeakMap"),rn=Ko(ee,"create"),nn=en&&new en,on={},sn=ls(Xr),an=ls($r),cn=ls(Qr),un=ls(tn),fn=ls(en),hn=ge?ge.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ia(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof mn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new mn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Be)return Be(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function mn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function gn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,c=e&h,u=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return no(t,a)}else{var b=zo(t),y=b==G||b==Y;if(Ea(t))return Xi(t,c);if(b==$||b==K||y&&!o){if(a=u||y?{}:Wo(t),!c)return u?function(t,e){return io(t,qo(t),e)}(t,function(t,e){return t&&io(e,sc(e),t)}(a,t)):function(t,e){return io(t,Ho(t),e)}(t,Rn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return $i(t);case z:case F:return new s(+t);case ct:return function(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ut:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case mt:return Qi(t,r);case J:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,qt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,c)}}s||(s=new Sn);var m=s.get(t);if(m)return m;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Pa(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?u?Co:Ro:u?sc:oc)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),In(a,i,jn(n,e,r,i,t,s))}),a}function Nn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Dn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,c=t.length,u=[],f=e.length;if(!c)return u;r&&(e=$e(e,yr(r))),n?(s=Xe,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Pn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new gn,map:new($r||wn),string:new gn}},_n.prototype.delete=function(t){var e=Do(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return Do(this,t).get(t)},_n.prototype.has=function(t){return Do(this,t).has(t)},_n.prototype.set=function(t,e){var r=Do(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,c),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!$r||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):Qe(i,a):n||(i[i.length]=a)}return i}var Vn=co(),Gn=co(!0);function Yn(t,e){return t&&Vn(t,e,oc)}function Jn(t,e){return t&&Gn(t,e,oc)}function Zn(t,e){return Je(e,function(e){return Aa(t[e])})}function Xn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Xe:Ze,o=t[0].length,s=t.length,a=s,c=Ot(s),u=1/0,f=[];a--;){var h=t[a];a&&e&&(h=$e(h,yr(e))),u=Vr(h.length,u),c[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=c[0];t:for(;++l=a)return c;var u=r[n];return c*("desc"==u?-1:1)}}return t.index-e.index}(t,e,r)})}function gi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,c,1),Oe.call(t,c,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Jr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>C)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Bc),t+"")}function Ai(t){return An(pc(t))}function xi(t,e){var r=pc(t);return us(r,Ln(e,0,r.length))}function Mi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,c=t;null!=c&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,u=new En}else u=e?[]:c;t:for(;++n=i?t:Bi(t,e,r)}var Zi=Lr||function(t){return Re.clearTimeout(t)};function Xi(t,e){if(e)return t.slice();var r=t.length,n=Me?Me(r):new t.constructor(r);return t.copy(n),n}function $i(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function Qi(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,c=null===e,u=e==e,f=ja(e);if(!c&&!f&&!s&&t>e||s&&a&&u&&!c&&!f||i&&a&&u||!r&&u||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Bo(function(e){var r=e.length,i=r,o=mn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!c&&"wrapper"==Lo(a))var c=new mn([],!0)}for(i=c?i:r;++i1&&g.reverse(),h&&uc))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Nt):[]}(n),r)))}function cs(t){var e=0,r=0;return function(){var i=Gr(),o=I-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function us(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Cs(t,r="function"==typeof r?(t.pop(),r):n)});function Ks(t){var e=pn(t);return e.__chain__=!0,e}function Hs(t,e){return e(t)}var qs=Bo(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Hs,args:[o],thisArg:n}),new mn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var zs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Cn(t,r,1)});var Fs=lo(ms),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Kn)(t,No(e,3))}function Gs(t,e){return(va(t)?Ge:Hn)(t,No(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Cn(t,r,[e])});var Js=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Kn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Cn(t,r,e)});function Xs(t,e){return(va(t)?$e:di)(t,No(e,3))}var $s=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var Qs=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Re.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Mr(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|m;if(r.length){var i=Mr(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,c,u,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,c=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function m(){var t=ta();if(y(t))return v(t);u=os(m,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return u=n,p&&i?b(t):(i=o=n,c)}function g(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(u===n)return function(t){return h=t,u=os(m,e),l?b(t):c}(f);if(d)return Zi(u),u=os(m,e),b(f)}return u===n&&(u=os(m,e)),c}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),g.cancel=function(){u!==n&&Zi(u),h=0,i=f=o=u=n},g.flush=function(){return u===n?c:v(ta())},g}var sa=ki(function(t,e){return Dn(t,1,e)}),aa=ki(function(t,e,r){return Dn(t,Fa(e)||0,r)});function ca(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ca.Cache||_n),r}function ua(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ca.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?$e(e[0],yr(No())):$e(Wn(e,1),yr(No()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ma=oi(function(){return arguments}())?oi:function(t){return Ia(t)&&fe.call(t,"callee")&&!Ce.call(t,"callee")},va=Ot.isArray,ga=De?yr(De):function(t){return Ia(t)&&Qn(t)==at};function wa(t){return null!=t&&Ma(t.length)&&!Aa(t)}function _a(t){return Ia(t)&&wa(t)}var Ea=Hr||Fc,Sa=Ue?yr(Ue):function(t){return Ia(t)&&Qn(t)==F};function ka(t){if(!Ia(t))return!1;var e=Qn(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ra(t)}function Aa(t){if(!Ta(t))return!1;var e=Qn(t);return e==G||e==Y||e==q||e==Q}function xa(t){return"number"==typeof t&&t==qa(t)}function Ma(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=C}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ia(t){return null!=t&&"object"==typeof t}var Pa=Ke?yr(Ke):function(t){return Ia(t)&&zo(t)==J};function Ba(t){return"number"==typeof t||Ia(t)&&Qn(t)==Z}function Ra(t){if(!Ia(t)||Qn(t)!=$)return!1;var e=Pe(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ue.call(r)==pe}var Ca=He?yr(He):function(t){return Ia(t)&&Qn(t)==tt};var Oa=qe?yr(qe):function(t){return Ia(t)&&zo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ia(t)&&Qn(t)==rt}function ja(t){return"symbol"==typeof t||Ia(t)&&Qn(t)==nt}var Na=ze?yr(ze):function(t){return Ia(t)&&Ma(t.length)&&!!Ae[Qn(t)]};var Da=_o(li),Ua=_o(function(t,e){return t<=e});function Ka(t){if(!t)return[];if(wa(t))return La(t)?Br(t):no(t);if(Ne&&t[Ne])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Ne]());var e=zo(t);return(e==J?Ar:e==et?Tr:pc)(t)}function Ha(t){return t?(t=Fa(t))===R||t===-R?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function qa(t){var e=Ha(t),r=e%1;return e==e?r?e-r:e:0}function za(t){return t?Ln(qa(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Ie(t.slice(2),r?2:8):zt.test(t)?L:+t}function Wa(t){return io(t,sc(t))}function Va(t){return null==t?"":Ni(t)}var Ga=so(function(t,e){if($o(e)||wa(e))io(e,oc(e),t);else for(var r in e)fe.call(e,r)&&In(t,r,e[r])}),Ya=so(function(t,e){io(e,sc(e),t)}),Ja=so(function(t,e,r,n){io(e,sc(e),t,n)}),Za=so(function(t,e,r,n){io(e,oc(e),t,n)}),Xa=Bo(On);var $a=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Co(t),r),n&&(r=jn(r,h|l|d,Io));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fc=Bo(function(t,e){return null==t?{}:function(t,e){return gi(t,e,function(e,r){return ec(t,r)})}(t,e)});function hc(t,e){if(null==t)return{};var r=$e(Co(t),function(t){return[t]});return e=No(e),gi(t,r,function(t,r){return e(t,r[0])})}var lc=Ao(oc),dc=Ao(sc);function pc(t){return null==t?[]:mr(t,oc(t))}var bc=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yc(e):e)});function yc(t){return kc(Va(t).toLowerCase())}function mc(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vc=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),gc=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wc=uo("toLowerCase");var _c=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Ec=fo(function(t,e,r){return t+(r?" ":"")+kc(e)});var Sc=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),kc=uo("toUpperCase");function Ac(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(e)||[]}var xc=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new $t(t)}}),Mc=Bo(function(t,e){return Ve(e,function(e){e=hs(e),Cn(t,e,na(t[e],t))}),t});function Tc(t){return function(){return t}}var Ic=po(),Pc=po(!0);function Bc(t){return t}function Rc(t){return ui("function"==typeof t?t:jn(t,h))}var Cc=ki(function(t,e){return function(r){return ii(r,t,e)}}),Oc=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lc(t,e,r){var n=oc(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,oc(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,Qe([this.value()],arguments))})}),t}function jc(){}var Nc=vo($e),Dc=vo(Ye),Uc=vo(rr);function Kc(t){return Jo(t)?fr(hs(t)):function(t){return function(e){return Xn(e,t)}}(t)}var Hc=wo(),qc=wo(!0);function zc(){return[]}function Fc(){return!1}var Wc=mo(function(t,e){return t+e},0),Vc=So("ceil"),Gc=mo(function(t,e){return t/e},1),Yc=So("floor");var Jc,Zc=mo(function(t,e){return t*e},1),Xc=So("round"),$c=mo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Ja,pn.assignWith=Za,pn.at=Xa,pn.before=ra,pn.bind=na,pn.bindAll=Mc,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Ks,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(qa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Dr(i/e));oo?0:o+r),(i=i===n||i>o?o:qa(i))<0&&(i+=o),i=r>i?0:za(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ca(e))&&!(e=Ni(e))&&kr(t)?Ji(Br(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(qa(e),0),ki(function(r){var n=r[e],i=Ji(r,0,e);return n&&Qe(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Bi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Bi(t,0,(e=r||e===n?1:qa(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Bi(t,(e=i-(e=r||e===n?1:qa(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Hi(t,No(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Hi(t,No(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Hs,pn.toArray=Ka,pn.toPairs=lc,pn.toPairsIn=dc,pn.toPath=function(t){return va(t)?$e(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Na(t);if(e=No(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Pe(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Is,pn.unionBy=Ps,pn.unionWith=Bs,pn.uniq=function(t){return t&&t.length?Di(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Di(t,No(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Di(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Rs,pn.unzipWith=Cs,pn.update=function(t,e,r){return null==t?t:Ki(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Ki(t,e,Vi(r),i)},pn.values=pc,pn.valuesIn=function(t){return null==t?[]:mr(t,sc(t))},pn.without=Os,pn.words=Ac,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ns,pn.zip=Ds,pn.zipObject=function(t,e){return Fi(t||[],e||[],In)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Mi)},pn.zipWith=Us,pn.entries=lc,pn.entriesIn=dc,pn.extend=Ya,pn.extendWith=Ja,Lc(pn,pn),pn.add=Wc,pn.attempt=xc,pn.camelCase=bc,pn.capitalize=yc,pn.ceil=Vc,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Nn(t,e,oc(e))},pn.deburr=mc,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gc,pn.endsWith=function(t,e,r){t=Va(t),e=Ni(e);var i=t.length,o=r=r===n?i:Ln(qa(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Rt.test(t)?t.replace(Bt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:qn;return r&&Yo(t,e,r)&&(e=n),i(t,No(e,3))},pn.find=Fs,pn.findIndex=ms,pn.findKey=function(t,e){return ir(t,No(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,No(e,3),Jn)},pn.floor=Yc,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,No(e,3),sc)},pn.forInRight=function(t,e){return null==t?t:Gn(t,No(e,3),sc)},pn.forOwn=function(t,e){return t&&Yn(t,No(e,3))},pn.forOwnRight=function(t,e){return t&&Jn(t,No(e,3))},pn.get=tc,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=ec,pn.head=ws,pn.identity=Bc,pn.includes=function(t,e,r,n){t=wa(t)?t:pc(t),r=r&&!n?qa(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:qa(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ha(e),r===n?(r=e,e=0):r=Ha(r),function(t,e,r){return t>=Vr(e,r)&&t=-C&&t<=C},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Na,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ia(t)&&zo(t)==ot},pn.isWeakSet=function(t){return Ia(t)&&Qn(t)==st},pn.join=function(t,e){return null==t?"":zr.call(t,e)},pn.kebabCase=vc,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=qa(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,cr,o,!0)},pn.lowerCase=gc,pn.lowerFirst=wc,pn.lt=Da,pn.lte=Ua,pn.max=function(t){return t&&t.length?zn(t,Bc,ti):n},pn.maxBy=function(t,e){return t&&t.length?zn(t,No(e,2),ti):n},pn.mean=function(t){return ur(t,Bc)},pn.meanBy=function(t,e){return ur(t,No(e,2))},pn.min=function(t){return t&&t.length?zn(t,Bc,li):n},pn.minBy=function(t,e){return t&&t.length?zn(t,No(e,2),li):n},pn.stubArray=zc,pn.stubFalse=Fc,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zc,pn.nth=function(t,e){return t&&t.length?mi(t,qa(e)):n},pn.noConflict=function(){return Re._===this&&(Re._=be),this},pn.noop=jc,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return go(Ur(i),r)+t+go(Dr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Jr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Kn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Hn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:qa(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iC)return[];var r=j,n=Vr(t,j);e=No(e),t-=j;for(var i=pr(n,e);++r=s)return t;var c=r-Pr(i);if(c<1)return i;var u=a?Ji(a,0,c).join(""):t.slice(0,c);if(o===n)return u+i;if(a&&(c+=u.length-c),Ca(o)){if(t.slice(c).search(o)){var f,h=u;for(o.global||(o=re(o.source,Va(qt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;u=u.slice(0,l===n?c:l)}}else if(t.indexOf(Ni(o),c)!=c){var d=u.lastIndexOf(o);d>-1&&(u=u.slice(0,d))}return u+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Cr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Sc,pn.upperFirst=kc,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lc(pn,(Jc={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Jc[e]=t)}),Jc),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(qa(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:No(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Bc)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ua(No(t)))},vn.prototype.slice=function(t,e){t=qa(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=qa(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,c=e instanceof vn,u=a[0],f=c||va(e),h=function(t){var e=o.apply(pn,Qe([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof u&&1!=u.length&&(c=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=c&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Hs,args:[h],thisArg:n}),new mn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,m).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Hs,args:[Ts],thisArg:n}),new mn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return qi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Ne&&(pn.prototype[Ne]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Ce._=Or):Re._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],262:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function c(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function u(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=u(i,s=u(s,r=u(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=u(i,s=u(s,r=u(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=u(i,s=u(s,r=u(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=u(i,s=u(s,r=u(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":243,inherits:258,"safe-buffer":321}],263:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),c=0;!a.testn(c);c++);for(var u=t.shrn(c),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(u);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(u)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],267:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===u&&!1===isNaN(t))return e.long?c(r=t,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],268:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),c=1;cn)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,u,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,u=new Buffer(a),c=o-((f=Math.ceil(o/a))-1)*a),p.copy(u,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?u(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),u=e.slice(s+1),f=o(a,i(u,s)),h=o(u,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,"safe-buffer":321}],295:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),c=t("bn.js"),u=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,u=o("sha1").update(Buffer.alloc(0)).digest(),f=u.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([u,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new c(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):u(l,d)}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,randombytes:303,"safe-buffer":321}],296:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":82,"safe-buffer":321}],297:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":39}],299:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function c(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){o=f,u.port1.onmessage=c,c()};var f=function(){u.port2.postMessage(0)};o=function(){setTimeout(c,0),f()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(t){return function(){return a.apply(t,arguments)}}var u,f=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return B(t)?t:R(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):H(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=P(t);return B(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(H(e))},i.reject=function(e){t||a(K(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function M(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=M,x.all=F,x.reject=K,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=M,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return K(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return K(t)}}return K(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=I,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=P,k.isPromise=B,k.isPromiseAlike=R,k.isPending=function(t){return B(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!B(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return B(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var C,O,L,j=[],N=[],D=!0;function U(){j.length=0,N.length=0,D||(D=!0)}function K(t){var e=T({when:function(e){return e&&function(t){if(D){var e=l(N,t);-1!==e&&(N.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){D&&(N.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function H(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function q(t,e,r){return k(t).spread(e,r)}function z(t,e,r){return k(t).dispatch(e,r)}function F(t){return I(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;B(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,I(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return I(t,function(t){return t=d(t,k),I(F(d(t,function(t){return I(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),D=!1},U(),k.reject=K,k.fulfill=H,k.master=function(t){return T({isDef:function(){}},function(e,r){return z(t,e,r)},function(){return k(t).inspect()})},k.spread=q,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return K(t)}return o.done?o.value:I(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===m(t)||t instanceof u}(t)?t.value:K(t)}return I(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new u(t)},k.promised=function(t){return function(){return q([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=z,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(C=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),C.apply(C,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],300:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=t.length;c>0&&u>c&&(u=c);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],301:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;au||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>u||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}c&&c.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:270,randombytes:303,"safe-buffer":321}],305:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(c," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],306:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=u;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(u,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):B(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,B(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(P,t))}function P(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function B(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function L(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function K(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):I(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new g("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function a(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==K(i.pipes,t))&&!h&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){c("onfinish"),t.removeListener("close",p),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?I(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(C,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(C,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,P(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":305,"./_stream_duplex":306,"./internal/streams/destroy":313,"./internal/streams/state":317,"./internal/streams/stream":318,_process:270,buffer:110,inherits:258,"util-deprecate":356}],311:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[c]?n(t[c]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[u]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[c]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[u]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":314,_process:270}],312:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))})});return r.reduce(u)}},{"../../../errors":305,"./end-of-stream":314}],317:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":305}],318:[function(t,e,r){arguments[4][230][0].apply(r,arguments)},{dup:230,events:220}],319:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":306,"./lib/_stream_passthrough.js":307,"./lib/_stream_readable.js":308,"./lib/_stream_transform.js":309,"./lib/_stream_writable.js":310,"./lib/internal/streams/end-of-stream.js":314,"./lib/internal/streams/pipeline.js":316}],320:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,g=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,M;A<16?(x=p(r,n,i,l,g,t[s[A]],f[0],c[A]),M=v(w,_,E,S,k,t[a[A]],h[0],u[A])):A<32?(x=b(r,n,i,l,g,t[s[A]],f[1],c[A]),M=m(w,_,E,S,k,t[a[A]],h[1],u[A])):A<48?(x=y(r,n,i,l,g,t[s[A]],f[2],c[A]),M=y(w,_,E,S,k,t[a[A]],h[2],u[A])):A<64?(x=m(r,n,i,l,g,t[s[A]],f[3],c[A]),M=b(w,_,E,S,k,t[a[A]],h[3],u[A])):(x=v(r,n,i,l,g,t[s[A]],f[4],c[A]),M=p(w,_,E,S,k,t[a[A]],h[4],u[A])),r=g,g=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=M}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+g+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:110,"hash-base":243,inherits:258}],321:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],322:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:270,buffer:110}],323:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":327,"./lib/elliptic":326}],324:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":259}],325:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var c=t[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+t[i]}if(!(c>n-i)){var u=i;for(i+=c;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);c>0&&0===t[u];c-=1,u+=1);if(!(c>32)){var h=t.slice(u,u+c);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:38,"safe-buffer":321}],326:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),c=a.curve;function u(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(c.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):c.n.sub(e).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=u(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==u(t)},r.publicKeyTweakAdd=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=c.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(c.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var u=new i(e);if(u.cmp(c.n)>=0||u.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=u(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},u=new i(o.r),f=new i(o.s);if(u.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(u.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":328,"bn.js":82,"create-hash":118,elliptic:202,"safe-buffer":321}],327:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":321}],330:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function u(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+u(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],332:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=u(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],333:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":329,"./sha256":334,inherits:258,"safe-buffer":321}],334:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=t.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((e=r[m-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[m-7]+l(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+h(d)+c(d,p,b)+o[v]+r[v]|0,w=f(n)+u(n,i,s)|0;y=b,b=p,p=d,d=a+g|0,a=s,s=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],335:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":329,"./sha512":336,inherits:258,"safe-buffer":321}],336:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,m=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,M=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var I=e[T-30],P=e[T-30+1],B=l(I,P),R=d(P,I),C=p(I=e[T-4],P=e[T-4+1]),O=b(P,I),L=e[T-14],j=e[T-14+1],N=e[T-32],D=e[T-32+1],U=R+j|0,K=B+L+y(U,R)|0;K=(K=K+C+y(U=U+O|0,O)|0)+N+y(U=U+D|0,D)|0,e[T]=K,e[T+1]=U}for(var H=0;H<160;H+=2){K=e[H],U=e[H+1];var q=u(r,n,i),z=u(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[H],J=o[H+1],Z=c(a,m,v),X=c(k,A,x),$=M+G|0,Q=g+V+y($,M)|0;Q=(Q=(Q=Q+Z+y($=$+X|0,X)|0)+Y+y($=$+J|0,J)|0)+K+y($=$+U|0,U)|0;var tt=W+z|0,et=F+q+y(tt,W)|0;g=v,M=x,v=m,x=A,m=a,A=k,a=s+Q+y(k=S+$|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=Q+et+y(w=$+tt|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+M|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+m+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,x)|0,this._hh=this._hh+g+y(this._hl,M)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],337:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var c,u,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(c=t.j[r])[0];var b=c[1],y=c[2],m=c[3],v=c[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^m[255&e]^i[d],u=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^m[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^m[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^m[255&a]^i[d+3],d+=4,o=c,s=u,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],c=o,o=s,s=a,a=e,e=c;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],c=this.j[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=u+r|0,u=c,c=a,s=r+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(e=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,c,u,f=[],h=n.bitArray;for(u=1;32*f.length<(i||1);u++){for(o=s=t.encrypt(h.concat(e,[u])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){c.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":342,"./is-object":344,"./request-base":345,"./response-base":346,"component-emitter":115}],344:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],345:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":344}],346:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":347}],347:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],348:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new u(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new u(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":270,timers:348}],349:[function(t,e,r){var n=t("./native");function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function c(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),c('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,e.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},{"./native":352}],350:[function(t,e,r){(function(Buffer){(function(){var r=t("./native"),n=t("./errors");function i(t){return Buffer.isBuffer(t)}function o(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function s(t,e){var r=t.toJSON();function i(i){if(!t(i))return!1;if(i.length===e)return!0;throw n.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var a=s.bind(null,r.Array),c=s.bind(null,i),u=s.bind(null,o),f=s.bind(null,r.String);var h=Math.pow(2,53)-1;var l={ArrayN:a,Buffer:i,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:o,HexN:u,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":259,"./errors":349,"./native":352}],351:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":349,"./extra":350,"./native":352}],352:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],353:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,u=21,f=28,h=u*f,l=c*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var m=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function g(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?C+="x":C+=R[O];if(!C.match(d)){var j=P.slice(0,M),N=P.slice(M+1),D=R.match(p);D&&(j.push(D[1]),N.unshift(D[2])),N.length&&(g="/"+N.join(".")+g),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+U,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[E])for(M=0,B=f.length;M0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,M=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),M++):M&&(S.splice(T,1),M--);if(!_&&!E)for(;M--;M)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var I,P=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=P?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift()));return(_=_||r.host&&S.length)&&!P&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":355,punycode:221,querystring:302}],355:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],356:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":321}],358:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),c=0,u=a.length;c>"),S("endobj"),b=A[a].join("\n"),T(),u){for(c=[],d=0;d>8&255,f>>16&255,f>>24&255])],b="";for(d in c)c.hasOwnProperty(d)&&(b+=String.fromCharCode.apply(null,c[d]));S("<>")}else S("<>");U(b),S("endobj")}for(D[1]=t,S("1 0 obj"),S("<>"),S("endobj")},W=function(a){a.objectNumber=T(),S("<>"),S("endobj")},X=function(){var a;for(a in E)E.hasOwnProperty(a)&&W(E[a])},Y=function(){N.publish("putXobjectDict")},Z=function(){S("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),S("/Font <<");var a;for(a in E)E.hasOwnProperty(a)&&S("/"+a+" "+E[a].objectNumber+" 0 R");S(">>"),S("/XObject <<"),Y(),S(">>")},$=function(){X(),N.publish("putResources"),D[2]=t,S("2 0 obj"),S("<<"),Z(),S(">>"),S("endobj"),N.publish("postPutResources")},_=function(a,b,c){var d;F[b]===d&&(F[b]={}),F[b][c]=a},aa=function(a,b,d,e){var f="F"+(c(E)+1).toString(10),g=E[f]={id:f,PostScriptName:a,fontName:b,fontStyle:d,encoding:e,metadata:{}};return _(f,b,d),N.publish("addFont",g),f},ba=function(){var a,b,c,d,e="helvetica",f="times",g="courier",h="normal",i="bold",j="italic",k="bolditalic",l="StandardEncoding",m=[["Helvetica",e,h],["Helvetica-Bold",e,i],["Helvetica-Oblique",e,j],["Helvetica-BoldOblique",e,k],["Courier",g,h],["Courier-Bold",g,i],["Courier-Oblique",g,j],["Courier-BoldOblique",g,k],["Times-Roman",f,h],["Times-Bold",f,i],["Times-Italic",f,j],["Times-BoldItalic",f,k]];for(a=0,b=m.length;a>8&&(k=!0);a=j.join("")}for(c=a.length;k===e&&0!==c;)a.charCodeAt(c-1)>>8&&(k=!0),c--;if(k){for(j=b.noBOM?[]:[254,255],c=0,d=a.length;c>8,m>>8)throw new Error("Character at position "+c.toString(10)+" of string '"+a+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");j.push(m),j.push(l-(m<<8))}return String.fromCharCode.apply(e,j)}return a},da=function(a,b){return ca(a,b).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},ea=function(){S("/Producer (jsPDF "+b.version+")"),J.title&&S("/Title ("+da(J.title)+")"),J.subject&&S("/Subject ("+da(J.subject)+")"),J.author&&S("/Author ("+da(J.author)+")"),J.keywords&&S("/Keywords ("+da(J.keywords)+")"),J.creator&&S("/Creator ("+da(J.creator)+")");var a=new Date;S("/CreationDate (D:"+[a.getFullYear(),Q(a.getMonth()+1),Q(a.getDate()),Q(a.getHours()),Q(a.getMinutes()),Q(a.getSeconds())].join("")+")")},fa=function(){S("/Type /Catalog"),S("/Pages 1 0 R"),S("/OpenAction [3 0 R /FitH null]"),S("/PageLayout /OneColumn"),N.publish("putCatalog")},ga=function(){S("/Size "+(B+1)),S("/Root "+B+" 0 R"),S("/Info "+(B-1)+" 0 R")},ha=function(){z++,C=!0,A[z]=[]},ia=function(){ha(),S(O(H*l)+" w"),S(y),0!==K&&S(K.toString(10)+" J"),0!==L&&S(L.toString(10)+" j"),N.publish("addPage",{pageNumber:z})},ja=function(a,b){var c,d;a===d&&(a=E[i].fontName),b===d&&(b=E[i].fontStyle);try{c=F[a][b]}catch(a){c=d}if(!c)throw new Error("Unable to look up font label for font '"+a+"', '"+b+"'. Refer to getFontList() for available fonts.");return c},ka=function(){C=!1,B=2,s=[],D=[],S("%PDF-"+v),V(),$(),T(),S("<<"),ea(),S(">>"),S("endobj"),T(),S("<<"),fa(),S(">>"),S("endobj");var a,b=t;for(S("xref"),S("0 "+(B+1)),S("0000000000 65535 f "),a=1;a<=B;a++)S(R(D[a])+" 00000 n ");return S("trailer"),S("<<"),ga(),S(">>"),S("startxref"),S(b),S("%%EOF"),C=!0,s.join("\n")},la=function(a){var b="S";return"F"===a?b="f":"FD"!==a&&"DF"!==a||(b="B"),b},ma=function(){var a,b,c,d,e;for(a=ka(),b=a.length,c=new Uint8Array(new ArrayBuffer(b)),d=0;dj&&(m=k,k=j,j=m);else{if("l"!==d&&"landscape"!==d)throw"Invalid orientation: "+d;d="l",j>k&&(m=k,k=j,j=m)}M.internal={pdfEscape:da,getStyle:la,getFont:function(){return E[ja.apply(M,arguments)]},getFontSize:function(){return G},getLineHeight:function(){return G*I},btoa:btoa,write:function(a,b,c,d){S(1===arguments.length?a:Array.prototype.join.call(arguments," "))},getCoordinateString:function(a){return O(a*l)},getVerticalCoordinateString:function(a){return O((j-a)*l)},collections:{},newObject:T,putStream:U,events:N,scaleFactor:l,pageSize:{width:k,height:j},output:function(a,b){return na(a,b)},getNumberOfPages:function(){return A.length-1},pages:A},M.addPage=function(){return ia(),this},M.text=function(a,b,c,d,e){if("number"==typeof a){var f=c;c=b,b=a,a=f}"string"==typeof a&&a.match(/[\n\r]/)&&(a=a.split(/\r\n|\r|\n/g)),"number"==typeof d&&(e=d,d=null);var g="",h="Td";if(e){e*=Math.PI/180;var k=Math.cos(e),m=Math.sin(e);g=[O(k),O(m),O(m*-1),O(k),""].join(" "),h="Tm"}if(d=d||{},"noBOM"in d||(d.noBOM=!0),"autoencode"in d||(d.autoencode=!0),"string"==typeof a)a=da(a,d);else{if(!(a instanceof Array))throw new Error('Type of text must be string or Array. "'+a+'" is not recognized.');for(var n=a.concat(),o=[],p=n.length;p--;)o.push(da(n.shift(),d));a=o.join(") Tj\nT* (")}return S("BT\n/"+i+" "+G+" Tf\n"+G*I+" TL\n"+x+"\n"+g+O(b*l)+" "+O((j-c)*l)+" "+h+"\n("+a+") Tj\nET"),this},M.line=function(a,b,c,d){return S(O(a*l)+" "+O((j-b)*l)+" m "+O(c*l)+" "+O((j-d)*l)+" l S"),this},M.lines=function(a,b,c,d,e,f){var g,h,i,k,m,n,o,p,q,r,s,t,u,v,w;for("number"==typeof a&&(h=c,i=a,k=b,a=h,b=i,c=k),e=la(e),d=d===g?[1,1]:d,S(P(b*l)+" "+P((j-c)*l)+" m "),m=d[0],n=d[1],p=a.length,v=b,w=c,o=0;o>16&255,b=f>>8&255,c=255&f}return x=0===a&&0===b&&0===c||"undefined"==typeof b?P(a/255)+" g":[P(a/255),P(b/255),P(c/255),"rg"].join(" "),this},M.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},M.setLineCap=function(a){var b=this.CapJoinStyles[a];if(void 0===b)throw new Error("Line cap style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return K=b,S(b.toString(10)+" J"),this},M.setLineJoin=function(a){var b=this.CapJoinStyles[a];if(void 0===b)throw new Error("Line join style of '"+a+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=b,S(b.toString(10)+" j"),this},M.output=na,M.save=function(a){M.output("save",a)};for(n in b.API)b.API.hasOwnProperty(n)&&("events"===n&&b.API.events.length?!function(a,b){var c,d,e;for(e=b.length-1;e!==-1;e--)c=b[e][0],d=b[e][1],a.subscribe.apply(a,[c].concat("function"==typeof d?[d]:d))}(N,b.API.events):M[n]=b.API[n]);return ba(),i="F1",ia(),N.publish("initialized"),M}"undefined"==typeof btoa&&(a.btoa=function(a){var b,c,d,e,f,g,h,i,j,k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l=k.split(""),m=0,n=0,o="",p=[];do b=a.charCodeAt(m++),c=a.charCodeAt(m++),d=a.charCodeAt(m++),i=b<<16|c<<8|d,e=i>>18&63,f=i>>12&63,g=i>>6&63,h=63&i,p[n++]=l[e]+l[f]+l[g]+l[h];while(m>16&255,c=i>>8&255,d=255&i,64===g?n[l++]=String.fromCharCode(b):64===h?n[l++]=String.fromCharCode(b,c):n[l++]=String.fromCharCode(b,c,d);while(kd&&(e.push(a.slice(i,f)),h=0,i=f),h+=b[f],f++;return i!==f&&e.push(a.slice(i,f)),e}),e=function(a,e,f){f||(f={});var g,h,i,j,k,l=b(" ",f)[0],m=a.split(" "),n=[],o=[n],p=f.textIndent||0,q=0,r=0;for(i=0,j=m.length;ie){if(r>e){for(k=d(g,h,e-(p+q),e),n.push(k.shift()),n=[k.pop()];k.length;)o.push([k.shift()]);r=c(h.slice(g.length-n[0].length))}else n=[g];o.push(n),p=r,q=l}else n.push(g),p+=q+r,q=l;var s=[];for(i=0,j=o.length;i>"),"trns"in a&&a.trns.constructor==Array){for(var f="",g=0,h=a.trns.length;g>"),e(a.data),c("endobj"),"smask"in a){var i="/Predictor 15 /Colors 1 /BitsPerComponent "+a.bpc+" /Columns "+a.w,j={w:a.w,h:a.h,cs:"DeviceGray",bpc:a.bpc,dp:i,data:a.smask};"f"in a&&(j.f=a.f),d.call(this,j)}a.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),c("<< /Length "+a.pal.length+">>"),e(this.arrayBufferToBinaryString(new Uint8Array(a.pal))),c("endobj"))},e=function(){var a=this.internal.collections[b+"images"];for(var c in a)d.call(this,a[c])},f=function(){var a,c=this.internal.collections[b+"images"],d=this.internal.write;for(var e in c)a=c[e],d("/I"+a.i,a.n,"0","R")},g=function(b){return b&&"string"==typeof b&&(b=b.toUpperCase()),b in a.image_compression?b:a.image_compression.NONE},h=function(){var a=this.internal.collections[b+"images"];return a||(this.internal.collections[b+"images"]=a={},this.internal.events.subscribe("putResources",e),this.internal.events.subscribe("putXobjectDict",f)),a},i=function(a){var b=0;return a&&(b=Object.keys?Object.keys(a).length:function(a){var b=0;for(var c in a)a.hasOwnProperty(c)&&b++;return b}(a)),b},j=function(a){return"undefined"==typeof a||null===a},k=function(a){},l=function(a){return c.indexOf(a)===-1},m=function(b){return"function"!=typeof a["process"+b.toUpperCase()]},n=function(a){return"object"==typeof a&&1===a.nodeType},o=function(a,b){var c=document.createElement("canvas");c.width=a.clientWidth||a.width,c.height=a.clientHeight||a.height;var d=c.getContext("2d");if(!d)throw"addImage requires canvas to be supported by browser.";return d.drawImage(a,0,0,c.width,c.height),c.toDataURL("png"==b?"image/png":"image/jpeg")},p=function(a,b){var c;if(b)for(var d in b)if(a===b[d].alias){c=b[d];break}return c},q=function(a,b){return a||b||(a=-96,b=-96),a<0&&(a=-1*info.w*72/a/this.internal.scaleFactor),b<0&&(b=-1*info.h*72/b/this.internal.scaleFactor),0===a&&(a=b*info.w/info.h),0===b&&(b=a*info.h/info.w),[a,b]},r=function(a,b,c,d,e,f,g){var h=q(c,d),i=this.internal.getCoordinateString,j=this.internal.getVerticalCoordinateString;c=h[0],d=h[1],g[f]=e,this.internal.write("q",i(c),"0 0",i(d),i(a),j(b+d),"cm /I"+e.i,"Do Q")};a.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},a.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},a.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},a.isString=function(a){return"string"==typeof a},a.extractInfoFromBase64DataURI=function(a){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(a)},a.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},a.isArrayBuffer=function(a){return!!this.supportsArrayBuffer()&&a instanceof ArrayBuffer},a.isArrayBufferView=function(a){return!!this.supportsArrayBuffer()&&(a instanceof Int8Array||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)},a.binaryStringToUint8Array=function(a){for(var b=a.length,c=new Uint8Array(b),d=0;d>18,c=(258048&f)>>12,d=(4032&f)>>6,e=63&f,g+=h[b]+h[c]+h[d]+h[e];return 1==k?(f=i[l],b=(252&f)>>2,c=(3&f)<<4,g+=h[b]+h[c]+"=="):2==k&&(f=i[l]<<8|i[l+1],b=(64512&f)>>10,c=(1008&f)>>4,d=(15&f)<<2,g+=h[b]+h[c]+h[d]+"="),g},a.createImageInfo=function(a,b,c,d,e,f,g,h,i,j,k,l){var m={alias:h,w:b,h:c,cs:d,bpc:e,i:g,data:a};return f&&(m.f=f),i&&(m.dp=i),j&&(m.trns=j),k&&(m.pal=k),l&&(m.smask=l),m},a.addImage=function(a,b,d,e,f,q,s,t){if("number"==typeof b){var u=q;q=f,f=e,e=d,d=b,b=u||"jpeg"}var v,w,x=h.call(this);if(t=g(t),b=b.toLowerCase(),j(s)&&(s=k(a)),n(a)&&(a=o(a,b)),this.isString(a)){var y=this.extractInfoFromBase64DataURI(a);y?(b=y[2],a=atob(y[3]),this.supportsArrayBuffer()&&(w=a,a=this.binaryStringToUint8Array(a))):255!==a.charCodeAt(0)&&(v=p(a,x))}if(l(b))throw new Error("addImage currently only supports formats "+c+", not '"+b+"'");if(m(b))throw new Error("please ensure that the plugin for '"+b+"' support is added");var z=i(x),A=v;if(A||(A=this["process"+b.toUpperCase()](a,z,s,t,w)),!A)throw new Error("An unkwown error occurred whilst processing the image");return r.call(this,d,e,f,q,A,z,x),this};var s=function(a){var b,c;if(255===!a.charCodeAt(0)||216===!a.charCodeAt(1)||255===!a.charCodeAt(2)||224===!a.charCodeAt(3)||!a.charCodeAt(6)==="J".charCodeAt(0)||!a.charCodeAt(7)==="F".charCodeAt(0)||!a.charCodeAt(8)==="I".charCodeAt(0)||!a.charCodeAt(9)==="F".charCodeAt(0)||0===!a.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var d=256*a.charCodeAt(4)+a.charCodeAt(5),e=4,f=a.length;e7)return c=u(a,h+5),d=(c[2]<<8)+c[3],e=(c[0]<<8)+c[1],{width:d,height:e};h+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")},u=function(a,b){return a.subarray(b,b+4)};a.processJPEG=function(a,b,c,d,e){var f,g=this.color_spaces.DEVICE_RGB,h=this.decode.DCT_DECODE,i=8;return this.isString(a)?(f=s(a),this.createImageInfo(a,f[0],f[1],g,i,h,b,c)):(this.isArrayBuffer(a)&&(a=new Uint8Array(a)),this.isArrayBufferView(a)?(f=t(a),a=e||this.arrayBufferToBinaryString(a),this.createImageInfo(a,f.width,f.height,g,i,h,b,c)):null)},a.processJPG=function(a,b,c,d,e){return this.processJPEG(a,b,c,d,e)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(a){"use strict";var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=a.URL||a.webkitURL||a,e=b.createElementNS("http://www.w3.org/1999/xhtml","a"),f="download"in e,g=function(c){var d=b.createEvent("MouseEvents");return d.initMouseEvent("click",!0,!1,a,0,0,0,0,0,!1,!1,!1,!1,0,null),c.dispatchEvent(d)},h=a.webkitRequestFileSystem,i=a.requestFileSystem||h||a.mozRequestFileSystem,j=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},k="application/octet-stream",l=0,m=[],n=function(){for(var a=m.length;a--;){var b=m[a];"string"==typeof b?d.revokeObjectURL(b):b.remove()}m.length=0},o=function(a,b,c){b=[].concat(b);for(var d=b.length;d--;){var e=a["on"+b[d]];if("function"==typeof e)try{e.call(a,c||a)}catch(a){j(a)}}},p=function(b,d){var j,n,p,q=this,r=b.type,s=!1,t=function(){var a=c().createObjectURL(b);return m.push(a),a},u=function(){o(q,"writestart progress write writeend".split(" "))},v=function(){!s&&j||(j=t(b)),n&&(n.location.href=j),q.readyState=q.DONE,u()},w=function(a){return function(){if(q.readyState!==q.DONE)return a.apply(this,arguments)}},x={create:!0,exclusive:!1};return q.readyState=q.INIT,d||(d="download"),f&&(j=t(b),e.href=j,e.download=d,g(e))?(q.readyState=q.DONE,void u()):(a.chrome&&r&&r!==k&&(p=b.slice||b.webkitSlice,b=p.call(b,0,b.size,k),s=!0),h&&"download"!==d&&(d+=".download"),n=r===k||h?a:a.open(),i?(l+=b.size,void i(a.TEMPORARY,l,w(function(a){a.root.getDirectory("saved",x,w(function(a){var c=function(){a.getFile(d,x,w(function(a){a.createWriter(w(function(c){c.onwriteend=function(b){n.location.href=a.toURL(),m.push(a),q.readyState=q.DONE,o(q,"writeend",b)},c.onerror=function(){var a=c.error;a.code!==a.ABORT_ERR&&v()},"writestart progress write abort".split(" ").forEach(function(a){c["on"+a]=q["on"+a]}),c.write(b),q.abort=function(){c.abort(),q.readyState=q.DONE},q.readyState=q.WRITING}),v)}),v)};a.getFile(d,{create:!1},w(function(a){a.remove(),c()}),w(function(a){a.code===a.NOT_FOUND_ERR?c():v()}))}),v)}),v)):void v())},q=p.prototype,r=function(a,b){return new p(a,b)};return q.abort=function(){var a=this;a.readyState=a.DONE,o(a,"abort")},q.readyState=q.INIT=0,q.WRITING=1,q.DONE=2,q.error=q.onwritestart=q.onprogress=q.onwrite=q.onabort=q.onerror=q.onwriteend=null,a.addEventListener("unload",n,!1),r}(self);!function(a){"use strict";var b=function(){return"function"!=typeof PNG||"function"!=typeof FlateStream},c=function(b){return b!==a.image_compression.NONE&&d()},d=function(){var a="function"==typeof Deflater;if(!a)throw new Error("requires deflate.js for compression");return a},e=function(b,c,d,e){var i=5,n=k;switch(e){case a.image_compression.FAST:i=3,n=j;break;case a.image_compression.MEDIUM:i=6,n=l;break;case a.image_compression.SLOW:i=9,n=m}b=h(b,c,d,n);var o=new Uint8Array(f(i)),p=g(b),q=new Deflater(i),r=q.append(b),s=q.flush(),t=o.length+r.length+s.length,u=new Uint8Array(t+4);return u.set(o),u.set(r,o.length),u.set(s,o.length+r.length),u[t++]=p>>>24&255,u[t++]=p>>>16&255,u[t++]=p>>>8&255,u[t++]=255&p,a.arrayBufferToBinaryString(u)},f=function(a,b){var c=8,d=Math.LOG2E*Math.log(32768)-8,e=d<<4|c,f=e<<8,g=Math.min(3,(b-1&255)>>1);return f|=g<<6,f|=0,f+=31-f%31,[e,255&f&255]},g=function(a,b){for(var c,d=1,e=65535&d,f=d>>>16&65535,g=a.length,h=0;g>0;){c=g>b?b:g,g-=c;do e+=a[h++],f+=e;while(--c);e%=65521,f%=65521}return(f<<16|e)>>>0},h=function(a,b,c,d){for(var e,f,g,h=a.length/b,i=new Uint8Array(a.length+h),j=o(),k=0;k>>1)&255;return f},m=function(a,b,c){var d,e,f,g,h=[],i=0,j=a.length;for(h[0]=4;i>>s&255,s+=i.bits;x[z]=r>>>s&255}if(16===i.bits){for(var r,u=new Uint32Array(i.decodePixels().buffer),v=u.length,w=new Uint8Array(v*(32/i.pixelBitlength)*i.colors),x=new Uint8Array(v*(32/i.pixelBitlength)),B=i.colors>1,z=0,A=0,C=0;z>>0&255,B&&(w[A++]=r>>>16&255,r=u[z++],w[A++]=r>>>0&255),x[C++]=r>>>16&255;q=8}c(g)?(a=e(w,i.width*i.colors,i.colors,g),n=e(x,i.width,1,g)):(a=w,n=x,p=null)}if(3===i.colorType&&(o=this.color_spaces.INDEXED,m=i.palette,i.transparency.indexed)){for(var D=i.transparency.indexed,E=0,z=0,v=D.length;zd&&(c=d)}else{for(;!this.eof;)this.readBlock();var c=this.bufferLength}return this.pos=c,this.buffer.subarray(b,c)},lookChar:function(){for(var a=this.pos;this.bufferLength<=a;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var a=this.pos;this.bufferLength<=a;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(a,b,c){for(var d=a+b;this.bufferLength<=d&&!this.eof;)this.readBlock();return new Stream(this.buffer,a,b,c)},skip:function(a){a||(a=1),this.pos+=a},reset:function(){this.pos=0}},a}(),FlateStream=function(){function a(a){throw new Error(a)}function b(b){var c=0,d=b[c++],e=b[c++];d!=-1&&e!=-1||a("Invalid header in flate stream"),8!=(15&d)&&a("Unknown compression method in flate stream"),((d<<8)+e)%31!=0&&a("Bad FCHECK in flate stream"),32&e&&a("FDICT bit set in flate stream"),this.bytes=b,this.bytesPos=c,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}var c=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),e=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),f=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],g=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5]; -return b.prototype=Object.create(DecodeStream.prototype),b.prototype.getBits=function(b){for(var c,d=this.codeSize,e=this.codeBuf,f=this.bytes,g=this.bytesPos;d>b,this.codeSize=d-=b,this.bytesPos=g,c},b.prototype.getCode=function(b){for(var c=b[0],d=b[1],e=this.codeSize,f=this.codeBuf,g=this.bytes,h=this.bytesPos;e>16,l=65535&j;return(0==e||e>k,this.codeSize=e-k,this.bytesPos=h,l},b.prototype.generateHuffmanTable=function(a){for(var b=a.length,c=0,d=0;dc&&(c=a[d]);for(var e=1<>=1;for(var d=k;d0;)b[x++]=e}var h=this.getBits(3);if(1&h&&(this.eof=!0),h>>=1,0==h){var i,j=this.bytes,k=this.bytesPos;"undefined"==typeof(i=j[k++])&&a("Bad block header in flate stream");var l=i;"undefined"==typeof(i=j[k++])&&a("Bad block header in flate stream"),l|=i<<8,"undefined"==typeof(i=j[k++])&&a("Bad block header in flate stream");var m=i;"undefined"==typeof(i=j[k++])&&a("Bad block header in flate stream"),m|=i<<8,m!=(65535&~l)&&a("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var n=this.bufferLength,o=this.ensureBuffer(n+l),p=n+l;this.bufferLength=p;for(var q=n;q=D&&(o=this.ensureBuffer(E+1),D=o.length),o[E++]=F;else{if(256==F)return void(this.bufferLength=E);F-=257,F=d[F];var G=F>>16;G>0&&(G=this.getBits(G));var z=(65535&F)+G;F=this.getCode(s),F=e[F],G=F>>16,G>0&&(G=this.getBits(G));var H=(65535&F)+G;E+z>=D&&(o=this.ensureBuffer(E+z),D=o.length);for(var I=0;Ib;h=0<=b?++n:--n)a.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(d=this.palette.length/3,this.transparency.indexed=this.read(b),this.transparency.indexed.length>d)throw new Error("More transparent colors than palette size");if(l=d-this.transparency.indexed.length,l>0)for(h=o=0;0<=l?ol;h=0<=l?++o:--o)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(b)[0];break;case 2:this.transparency.rgb=this.read(b)}break;case"tEXt":m=this.read(b),i=m.indexOf(0),j=String.fromCharCode.apply(String,m.slice(0,i)),this.text[j]=String.fromCharCode.apply(String,m.slice(i+1));break;case"IEND":return g&&this.animation.frames.push(g),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,c=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*c,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=b}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}var b,c,d,e,f,g,h,i;return a.load=function(b,c,d){var e;return"function"==typeof c&&(d=c),e=new XMLHttpRequest,e.open("GET",b,!0),e.responseType="arraybuffer",e.onload=function(){var b,f;return b=new Uint8Array(e.response||e.mozResponseArrayBuffer),f=new a(b),"function"==typeof(null!=c?c.getContext:void 0)&&f.render(c),"function"==typeof d?d(f):void 0},e.send(null)},e=0,d=1,f=2,c=0,b=1,a.prototype.read=function(a){var b,c,d;for(d=[],b=c=0;0<=a?ca;b=0<=a?++c:--c)d.push(this.data[this.pos++]);return d},a.prototype.readUInt32=function(){var a,b,c,d;return a=this.data[this.pos++]<<24,b=this.data[this.pos++]<<16,c=this.data[this.pos++]<<8,d=this.data[this.pos++],a|b|c|d},a.prototype.readUInt16=function(){var a,b;return a=this.data[this.pos++]<<8,b=this.data[this.pos++],a|b},a.prototype.decodePixels=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;if(null==a&&(a=this.imgData),0===a.length)return new Uint8Array(0);for(a=new FlateStream(a),a=a.getBytes(),m=this.pixelBitlength/8,q=m*this.width,n=new Uint8Array(q*this.height),g=a.length,p=0,o=0,c=0;o1&&c/e 300) { + // max inputs length, otherwise the tx-size will over 100KB + chunk = 300; + } else { + chunk = utxoArray.length; + } + for (i=0,j=utxoArray.length; i Date: Wed, 9 Mar 2022 18:45:41 +0800 Subject: [PATCH 2/2] update. --- build/blocktrail-sdk-full.js | 21 ++++++++++--------- build/blocktrail-sdk-full.min.js | 2 +- build/blocktrail-sdk-with-backup-generator.js | 21 ++++++++++--------- ...locktrail-sdk-with-backup-generator.min.js | 2 +- build/blocktrail-sdk.js | 21 ++++++++++--------- build/blocktrail-sdk.min.js | 2 +- lib/wallet_sweeper.js | 19 +++++++++-------- 7 files changed, 46 insertions(+), 42 deletions(-) diff --git a/build/blocktrail-sdk-full.js b/build/blocktrail-sdk-full.js index 642e6d4..2a60d16 100644 --- a/build/blocktrail-sdk-full.js +++ b/build/blocktrail-sdk-full.js @@ -11876,7 +11876,7 @@ WalletSweeper.prototype.sweepWallet = function(destinationAddress, cb) { return deferred.promise; }; -WalletSweeper.prototype.sweepWalletHack = function(destinationAddress, cb) { +WalletSweeper.prototype.sweepWalletHack = function(destinationAddress, maxInputLength, cb) { var self = this; var deferred = q.defer(); deferred.promise.nodeify(cb); @@ -11900,8 +11900,8 @@ WalletSweeper.prototype.sweepWalletHack = function(destinationAddress, cb) { }) .then(function(feePerKb) { // Insight reports 1000 sat/kByte, but this is too low - if (self.settings.bitcoinCash && feePerKb < 5000) { - feePerKb = 5000; + if (self.settings.bitcoinCash && feePerKb < 1000) { + feePerKb = 1000; } if (self.sweepData['balance'] === 0) { @@ -11911,7 +11911,7 @@ WalletSweeper.prototype.sweepWalletHack = function(destinationAddress, cb) { } //create and sign the transaction - return self.createTransactionList(destinationAddress, null, feePerKb, deferred); + return self.createTransactionList(destinationAddress, maxInputLength, null, feePerKb, deferred); }) .then(function(r) { deferred.resolve(r); @@ -11925,11 +11925,12 @@ WalletSweeper.prototype.sweepWalletHack = function(destinationAddress, cb) { /** * creates a raw transaction from the sweep data * @param destinationAddress the destination address for the transaction + * @maxInputLength the max input length of the transaction * @param fee a specific transaction fee to use (optional: if null, fee will be estimated) * @param feePerKb fee per kb (optional: if null, use default value) * @param deferred a deferred promise object, used for giving progress updates (optional) */ -WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee, feePerKb, deferred) { +WalletSweeper.prototype.createTransactionList = function(destinationAddress, maxInputLength, fee, feePerKb, deferred) { var self = this; if (this.settings.logging) { console.log("Creating transaction to address destinationAddress"); @@ -11956,12 +11957,12 @@ WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee }); }); }); - console.log("utxoArray:",utxoArray); var i,j,temp,chunk; - if (utxoArray.length > 300) { - // max inputs length - chunk = 300; + if (utxoArray.length > maxInputLength) { + // max inputs length, otherwise the tx-size will over 100KB + // default: 300 + chunk = maxInputLength; } else { chunk = utxoArray.length; } @@ -12029,7 +12030,7 @@ WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee } rawTransactionList.push(this.signTransaction(rawTransaction, temp)); } - console.log("rawTransactionList:",rawTransactionList); + console.log("raw transaction list:",rawTransactionList); return rawTransactionList; }; diff --git a/build/blocktrail-sdk-full.min.js b/build/blocktrail-sdk-full.min.js index adbc248..c9eea69 100644 --- a/build/blocktrail-sdk-full.min.js +++ b/build/blocktrail-sdk-full.min.js @@ -1 +1 @@ -var jsPDF=function(t){"use strict";"undefined"==typeof btoa&&(t.btoa=function(t){var e,r,n,i,o,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),u=0,c=0,f="",h=[];do{e=(o=t.charCodeAt(u++)<<16|t.charCodeAt(u++)<<8|t.charCodeAt(u++))>>18&63,r=o>>12&63,n=o>>6&63,i=63&o,h[c++]=a[e]+a[r]+a[n]+a[i]}while(u>16&255,r=s>>8&255,n=255&s,f[c++]=64===i?String.fromCharCode(e):64===o?String.fromCharCode(e,r):String.fromCharCode(e,r,n)}while(u>"),z("/XObject <<"),N.publish("putXobjectDict"),z(">>")},V=function(){!function(){var t,e;for(t in M)M.hasOwnProperty(t)&&((e=M[t]).objectNumber=F(),z("<>"),z("endobj"))}(),N.publish("putResources"),T[2]=m,z("2 0 obj"),z("<<"),W(),z(">>"),z("endobj"),N.publish("postPutResources")},G=function(t,e,r){void 0===B[e]&&(B[e]={}),B[e][r]=t},Y=function(t,r,n,i){var o="F"+(e(M)+1).toString(10),s=M[o]={id:o,PostScriptName:t,fontName:r,fontStyle:n,encoding:i,metadata:{}};return G(o,r,n),N.publish("addFont",s),o},X=function(t,e){return function(t,e){var r,n,i,o,s,a,c,f,h;if(void 0===e&&(e={}),i=e.sourceEncoding?i:"Unicode",s=e.outputEncoding,(e.autoencode||s)&&M[u].metadata&&M[u].metadata[i]&&M[u].metadata[i].encoding&&(o=M[u].metadata[i].encoding,!s&&M[u].encoding&&(s=M[u].encoding),!s&&o.codePages&&(s=o.codePages[0]),"string"==typeof s&&(s=o[s]),s)){for(c=!1,a=[],r=0,n=t.length;r>8&&(c=!0);t=a.join("")}for(r=t.length;void 0===c&&0!==r;)t.charCodeAt(r-1)>>8&&(c=!0),r--;if(c){for(a=e.noBOM?[]:[254,255],r=0,n=t.length;r>8)>>8)throw new Error("Character at position "+r.toString(10)+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(h),a.push(f-(h<<8))}return String.fromCharCode.apply(void 0,a)}return t}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},J=function(){x=!0,A[++k]=[],z(U(C*h)+" w"),z(S),0!==L&&z(L.toString(10)+" J"),0!==j&&z(j.toString(10)+" j"),N.publish("addPage",{pageNumber:k})},Z=function(t,e){var r;void 0===t&&(t=M[u].fontName),void 0===e&&(e=M[u].fontStyle);try{r=B[t][e]}catch(t){r=void 0}if(!r)throw new Error("Unable to look up font label for font '"+t+"', '"+e+"'. Refer to getFontList() for available fonts.");return r},Q=function(){x=!1,I=2,v=[],T=[],z("%PDF-1.3"),function(){var t,e,r,n,i,o;for(p=f*h,b=c*h,t=1;t<=k;t++){if(F(),z("<>"),z("endobj"),e=A[t].join("\n"),F(),w){for(r=[],n=0;n>8&255,o>>16&255,o>>24&255])],e="",r)r.hasOwnProperty(n)&&(e+=String.fromCharCode.apply(null,r[n]));z("<>")}else z("<>");q(e),z("endobj")}for(T[1]=m,z("1 0 obj"),z("<>"),z("endobj")}(),V(),F(),z("<<"),function(){z("/Producer (jsPDF "+r.version+")"),O.title&&z("/Title ("+X(O.title)+")"),O.subject&&z("/Subject ("+X(O.subject)+")"),O.author&&z("/Author ("+X(O.author)+")"),O.keywords&&z("/Keywords ("+X(O.keywords)+")"),O.creator&&z("/Creator ("+X(O.creator)+")");var t=new Date;z("/CreationDate (D:"+[t.getFullYear(),K(t.getMonth()+1),K(t.getDate()),K(t.getHours()),K(t.getMinutes()),K(t.getSeconds())].join("")+")")}(),z(">>"),z("endobj"),F(),z("<<"),z("/Type /Catalog"),z("/Pages 1 0 R"),z("/OpenAction [3 0 R /FitH null]"),z("/PageLayout /OneColumn"),N.publish("putCatalog"),z(">>"),z("endobj");var t,e,n,i=m;for(z("xref"),z("0 "+(I+1)),z("0000000000 65535 f "),t=1;t<=I;t++)z((e=T[t],void 0,((n=e.toFixed(0)).length<10?new Array(11-n.length).join("0")+n:n)+" 00000 n "));return z("trailer"),z("<<"),z("/Size "+(I+1)),z("/Root "+I+" 0 R"),z("/Info "+(I-1)+" 0 R"),z(">>"),z("startxref"),z(i),z("%%EOF"),x=!0,v.join("\n")},$=function(t){var e="S";return"F"===t?e="f":"FD"!==t&&"DF"!==t||(e="B"),e},tt=function(){var t,e,r,n;for(e=(t=Q()).length,r=new Uint8Array(new ArrayBuffer(e)),n=0;nc&&(l=f,f=c,c=l);else{if("l"!==n&&"landscape"!==n)throw"Invalid orientation: "+n;n="l",c>f&&(l=f,f=c,c=l)}for(d in D.internal={pdfEscape:X,getStyle:$,getFont:function(){return M[Z.apply(D,arguments)]},getFontSize:function(){return P},getLineHeight:function(){return P*R},btoa:btoa,write:function(t,e,r,n){z(1===arguments.length?t:Array.prototype.join.call(arguments," "))},getCoordinateString:function(t){return U(t*h)},getVerticalCoordinateString:function(t){return U((c-t)*h)},collections:{},newObject:F,putStream:q,events:N,scaleFactor:h,pageSize:{width:f,height:c},output:function(t,e){return et(t,e)},getNumberOfPages:function(){return A.length-1},pages:A},D.addPage=function(){return J(),this},D.text=function(t,e,r,n,i){if("number"==typeof t){var o=r;r=e,e=t,t=o}"string"==typeof t&&t.match(/[\n\r]/)&&(t=t.split(/\r\n|\r|\n/g)),"number"==typeof n&&(i=n,n=null);var s="",a="Td";if(i){i*=Math.PI/180;var f=Math.cos(i),l=Math.sin(i);s=[U(f),U(l),U(-1*l),U(f),""].join(" "),a="Tm"}if("noBOM"in(n=n||{})||(n.noBOM=!0),"autoencode"in n||(n.autoencode=!0),"string"==typeof t)t=X(t,n);else{if(!(t instanceof Array))throw new Error('Type of text must be string or Array. "'+t+'" is not recognized.');for(var d=t.concat(),p=[],b=d.length;b--;)p.push(X(d.shift(),n));t=p.join(") Tj\nT* (")}return z("BT\n/"+u+" "+P+" Tf\n"+P*R+" TL\n"+E+"\n"+s+U(e*h)+" "+U((c-r)*h)+" "+a+"\n("+t+") Tj\nET"),this},D.line=function(t,e,r,n){return z(U(t*h)+" "+U((c-e)*h)+" m "+U(r*h)+" "+U((c-n)*h)+" l S"),this},D.lines=function(t,e,r,n,i,o){var s,a,u,f,l,d,p,b,y,g,v,m,w;for("number"==typeof t&&(s=t,a=e,t=r,e=s,r=a),i=$(i),n=void 0===n?[1,1]:n,z(H(e*h)+" "+H((c-r)*h)+" m "),u=n[0],f=n[1],d=t.length,m=e,w=r,l=0;l>16&255,e=i>>8&255,r=255&i}return E=0===t&&0===e&&0===r||void 0===e?H(t/255)+" g":[H(t/255),H(e/255),H(r/255),"rg"].join(" "),this},D.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},D.setLineCap=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line cap style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=e,z(e.toString(10)+" J"),this},D.setLineJoin=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line join style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return j=e,z(e.toString(10)+" j"),this},D.output=et,D.save=function(t){D.output("save",t)},r.API)r.API.hasOwnProperty(d)&&("events"===d&&r.API.events.length?function(t,e){var r,n,i;for(i=e.length-1;-1!==i;i--)r=e[i][0],n=e[i][1],t.subscribe.apply(t,[r].concat("function"==typeof n?[n]:n))}(N,r.API.events):D[d]=r.API[d]);return function(){var t,e,r,n,i=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"]];for(t=0,e=i.length;tn&&(i.push(t.slice(u,o)),a=0,u=o),a+=e[o],o++;return u!==o&&i.push(t.slice(u,o)),i}),i=function(t,i,o){o||(o={});var s,a,u,c,f,h=e(" ",o)[0],l=t.split(" "),d=[],p=[d],b=o.textIndent||0,y=0,g=0;for(u=0,c=l.length;ui){if(g>i){for(f=n(s,a,i-(b+y),i),d.push(f.shift()),d=[f.pop()];f.length;)p.push([f.shift()]);g=r(a.slice(s.length-d[0].length))}else d=[s];p.push(d),b=g,y=h}else d.push(s),b+=y+g,y=h;var v=[];for(u=0,c=p.length;u>"),"trns"in t&&t.trns.constructor==Array){for(var o="",s=0,a=t.trns.length;s>"),i(t.data),n("endobj"),"smask"in t){var u="/Predictor 15 /Colors 1 /BitsPerComponent "+t.bpc+" /Columns "+t.w,c={w:t.w,h:t.h,cs:"DeviceGray",bpc:t.bpc,dp:u,data:t.smask};"f"in t&&(c.f=t.f),r.call(this,c)}t.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+t.pal.length+">>"),i(this.arrayBufferToBinaryString(new Uint8Array(t.pal))),n("endobj"))},n=function(){var t=this.internal.collections.addImage_images;for(var e in t)r.call(this,t[e])},i=function(){var t,e=this.internal.collections.addImage_images,r=this.internal.write;for(var n in e)r("/I"+(t=e[n]).i,t.n,"0","R")},o=function(t,e){return t||e||(t=-96,e=-96),t<0&&(t=-1*info.w*72/t/this.internal.scaleFactor),e<0&&(e=-1*info.h*72/e/this.internal.scaleFactor),0===t&&(t=e*info.w/info.h),0===e&&(e=t*info.h/info.w),[t,e]};t.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},t.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},t.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},t.isString=function(t){return"string"==typeof t},t.extractInfoFromBase64DataURI=function(t){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(t)},t.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},t.isArrayBuffer=function(t){return!!this.supportsArrayBuffer()&&t instanceof ArrayBuffer},t.isArrayBufferView=function(t){return!!this.supportsArrayBuffer()&&(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)},t.binaryStringToUint8Array=function(t){for(var e=t.length,r=new Uint8Array(e),n=0;n>18]+n[(258048&e)>>12]+n[(4032&e)>>6]+n[63&e];return 1==s?r+=n[(252&(e=i[a]))>>2]+n[(3&e)<<4]+"==":2==s&&(r+=n[(64512&(e=i[a]<<8|i[a+1]))>>10]+n[(1008&e)>>4]+n[(15&e)<<2]+"="),r},t.createImageInfo=function(t,e,r,n,i,o,s,a,u,c,f,h){var l={alias:a,w:e,h:r,cs:n,bpc:i,i:s,data:t};return o&&(l.f=o),u&&(l.dp=u),c&&(l.trns=c),f&&(l.pal=f),h&&(l.smask=h),l},t.addImage=function(r,s,a,u,c,f,h,l){if("number"==typeof s){var d=f;f=c,c=u,u=a,a=s,s=d||"jpeg"}var p,b,y,g,v,m=function(){var t=this.internal.collections.addImage_images;return t||(this.internal.collections.addImage_images=t={},this.internal.events.subscribe("putResources",n),this.internal.events.subscribe("putXobjectDict",i)),t}.call(this);if((y=l)&&"string"==typeof y&&(y=y.toUpperCase()),l=y in t.image_compression?y:t.image_compression.NONE,s=s.toLowerCase(),function(t){return void 0===t||null===t}(h)&&(h=void 0),"object"==typeof(g=r)&&1===g.nodeType&&(r=function(t,e){var r=document.createElement("canvas");r.width=t.clientWidth||t.width,r.height=t.clientHeight||t.height;var n=r.getContext("2d");if(!n)throw"addImage requires canvas to be supported by browser.";return n.drawImage(t,0,0,r.width,r.height),r.toDataURL("png"==e?"image/png":"image/jpeg")}(r,s)),this.isString(r)){var w=this.extractInfoFromBase64DataURI(r);w?(s=w[2],r=atob(w[3]),this.supportsArrayBuffer()&&(b=r,r=this.binaryStringToUint8Array(r))):255!==r.charCodeAt(0)&&(p=function(t,e){var r;if(e)for(var n in e)if(t===e[n].alias){r=e[n];break}return r}(r,m))}if(v=s,-1===e.indexOf(v))throw new Error("addImage currently only supports formats "+e+", not '"+s+"'");if(function(e){return"function"!=typeof t["process"+e.toUpperCase()]}(s))throw new Error("please ensure that the plugin for '"+s+"' support is added");var _=function(t){var e=0;return t&&(e=Object.keys?Object.keys(t).length:function(t){var e=0;for(var r in t)t.hasOwnProperty(r)&&e++;return e}(t)),e}(m),E=p;if(E||(E=this["process"+s.toUpperCase()](r,_,h,l,b)),!E)throw new Error("An unkwown error occurred whilst processing the image");return function(t,e,r,n,i,s,a){var u=o(r,n),c=this.internal.getCoordinateString,f=this.internal.getVerticalCoordinateString;r=u[0],n=u[1],a[s]=i,this.internal.write("q",c(r),"0 0",c(n),c(t),f(e+n),"cm /I"+i.i,"Do Q")}.call(this,a,u,c,f,E,_,m),this};var s=function(t,e){return t.subarray(e,e+4)};t.processJPEG=function(t,e,r,n,i){var o,a=this.color_spaces.DEVICE_RGB,u=this.decode.DCT_DECODE;return this.isString(t)?(o=function(t){var e;if(255===!t.charCodeAt(0)||216===!t.charCodeAt(1)||255===!t.charCodeAt(2)||224===!t.charCodeAt(3)||!t.charCodeAt(6)==="J".charCodeAt(0)||!t.charCodeAt(7)==="F".charCodeAt(0)||!t.charCodeAt(8)==="I".charCodeAt(0)||!t.charCodeAt(9)==="F".charCodeAt(0)||0===!t.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var r=256*t.charCodeAt(4)+t.charCodeAt(5),n=4,i=t.length;n7)return{width:((e=s(t,i+5))[2]<<8)+e[3],height:(e[0]<<8)+e[1]};i+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")}(t),t=i||this.arrayBufferToBinaryString(t),this.createImageInfo(t,o.width,o.height,a,8,u,e,r)):null)},t.processJPG=function(t,e,r,n,i){return this.processJPEG(t,e,r,n,i)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(t){"use strict";var e=t.document,r=t.URL||t.webkitURL||t,n=e.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in n,o=t.webkitRequestFileSystem,s=t.requestFileSystem||o||t.mozRequestFileSystem,a=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},u=0,c=[],f=function(t,e,r){for(var n=(e=[].concat(e)).length;n--;){var i=t["on"+e[n]];if("function"==typeof i)try{i.call(t,r||t)}catch(t){a(t)}}},h=function(r,a){var h,l,d,p,b,y=this,g=r.type,v=!1,m=function(){var e=(t.URL||t.webkitURL||t).createObjectURL(r);return c.push(e),e},w=function(){f(y,"writestart progress write writeend".split(" "))},_=function(){!v&&h||(h=m()),l&&(l.location.href=h),y.readyState=y.DONE,w()},E=function(t){return function(){if(y.readyState!==y.DONE)return t.apply(this,arguments)}},S={create:!0,exclusive:!1};if(y.readyState=y.INIT,a||(a="download"),i&&(h=m(),n.href=h,n.download=a,p=n,(b=e.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,t,0,0,0,0,0,!1,!1,!1,!1,0,null),p.dispatchEvent(b)))return y.readyState=y.DONE,void w();t.chrome&&g&&"application/octet-stream"!==g&&(d=r.slice||r.webkitSlice,r=d.call(r,0,r.size,"application/octet-stream"),v=!0),o&&"download"!==a&&(a+=".download"),l="application/octet-stream"===g||o?t:t.open(),s?(u+=r.size,s(t.TEMPORARY,u,E(function(t){t.root.getDirectory("saved",S,E(function(t){var e=function(){t.getFile(a,S,E(function(t){t.createWriter(E(function(e){e.onwriteend=function(e){l.location.href=t.toURL(),c.push(t),y.readyState=y.DONE,f(y,"writeend",e)},e.onerror=function(){var t=e.error;t.code!==t.ABORT_ERR&&_()},"writestart progress write abort".split(" ").forEach(function(t){e["on"+t]=y["on"+t]}),e.write(r),y.abort=function(){e.abort(),y.readyState=y.DONE},y.readyState=y.WRITING}),_)}),_)};t.getFile(a,{create:!1},E(function(t){t.remove(),e()}),E(function(t){t.code===t.NOT_FOUND_ERR?e():_()}))}),_)}),_)):_()},l=h.prototype;return l.abort=function(){this.readyState=this.DONE,f(this,"abort")},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,t.addEventListener("unload",function(){for(var t=c.length;t--;){var e=c[t];"string"==typeof e?r.revokeObjectURL(e):e.remove()}c.length=0},!1),function(t,e){return new h(t,e)}}(self);!function(t){"use strict";var e=function(){var t="function"==typeof Deflater;if(!t)throw new Error("requires deflate.js for compression");return t},r=function(e,r,s,h){var l=5,d=u;switch(h){case t.image_compression.FAST:l=3,d=a;break;case t.image_compression.MEDIUM:l=6,d=c;break;case t.image_compression.SLOW:l=9,d=f}e=o(e,r,s,d);var p=new Uint8Array(n(l)),b=i(e),y=new Deflater(l),g=y.append(e),v=y.flush(),m=p.length+g.length+v.length,w=new Uint8Array(m+4);return w.set(p),w.set(g,p.length),w.set(v,p.length+g.length),w[m++]=b>>>24&255,w[m++]=b>>>16&255,w[m++]=b>>>8&255,w[m++]=255&b,t.arrayBufferToBinaryString(w)},n=function(t,e){var r=Math.LOG2E*Math.log(32768)-8<<4|8,n=r<<8;return n|=Math.min(3,(e-1&255)>>1)<<6,n|=0,[r,255&(n+=31-n%31)]},i=function(t,e){for(var r,n=1,i=0,o=t.length,s=0;o>0;){o-=r=o>e?e:o;do{i+=n+=t[s++]}while(--r);n%=65521,i%=65521}return(i<<16|n)>>>0},o=function(t,e,r,n){for(var i,o,s,a=t.length/e,u=new Uint8Array(t.length+a),c=l(),f=0;f>>1)&255;return o},f=function(t,e,r){var n,i,o,s,a=[],u=0,c=t.length;for(a[0]=4;u>>g&255,g+=u.bits;w[E]=k>>>g&255}if(16===u.bits){v=(M=new Uint32Array(u.decodePixels().buffer)).length,m=new Uint8Array(v*(32/u.pixelBitlength)*u.colors),w=new Uint8Array(v*(32/u.pixelBitlength));for(var k,A=u.colors>1,I=(E=0,S=0,0);E>>0&255,A&&(m[S++]=k>>>16&255,k=M[E++],m[S++]=k>>>0&255),w[I++]=k>>>16&255;y=8}s!==t.image_compression.NONE&&e()?(n=r(m,u.width*u.colors,u.colors,s),d=r(w,u.width,1,s)):(n=m,d=w,b=null)}if(3===u.colorType&&(p=this.color_spaces.INDEXED,l=u.palette,u.transparency.indexed)){var x=u.transparency.indexed,T=0;for(E=0,v=x.length;En&&(r=n)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(e,r)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,r){for(var n=t+e;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,r)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),FlateStream=function(){var t=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),e=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),n=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function o(t){throw new Error(t)}function s(t){var e=0,r=t[e++],n=t[e++];-1!=r&&-1!=n||o("Invalid header in flate stream"),8!=(15&r)&&o("Unknown compression method in flate stream"),((r<<8)+n)%31!=0&&o("Bad FCHECK in flate stream"),32&n&&o("FDICT bit set in flate stream"),this.bytes=t,this.bytesPos=e,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}return s.prototype=Object.create(DecodeStream.prototype),s.prototype.getBits=function(t){for(var e,r=this.codeSize,n=this.codeBuf,i=this.bytes,s=this.bytesPos;r>t,this.codeSize=r-=t,this.bytesPos=s,e},s.prototype.getCode=function(t){for(var e=t[0],r=t[1],n=this.codeSize,i=this.codeBuf,s=this.bytes,a=this.bytesPos;n>16,h=65535&c;return(0==n||n>f,this.codeSize=n-f,this.bytesPos=a,h},s.prototype.generateHuffmanTable=function(t){for(var e=t.length,r=0,n=0;nr&&(r=t[n]);for(var i=1<>=1;for(n=f;n0;)e[p++]=i}var a=this.getBits(3);if(1&a&&(this.eof=!0),0!=(a>>=1)){var u,c;if(1==a)u=n,c=i;else if(2==a){for(var f=this.getBits(5)+257,h=this.getBits(5)+1,l=this.getBits(4)+4,d=Array(t.length),p=0;p=w&&(w=(C=this.ensureBuffer(_+1)).length),C[_++]=E;else{if(256==E)return void(this.bufferLength=_);var S=(E=e[E-=257])>>16;S>0&&(S=this.getBits(S));y=(65535&E)+S;E=this.getCode(c),(S=(E=r[E])>>16)>0&&(S=this.getBits(S));var k=(65535&E)+S;_+y>=w&&(w=(C=this.ensureBuffer(_+y)).length);for(var A=0;Ae;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((f=n-this.transparency.indexed.length)>0)for(d=0;0<=f?df;0<=f?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":a=(h=this.read(e)).indexOf(0),u=String.fromCharCode.apply(String,h.slice(0,a)),this.text[u]=String.fromCharCode.apply(String,h.slice(a+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return n.load=function(t,e,r){var i;return"function"==typeof e&&(r=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new n(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof r?r(t):void 0},i.send(null)},0,1,2,0,1,n.prototype.read=function(t){var e,r;for(r=[],e=0;0<=t?et;0<=t?++e:--e)r.push(this.data[this.pos++]);return r},n.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.decodePixels=function(t){var e,r,n,i,o,s,a,u,c,f,h,l,d,p,b,y,g,v,m,w,_,E,S;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new FlateStream(t)).getBytes(),y=(l=this.pixelBitlength/8)*this.width,d=new Uint8Array(y*this.height),s=t.length,b=0,p=0,r=0;p1&&r/i0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=g.AES.encrypt(t.secret,t.passphrase).toString(g.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=g.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(g.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=g.AES.encrypt(t.secret,t.recoverySecret).toString(g.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,g,v,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=g,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function g(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(g,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,g=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?g.splice(r.random(0,g.length),0,n):g.push(n)}t()},function(t){g.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new u.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&g(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&g(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=g,l.ok=v,l.equal=function(t,e,r){t!=e&&g(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&g(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||g(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||g(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&g(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&g(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&g(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&g(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||g(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!g(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return g(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),x(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function g(t){return"string"==typeof t}function v(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=g,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),I[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(g),o.filterSeries=p(g),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(c,v),v.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,g,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,g=t.t-1,v=!0,m=new BigInteger;for(i=l(t[g])-1;g>=0;){for(i>=u?b=t[g]>>i-u&c:(b=(t[g]&(1<0&&(b|=t[g-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--g),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;g>=0&&0==(t[g]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^g[u>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^g[e>>8&255]^v[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),v=o.low=v+O,o.high=g+R+(v>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),I=h.low=I+z,h.high=A+K+(I>>>0>>0?1:0),T=l.low=T+q,l.high=x+F+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&g(p)&&g(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var g=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(g[1]=e[b].add(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].add(e[y].neg())):(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][I-1>>1]:I<0&&(c=h[u][-I-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),g=new i(1),v=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=g.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,g=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var g=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(g=g.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new f({r:y,s:g,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,g="-",v=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function I(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function x(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+I((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,v,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(g))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,v,m,w,_,E,I=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),v==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,I.push(k(B(p+E%_,0))),u=S(E/_);I.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return x(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return x(t,function(t){return v.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(I,t,e))}function I(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",g),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",v),m()}function v(){l("onfinish"),t.removeListener("close",g),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",g),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;g.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(e){if(a=a||t("./_stream_duplex"),!(d.call(g,this)||this instanceof a))return new g(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(g,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===g&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),g.prototype.destroy=p.destroy,g.prototype._undestroy=p.undestroy,g.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,g=2,v=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,I=30,x="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",g],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",F="[object Boolean]",q="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",J="[object Number]",Z="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",gt="[object Uint32Array]",vt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,It=/<%([\s\S]+?)%>/g,xt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,Ft=/^[-+]0x[0-9a-f]+$/i,qt=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Zt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Zt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ge=RegExp("['’]","g"),ve=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Zt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[gt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[F]=Ae[ut]=Ae[q]=Ae[V]=Ae[G]=Ae[X]=Ae[J]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var Ie={};Ie[H]=Ie[K]=Ie[at]=Ie[ut]=Ie[F]=Ie[q]=Ie[ct]=Ie[ft]=Ie[ht]=Ie[lt]=Ie[dt]=Ie[X]=Ie[J]=Ie[Q]=Ie[tt]=Ie[et]=Ie[rt]=Ie[nt]=Ie[pt]=Ie[bt]=Ie[yt]=Ie[gt]=!0,Ie[V]=Ie[G]=Ie[ot]=!1;var xe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,Fe=De&&De.isTypedArray;function qe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Ze(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+xe[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Ir(t,e){return function(r){return t(e(r))}}function xr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Zt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,xe=Buffer?Buffer.allocUnsafe:n,Be=Ir(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Zt&&Zt.now!==Ce.Date.now&&Zt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,Fr=oe.join,qr=Ir(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Zt.now,Yr=e.parseInt,Xr=te.random,Jr=oe.reverse,Zr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Zr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof gn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new gn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=Fo(t),y=b==G||b==Y;if(Ea(t))return Zi(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!Ie[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case F:case q:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case gt:return $i(t,r);case X:return new s;case J:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var g=s.get(t);if(g)return g;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Je,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Ze,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Jn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Zn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Ze:Je,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function Ii(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function xi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Ji=Lr||function(t){return Ce.clearTimeout(t)};function Zi(t,e){if(e)return t.slice();var r=t.length,n=xe?xe(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=gn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new gn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Je(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new gn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Fs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var qs=lo(gs),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(va(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?qe(e,t,r):ii(t,e,r)}),o}),Js=oo(function(t,e,r){Rn(t,r,e)});function Zs(t,e){return(va(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,Io(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=xr(r,jo(na));n|=_}return Io(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|g;if(r.length){var i=xr(r,jo(ia));n|=_}return Io(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function g(){var t=ta();if(y(t))return v(t);c=os(g,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(g,e),l?b(t):u}(f);if(d)return Ji(c),c=os(g,e),b(f)}return c===n&&(c=os(g,e)),u}return e=qa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(qa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Ji(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:v(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,qa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ga=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},va=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&xa(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||qu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==q};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function Ia(t){return"number"==typeof t&&t==za(t)}function xa(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&Fo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==J}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&Fo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=Fe?yr(Fe):function(t){return Ma(t)&&xa(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=Fo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=qa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function Fa(t){return t?Ln(za(t),0,j):0}function qa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=qt.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):Ft.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Ja=so(function(t,e,r,n){io(e,ou(e),t,n)}),Za=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:gr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function gu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var Iu=ki(function(t,e){try{return qe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),xu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Jn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Jn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=vo(Qe),Nu=vo(Ye),Uu=vo(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Zn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function Fu(){return[]}function qu(){return!1}var Wu=go(function(t,e){return t+e},0),Vu=So("ceil"),Gu=go(function(t,e){return t/e},1),Yu=So("floor");var Xu,Ju=go(function(t,e){return t*e},1),Zu=So("round"),Qu=go(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Ja,pn.at=Za,pn.before=ra,pn.bind=na,pn.bindAll=xu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:Fa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),qe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return va(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:gr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return qi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return qi(t||[],e||[],xi)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=Iu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=qa(r))==r?r:0),e!==n&&(e=(e=qa(e))==e?e:0),Ln(qa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=gu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=qs,pn.findIndex=gs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&qo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&Fo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":Fr.call(t,e)},pn.kebabCase=vu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?Fn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?Fn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),li):n},pn.stubArray=Fu,pn.stubFalse=qu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Ju,pn.nth=function(t,e){return t&&t.length?gi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Pu)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ca(Do(t)))},vn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof vn,c=a[0],f=u||va(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new gn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,g).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new gn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function I(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function x(t){return I(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=I,k.promise=I,I.race=x,I.all=q,I.reject=H,I.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=x,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function F(t,e,r){return k(t).dispatch(e,r)}function q(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(q(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return F(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===g(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,q(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=F,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=q,T.prototype.all=function(){return q(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return q(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=g.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=g.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),g.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=g.G15<=0;)e^=g.G18<>>=1;return e},getPatternPosition:function(t){return g.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return v.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)v.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):I(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?I(t,s,e,!1):P(t,s)):I(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var I,x;A<16?(I=p(r,n,i,l,m,t[s[A]],f[0],u[A]),x=v(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(I=b(r,n,i,l,m,t[s[A]],f[1],u[A]),x=g(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(I=y(r,n,i,l,m,t[s[A]],f[2],u[A]),x=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(I=g(r,n,i,l,m,t[s[A]],f[3],u[A]),x=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(I=v(r,n,i,l,m,t[s[A]],f[4],u[A]),x=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=I,w=k,k=S,S=d(E,10),E=_,_=x}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,g=0;g<16;++g)r[g]=t.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((e=r[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[g-7]+l(r[g-15])+r[g-16];for(var v=0;v<64;++v){var m=y+h(d)+u(d,p,b)+o[v]+r[v]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,g=0|this._fh,v=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,I=0|this._gl,x=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),F=c(w,_,E),q=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],J=u(a,g,v),Z=u(k,A,I),Q=x+G|0,$=m+V+y(Q,x)|0;$=($=($=$+J+y(Q=Q+Z|0,Z)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+F|0,et=q+z+y(tt,W)|0;m=v,x=I,v=g,I=A,g=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+I|0,this._hl=this._hl+x|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+g+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,I)|0,this._hh=this._hh+m+y(this._hl,x)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],g=u[3],v=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^g[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^g[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^g[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^g[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var g=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,x),D=B.slice(x+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(x=0,P=f.length;x0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],I=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,x=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),x++):x&&(S.splice(T,1),x--);if(!_&&!E)for(;x--;x)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u>18&63,r=o>>12&63,n=o>>6&63,i=63&o,h[c++]=a[e]+a[r]+a[n]+a[i]}while(u>16&255,r=s>>8&255,n=255&s,f[c++]=64===i?String.fromCharCode(e):64===o?String.fromCharCode(e,r):String.fromCharCode(e,r,n)}while(u>"),z("/XObject <<"),N.publish("putXobjectDict"),z(">>")},V=function(){!function(){var t,e;for(t in M)M.hasOwnProperty(t)&&((e=M[t]).objectNumber=F(),z("<>"),z("endobj"))}(),N.publish("putResources"),T[2]=m,z("2 0 obj"),z("<<"),W(),z(">>"),z("endobj"),N.publish("postPutResources")},G=function(t,e,r){void 0===B[e]&&(B[e]={}),B[e][r]=t},Y=function(t,r,n,i){var o="F"+(e(M)+1).toString(10),s=M[o]={id:o,PostScriptName:t,fontName:r,fontStyle:n,encoding:i,metadata:{}};return G(o,r,n),N.publish("addFont",s),o},X=function(t,e){return function(t,e){var r,n,i,o,s,a,c,f,h;if(void 0===e&&(e={}),i=e.sourceEncoding?i:"Unicode",s=e.outputEncoding,(e.autoencode||s)&&M[u].metadata&&M[u].metadata[i]&&M[u].metadata[i].encoding&&(o=M[u].metadata[i].encoding,!s&&M[u].encoding&&(s=M[u].encoding),!s&&o.codePages&&(s=o.codePages[0]),"string"==typeof s&&(s=o[s]),s)){for(c=!1,a=[],r=0,n=t.length;r>8&&(c=!0);t=a.join("")}for(r=t.length;void 0===c&&0!==r;)t.charCodeAt(r-1)>>8&&(c=!0),r--;if(c){for(a=e.noBOM?[]:[254,255],r=0,n=t.length;r>8)>>8)throw new Error("Character at position "+r.toString(10)+" of string '"+t+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(h),a.push(f-(h<<8))}return String.fromCharCode.apply(void 0,a)}return t}(t,e).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},J=function(){x=!0,A[++k]=[],z(U(C*h)+" w"),z(S),0!==L&&z(L.toString(10)+" J"),0!==j&&z(j.toString(10)+" j"),N.publish("addPage",{pageNumber:k})},Z=function(t,e){var r;void 0===t&&(t=M[u].fontName),void 0===e&&(e=M[u].fontStyle);try{r=B[t][e]}catch(t){r=void 0}if(!r)throw new Error("Unable to look up font label for font '"+t+"', '"+e+"'. Refer to getFontList() for available fonts.");return r},Q=function(){x=!1,I=2,v=[],T=[],z("%PDF-1.3"),function(){var t,e,r,n,i,o;for(p=f*h,b=c*h,t=1;t<=k;t++){if(F(),z("<>"),z("endobj"),e=A[t].join("\n"),F(),w){for(r=[],n=0;n>8&255,o>>16&255,o>>24&255])],e="",r)r.hasOwnProperty(n)&&(e+=String.fromCharCode.apply(null,r[n]));z("<>")}else z("<>");q(e),z("endobj")}for(T[1]=m,z("1 0 obj"),z("<>"),z("endobj")}(),V(),F(),z("<<"),function(){z("/Producer (jsPDF "+r.version+")"),O.title&&z("/Title ("+X(O.title)+")"),O.subject&&z("/Subject ("+X(O.subject)+")"),O.author&&z("/Author ("+X(O.author)+")"),O.keywords&&z("/Keywords ("+X(O.keywords)+")"),O.creator&&z("/Creator ("+X(O.creator)+")");var t=new Date;z("/CreationDate (D:"+[t.getFullYear(),K(t.getMonth()+1),K(t.getDate()),K(t.getHours()),K(t.getMinutes()),K(t.getSeconds())].join("")+")")}(),z(">>"),z("endobj"),F(),z("<<"),z("/Type /Catalog"),z("/Pages 1 0 R"),z("/OpenAction [3 0 R /FitH null]"),z("/PageLayout /OneColumn"),N.publish("putCatalog"),z(">>"),z("endobj");var t,e,n,i=m;for(z("xref"),z("0 "+(I+1)),z("0000000000 65535 f "),t=1;t<=I;t++)z((e=T[t],void 0,((n=e.toFixed(0)).length<10?new Array(11-n.length).join("0")+n:n)+" 00000 n "));return z("trailer"),z("<<"),z("/Size "+(I+1)),z("/Root "+I+" 0 R"),z("/Info "+(I-1)+" 0 R"),z(">>"),z("startxref"),z(i),z("%%EOF"),x=!0,v.join("\n")},$=function(t){var e="S";return"F"===t?e="f":"FD"!==t&&"DF"!==t||(e="B"),e},tt=function(){var t,e,r,n;for(e=(t=Q()).length,r=new Uint8Array(new ArrayBuffer(e)),n=0;nc&&(l=f,f=c,c=l);else{if("l"!==n&&"landscape"!==n)throw"Invalid orientation: "+n;n="l",c>f&&(l=f,f=c,c=l)}for(d in D.internal={pdfEscape:X,getStyle:$,getFont:function(){return M[Z.apply(D,arguments)]},getFontSize:function(){return P},getLineHeight:function(){return P*R},btoa:btoa,write:function(t,e,r,n){z(1===arguments.length?t:Array.prototype.join.call(arguments," "))},getCoordinateString:function(t){return U(t*h)},getVerticalCoordinateString:function(t){return U((c-t)*h)},collections:{},newObject:F,putStream:q,events:N,scaleFactor:h,pageSize:{width:f,height:c},output:function(t,e){return et(t,e)},getNumberOfPages:function(){return A.length-1},pages:A},D.addPage=function(){return J(),this},D.text=function(t,e,r,n,i){if("number"==typeof t){var o=r;r=e,e=t,t=o}"string"==typeof t&&t.match(/[\n\r]/)&&(t=t.split(/\r\n|\r|\n/g)),"number"==typeof n&&(i=n,n=null);var s="",a="Td";if(i){i*=Math.PI/180;var f=Math.cos(i),l=Math.sin(i);s=[U(f),U(l),U(-1*l),U(f),""].join(" "),a="Tm"}if("noBOM"in(n=n||{})||(n.noBOM=!0),"autoencode"in n||(n.autoencode=!0),"string"==typeof t)t=X(t,n);else{if(!(t instanceof Array))throw new Error('Type of text must be string or Array. "'+t+'" is not recognized.');for(var d=t.concat(),p=[],b=d.length;b--;)p.push(X(d.shift(),n));t=p.join(") Tj\nT* (")}return z("BT\n/"+u+" "+P+" Tf\n"+P*R+" TL\n"+E+"\n"+s+U(e*h)+" "+U((c-r)*h)+" "+a+"\n("+t+") Tj\nET"),this},D.line=function(t,e,r,n){return z(U(t*h)+" "+U((c-e)*h)+" m "+U(r*h)+" "+U((c-n)*h)+" l S"),this},D.lines=function(t,e,r,n,i,o){var s,a,u,f,l,d,p,b,y,g,v,m,w;for("number"==typeof t&&(s=t,a=e,t=r,e=s,r=a),i=$(i),n=void 0===n?[1,1]:n,z(H(e*h)+" "+H((c-r)*h)+" m "),u=n[0],f=n[1],d=t.length,m=e,w=r,l=0;l>16&255,e=i>>8&255,r=255&i}return E=0===t&&0===e&&0===r||void 0===e?H(t/255)+" g":[H(t/255),H(e/255),H(r/255),"rg"].join(" "),this},D.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},D.setLineCap=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line cap style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=e,z(e.toString(10)+" J"),this},D.setLineJoin=function(t){var e=this.CapJoinStyles[t];if(void 0===e)throw new Error("Line join style of '"+t+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return j=e,z(e.toString(10)+" j"),this},D.output=et,D.save=function(t){D.output("save",t)},r.API)r.API.hasOwnProperty(d)&&("events"===d&&r.API.events.length?function(t,e){var r,n,i;for(i=e.length-1;-1!==i;i--)r=e[i][0],n=e[i][1],t.subscribe.apply(t,[r].concat("function"==typeof n?[n]:n))}(N,r.API.events):D[d]=r.API[d]);return function(){var t,e,r,n,i=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"]];for(t=0,e=i.length;tn&&(i.push(t.slice(u,o)),a=0,u=o),a+=e[o],o++;return u!==o&&i.push(t.slice(u,o)),i}),i=function(t,i,o){o||(o={});var s,a,u,c,f,h=e(" ",o)[0],l=t.split(" "),d=[],p=[d],b=o.textIndent||0,y=0,g=0;for(u=0,c=l.length;ui){if(g>i){for(f=n(s,a,i-(b+y),i),d.push(f.shift()),d=[f.pop()];f.length;)p.push([f.shift()]);g=r(a.slice(s.length-d[0].length))}else d=[s];p.push(d),b=g,y=h}else d.push(s),b+=y+g,y=h;var v=[];for(u=0,c=p.length;u>"),"trns"in t&&t.trns.constructor==Array){for(var o="",s=0,a=t.trns.length;s>"),i(t.data),n("endobj"),"smask"in t){var u="/Predictor 15 /Colors 1 /BitsPerComponent "+t.bpc+" /Columns "+t.w,c={w:t.w,h:t.h,cs:"DeviceGray",bpc:t.bpc,dp:u,data:t.smask};"f"in t&&(c.f=t.f),r.call(this,c)}t.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+t.pal.length+">>"),i(this.arrayBufferToBinaryString(new Uint8Array(t.pal))),n("endobj"))},n=function(){var t=this.internal.collections.addImage_images;for(var e in t)r.call(this,t[e])},i=function(){var t,e=this.internal.collections.addImage_images,r=this.internal.write;for(var n in e)r("/I"+(t=e[n]).i,t.n,"0","R")},o=function(t,e){return t||e||(t=-96,e=-96),t<0&&(t=-1*info.w*72/t/this.internal.scaleFactor),e<0&&(e=-1*info.h*72/e/this.internal.scaleFactor),0===t&&(t=e*info.w/info.h),0===e&&(e=t*info.h/info.w),[t,e]};t.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},t.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},t.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},t.isString=function(t){return"string"==typeof t},t.extractInfoFromBase64DataURI=function(t){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(t)},t.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},t.isArrayBuffer=function(t){return!!this.supportsArrayBuffer()&&t instanceof ArrayBuffer},t.isArrayBufferView=function(t){return!!this.supportsArrayBuffer()&&(t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)},t.binaryStringToUint8Array=function(t){for(var e=t.length,r=new Uint8Array(e),n=0;n>18]+n[(258048&e)>>12]+n[(4032&e)>>6]+n[63&e];return 1==s?r+=n[(252&(e=i[a]))>>2]+n[(3&e)<<4]+"==":2==s&&(r+=n[(64512&(e=i[a]<<8|i[a+1]))>>10]+n[(1008&e)>>4]+n[(15&e)<<2]+"="),r},t.createImageInfo=function(t,e,r,n,i,o,s,a,u,c,f,h){var l={alias:a,w:e,h:r,cs:n,bpc:i,i:s,data:t};return o&&(l.f=o),u&&(l.dp=u),c&&(l.trns=c),f&&(l.pal=f),h&&(l.smask=h),l},t.addImage=function(r,s,a,u,c,f,h,l){if("number"==typeof s){var d=f;f=c,c=u,u=a,a=s,s=d||"jpeg"}var p,b,y,g,v,m=function(){var t=this.internal.collections.addImage_images;return t||(this.internal.collections.addImage_images=t={},this.internal.events.subscribe("putResources",n),this.internal.events.subscribe("putXobjectDict",i)),t}.call(this);if((y=l)&&"string"==typeof y&&(y=y.toUpperCase()),l=y in t.image_compression?y:t.image_compression.NONE,s=s.toLowerCase(),function(t){return void 0===t||null===t}(h)&&(h=void 0),"object"==typeof(g=r)&&1===g.nodeType&&(r=function(t,e){var r=document.createElement("canvas");r.width=t.clientWidth||t.width,r.height=t.clientHeight||t.height;var n=r.getContext("2d");if(!n)throw"addImage requires canvas to be supported by browser.";return n.drawImage(t,0,0,r.width,r.height),r.toDataURL("png"==e?"image/png":"image/jpeg")}(r,s)),this.isString(r)){var w=this.extractInfoFromBase64DataURI(r);w?(s=w[2],r=atob(w[3]),this.supportsArrayBuffer()&&(b=r,r=this.binaryStringToUint8Array(r))):255!==r.charCodeAt(0)&&(p=function(t,e){var r;if(e)for(var n in e)if(t===e[n].alias){r=e[n];break}return r}(r,m))}if(v=s,-1===e.indexOf(v))throw new Error("addImage currently only supports formats "+e+", not '"+s+"'");if(function(e){return"function"!=typeof t["process"+e.toUpperCase()]}(s))throw new Error("please ensure that the plugin for '"+s+"' support is added");var _=function(t){var e=0;return t&&(e=Object.keys?Object.keys(t).length:function(t){var e=0;for(var r in t)t.hasOwnProperty(r)&&e++;return e}(t)),e}(m),E=p;if(E||(E=this["process"+s.toUpperCase()](r,_,h,l,b)),!E)throw new Error("An unkwown error occurred whilst processing the image");return function(t,e,r,n,i,s,a){var u=o(r,n),c=this.internal.getCoordinateString,f=this.internal.getVerticalCoordinateString;r=u[0],n=u[1],a[s]=i,this.internal.write("q",c(r),"0 0",c(n),c(t),f(e+n),"cm /I"+i.i,"Do Q")}.call(this,a,u,c,f,E,_,m),this};var s=function(t,e){return t.subarray(e,e+4)};t.processJPEG=function(t,e,r,n,i){var o,a=this.color_spaces.DEVICE_RGB,u=this.decode.DCT_DECODE;return this.isString(t)?(o=function(t){var e;if(255===!t.charCodeAt(0)||216===!t.charCodeAt(1)||255===!t.charCodeAt(2)||224===!t.charCodeAt(3)||!t.charCodeAt(6)==="J".charCodeAt(0)||!t.charCodeAt(7)==="F".charCodeAt(0)||!t.charCodeAt(8)==="I".charCodeAt(0)||!t.charCodeAt(9)==="F".charCodeAt(0)||0===!t.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var r=256*t.charCodeAt(4)+t.charCodeAt(5),n=4,i=t.length;n7)return{width:((e=s(t,i+5))[2]<<8)+e[3],height:(e[0]<<8)+e[1]};i+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")}(t),t=i||this.arrayBufferToBinaryString(t),this.createImageInfo(t,o.width,o.height,a,8,u,e,r)):null)},t.processJPG=function(t,e,r,n,i){return this.processJPEG(t,e,r,n,i)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(t){"use strict";var e=t.document,r=t.URL||t.webkitURL||t,n=e.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in n,o=t.webkitRequestFileSystem,s=t.requestFileSystem||o||t.mozRequestFileSystem,a=function(e){(t.setImmediate||t.setTimeout)(function(){throw e},0)},u=0,c=[],f=function(t,e,r){for(var n=(e=[].concat(e)).length;n--;){var i=t["on"+e[n]];if("function"==typeof i)try{i.call(t,r||t)}catch(t){a(t)}}},h=function(r,a){var h,l,d,p,b,y=this,g=r.type,v=!1,m=function(){var e=(t.URL||t.webkitURL||t).createObjectURL(r);return c.push(e),e},w=function(){f(y,"writestart progress write writeend".split(" "))},_=function(){!v&&h||(h=m()),l&&(l.location.href=h),y.readyState=y.DONE,w()},E=function(t){return function(){if(y.readyState!==y.DONE)return t.apply(this,arguments)}},S={create:!0,exclusive:!1};if(y.readyState=y.INIT,a||(a="download"),i&&(h=m(),n.href=h,n.download=a,p=n,(b=e.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,t,0,0,0,0,0,!1,!1,!1,!1,0,null),p.dispatchEvent(b)))return y.readyState=y.DONE,void w();t.chrome&&g&&"application/octet-stream"!==g&&(d=r.slice||r.webkitSlice,r=d.call(r,0,r.size,"application/octet-stream"),v=!0),o&&"download"!==a&&(a+=".download"),l="application/octet-stream"===g||o?t:t.open(),s?(u+=r.size,s(t.TEMPORARY,u,E(function(t){t.root.getDirectory("saved",S,E(function(t){var e=function(){t.getFile(a,S,E(function(t){t.createWriter(E(function(e){e.onwriteend=function(e){l.location.href=t.toURL(),c.push(t),y.readyState=y.DONE,f(y,"writeend",e)},e.onerror=function(){var t=e.error;t.code!==t.ABORT_ERR&&_()},"writestart progress write abort".split(" ").forEach(function(t){e["on"+t]=y["on"+t]}),e.write(r),y.abort=function(){e.abort(),y.readyState=y.DONE},y.readyState=y.WRITING}),_)}),_)};t.getFile(a,{create:!1},E(function(t){t.remove(),e()}),E(function(t){t.code===t.NOT_FOUND_ERR?e():_()}))}),_)}),_)):_()},l=h.prototype;return l.abort=function(){this.readyState=this.DONE,f(this,"abort")},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,t.addEventListener("unload",function(){for(var t=c.length;t--;){var e=c[t];"string"==typeof e?r.revokeObjectURL(e):e.remove()}c.length=0},!1),function(t,e){return new h(t,e)}}(self);!function(t){"use strict";var e=function(){var t="function"==typeof Deflater;if(!t)throw new Error("requires deflate.js for compression");return t},r=function(e,r,s,h){var l=5,d=u;switch(h){case t.image_compression.FAST:l=3,d=a;break;case t.image_compression.MEDIUM:l=6,d=c;break;case t.image_compression.SLOW:l=9,d=f}e=o(e,r,s,d);var p=new Uint8Array(n(l)),b=i(e),y=new Deflater(l),g=y.append(e),v=y.flush(),m=p.length+g.length+v.length,w=new Uint8Array(m+4);return w.set(p),w.set(g,p.length),w.set(v,p.length+g.length),w[m++]=b>>>24&255,w[m++]=b>>>16&255,w[m++]=b>>>8&255,w[m++]=255&b,t.arrayBufferToBinaryString(w)},n=function(t,e){var r=Math.LOG2E*Math.log(32768)-8<<4|8,n=r<<8;return n|=Math.min(3,(e-1&255)>>1)<<6,n|=0,[r,255&(n+=31-n%31)]},i=function(t,e){for(var r,n=1,i=0,o=t.length,s=0;o>0;){o-=r=o>e?e:o;do{i+=n+=t[s++]}while(--r);n%=65521,i%=65521}return(i<<16|n)>>>0},o=function(t,e,r,n){for(var i,o,s,a=t.length/e,u=new Uint8Array(t.length+a),c=l(),f=0;f>>1)&255;return o},f=function(t,e,r){var n,i,o,s,a=[],u=0,c=t.length;for(a[0]=4;u>>g&255,g+=u.bits;w[E]=k>>>g&255}if(16===u.bits){v=(M=new Uint32Array(u.decodePixels().buffer)).length,m=new Uint8Array(v*(32/u.pixelBitlength)*u.colors),w=new Uint8Array(v*(32/u.pixelBitlength));for(var k,A=u.colors>1,I=(E=0,S=0,0);E>>0&255,A&&(m[S++]=k>>>16&255,k=M[E++],m[S++]=k>>>0&255),w[I++]=k>>>16&255;y=8}s!==t.image_compression.NONE&&e()?(n=r(m,u.width*u.colors,u.colors,s),d=r(w,u.width,1,s)):(n=m,d=w,b=null)}if(3===u.colorType&&(p=this.color_spaces.INDEXED,l=u.palette,u.transparency.indexed)){var x=u.transparency.indexed,T=0;for(E=0,v=x.length;En&&(r=n)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(e,r)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,r){for(var n=t+e;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,r)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),FlateStream=function(){var t=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),e=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),n=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function o(t){throw new Error(t)}function s(t){var e=0,r=t[e++],n=t[e++];-1!=r&&-1!=n||o("Invalid header in flate stream"),8!=(15&r)&&o("Unknown compression method in flate stream"),((r<<8)+n)%31!=0&&o("Bad FCHECK in flate stream"),32&n&&o("FDICT bit set in flate stream"),this.bytes=t,this.bytesPos=e,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}return s.prototype=Object.create(DecodeStream.prototype),s.prototype.getBits=function(t){for(var e,r=this.codeSize,n=this.codeBuf,i=this.bytes,s=this.bytesPos;r>t,this.codeSize=r-=t,this.bytesPos=s,e},s.prototype.getCode=function(t){for(var e=t[0],r=t[1],n=this.codeSize,i=this.codeBuf,s=this.bytes,a=this.bytesPos;n>16,h=65535&c;return(0==n||n>f,this.codeSize=n-f,this.bytesPos=a,h},s.prototype.generateHuffmanTable=function(t){for(var e=t.length,r=0,n=0;nr&&(r=t[n]);for(var i=1<>=1;for(n=f;n0;)e[p++]=i}var a=this.getBits(3);if(1&a&&(this.eof=!0),0!=(a>>=1)){var u,c;if(1==a)u=n,c=i;else if(2==a){for(var f=this.getBits(5)+257,h=this.getBits(5)+1,l=this.getBits(4)+4,d=Array(t.length),p=0;p=w&&(w=(C=this.ensureBuffer(_+1)).length),C[_++]=E;else{if(256==E)return void(this.bufferLength=_);var S=(E=e[E-=257])>>16;S>0&&(S=this.getBits(S));y=(65535&E)+S;E=this.getCode(c),(S=(E=r[E])>>16)>0&&(S=this.getBits(S));var k=(65535&E)+S;_+y>=w&&(w=(C=this.ensureBuffer(_+y)).length);for(var A=0;Ae;0<=e?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(e),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((f=n-this.transparency.indexed.length)>0)for(d=0;0<=f?df;0<=f?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":a=(h=this.read(e)).indexOf(0),u=String.fromCharCode.apply(String,h.slice(0,a)),this.text[u]=String.fromCharCode.apply(String,h.slice(a+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return n.load=function(t,e,r){var i;return"function"==typeof e&&(r=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new n(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof r?r(t):void 0},i.send(null)},0,1,2,0,1,n.prototype.read=function(t){var e,r;for(r=[],e=0;0<=t?et;0<=t?++e:--e)r.push(this.data[this.pos++]);return r},n.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.decodePixels=function(t){var e,r,n,i,o,s,a,u,c,f,h,l,d,p,b,y,g,v,m,w,_,E,S;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new FlateStream(t)).getBytes(),y=(l=this.pixelBitlength/8)*this.width,d=new Uint8Array(y*this.height),s=t.length,b=0,p=0,r=0;p1&&r/i0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=g.AES.encrypt(t.secret,t.passphrase).toString(g.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=g.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(g.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=g.AES.encrypt(t.secret,t.recoverySecret).toString(g.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,g,v,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=g,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function g(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(g,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,g=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?g.splice(r.random(0,g.length),0,n):g.push(n)}t()},function(t){g.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new u.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;pe?e:p.length,a=0,u=p.length;a=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&g(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&g(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=g,l.ok=v,l.equal=function(t,e,r){t!=e&&g(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&g(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||g(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||g(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&g(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&g(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&g(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&g(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||g(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!g(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return g(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(g(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),x(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function g(t){return"string"==typeof t}function v(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=g,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),I[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(g),o.filterSeries=p(g),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(c,v),v.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,g,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,g=t.t-1,v=!0,m=new BigInteger;for(i=l(t[g])-1;g>=0;){for(i>=u?b=t[g]>>i-u&c:(b=(t[g]&(1<0&&(b|=t[g-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--g),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;g>=0&&0==(t[g]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^g[u>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^g[e>>8&255]^v[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^g[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^g[a>>8&255]^v[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var g=t("./templates");for(var v in g)e.exports[v]=g[v]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),g=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:g};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function g(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,v=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!g(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),v&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,g,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,g=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(g=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,g=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,g=u,v=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,g=u=h.P2PKH,v=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}g===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=g,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!g(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,g="...",v=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",I="[object Array]",x="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",q="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,J=RegExp(Y.source),Z=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[F]=yt[q]=!0,yt[A]=yt[I]=yt[L]=yt[x]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var gt={};gt[A]=gt[I]=gt[L]=gt[x]=gt[T]=gt[j]=gt[D]=gt[N]=gt[U]=gt[H]=gt[P]=gt[C]=gt[R]=gt[O]=gt[K]=gt[z]=gt[F]=gt[q]=!0,gt[M]=gt[B]=gt["[object Map]"]=gt["[object Set]"]=gt["[object WeakMap]"]=!1;var vt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,It=Et[typeof e]&&e&&!e.nodeType&&e,xt=At&&It&&"object"==typeof t&&t;!xt||xt.global!==xt&&xt.window!==xt&&xt.self!==xt||(kt=xt);var Tt=It&&It.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function qt(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!qn(t)){if(t instanceof Le)return t;if(Zt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=xe,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ge(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Jr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function Fr(t,e,i,o,s,p,y,g,v,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,I=!E&&Kr(t),x=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=qt(b,T);if((f-=M.length)=(e=+e)||!ve(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var g=e&u;if(!g&&!Yn(t))throw new It(S);var v=i?i.length:0;if(v||(e&=~(l|d),i=o=null),v-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!g&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],g=(l?t:e)[8],v=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=v)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Zt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Zt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Zr(n)&&(qn(t)||i.nonEnumArgs&&Fn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Zt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=qn(t)?Fe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(qn(t)?qe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(qn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?ze(t,e):sr(t,Rr(e,r,3))}function In(t,e,r){return"function"==typeof e&&void 0===r&&qn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var xn=Dr(function(t,e,r){Zt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(qn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=xe;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new It(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function g(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),g=n<=0||n>l;g?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return g&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(g=!0,s=t.apply(u,i)),!g||c||o||(i=u=null),s}return g.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},g}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!Fe(t,Yn))throw new It(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new It(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function Fn(t){return Zr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var qn=ye||function(t){return zt(t)&&Zr(t.length)&&$t.call(t)==I||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ve(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Jn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Zn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Jn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Zr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return gr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Zr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Zr(e)&&(qn(t)||je.nonEnumArgs&&Fn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=Ir(arguments,2),o=qt(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=vn,Oe.chunk=function(t,e,n){e=(n?Jr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Jr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Jr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Zr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Jr(t,e,r):null==e)&&(e=1),Ir(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return Ir(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Zt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=Fn,Oe.isArray=qn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==x||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Zr(e)&&(qn(t)||ti(t)||Fn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?vr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Zt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Zn(t)&&t!=+t},Oe.isNative=Jn,Oe.isNull=function(t){return null===t},Oe.isNumber=Zn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=Ii,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ve(e))return t;var i=(e-n)/2,o=se(i);return(r=qr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&qr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+qr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Jr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Zr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=gi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Jr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Ze)).imports),i.imports,Ze),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=vi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Jr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Jr(t,e,r)&&(e=null);var n=y,i=g;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||qn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=xt[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!qn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}g.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},g.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},g.prototype.split=function(t,e){t.iushrn(this.n,0,e)},g.prototype.imulK=function(t){return t.imul(this.k)},i(v,g),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[g++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[g++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[g++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[g++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[g++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[g++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[g++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[g++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return g(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],g=8191&y,v=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],I=8191&A,x=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,F=0|a[1],q=8191&F,W=F>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],J=8191&X,Z=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var gt=(c+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,z))+Math.imul(v,K)|0,o=Math.imul(v,z),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var vt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(l,J)|0))<<13)|0;c=((o=o+Math.imul(l,Z)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Z)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(x,K)|0,o=Math.imul(x,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Z)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,tt)|0)+Math.imul(v,$)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(x,G)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(g,rt)|0,i=(i=i+Math.imul(g,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(g,ot)|0,i=(i=i+Math.imul(g,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,q)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(g,ut)|0,i=(i=i+Math.imul(g,ct)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,W))+Math.imul(U,q)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(g,ht)|0,i=(i=i+Math.imul(g,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var It=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,Z)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var xt=(c+(n=n+Math.imul(g,pt)|0)|0)+((8191&(i=(i=i+Math.imul(g,bt)|0)+Math.imul(v,pt)|0))<<13)|0;c=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,Z))+Math.imul(U,J)|0,o=Math.imul(U,Z),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(I,ut)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=gt,u[2]=vt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=It,u[11]=xt,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):g(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},i(I,A),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],g=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,u[r]=v<<8|v>>>24,c[r]=v;v=16843009*g^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[g^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],g=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=g,l=v}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],g=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=g,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:g}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},g=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=g.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,g.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],g=t[e+6],v=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],I=t[e+15],x=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,x=c(x,T,M,B,s,7,a[0]),T,M,u,12,a[1]),x,T,d,17,a[2]),B,x,p,22,a[3]),M=c(M,B=c(B,x=c(x,T,M,B,b,7,a[4]),T,M,y,12,a[5]),x,T,g,17,a[6]),B,x,v,22,a[7]),M=c(M,B=c(B,x=c(x,T,M,B,m,7,a[8]),T,M,w,12,a[9]),x,T,_,17,a[10]),B,x,E,22,a[11]),M=c(M,B=c(B,x=c(x,T,M,B,S,7,a[12]),T,M,k,12,a[13]),x,T,A,17,a[14]),B,x,I,22,a[15]),M=f(M,B=f(B,x=f(x,T,M,B,u,5,a[16]),T,M,g,9,a[17]),x,T,E,14,a[18]),B,x,s,20,a[19]),M=f(M,B=f(B,x=f(x,T,M,B,y,5,a[20]),T,M,_,9,a[21]),x,T,I,14,a[22]),B,x,b,20,a[23]),M=f(M,B=f(B,x=f(x,T,M,B,w,5,a[24]),T,M,A,9,a[25]),x,T,p,14,a[26]),B,x,m,20,a[27]),M=f(M,B=f(B,x=f(x,T,M,B,k,5,a[28]),T,M,d,9,a[29]),x,T,v,14,a[30]),B,x,S,20,a[31]),M=h(M,B=h(B,x=h(x,T,M,B,y,4,a[32]),T,M,m,11,a[33]),x,T,E,16,a[34]),B,x,A,23,a[35]),M=h(M,B=h(B,x=h(x,T,M,B,u,4,a[36]),T,M,b,11,a[37]),x,T,v,16,a[38]),B,x,_,23,a[39]),M=h(M,B=h(B,x=h(x,T,M,B,k,4,a[40]),T,M,s,11,a[41]),x,T,p,16,a[42]),B,x,g,23,a[43]),M=h(M,B=h(B,x=h(x,T,M,B,w,4,a[44]),T,M,S,11,a[45]),x,T,I,16,a[46]),B,x,d,23,a[47]),M=l(M,B=l(B,x=l(x,T,M,B,s,6,a[48]),T,M,v,10,a[49]),x,T,A,15,a[50]),B,x,y,21,a[51]),M=l(M,B=l(B,x=l(x,T,M,B,S,6,a[52]),T,M,p,10,a[53]),x,T,_,15,a[54]),B,x,u,21,a[55]),M=l(M,B=l(B,x=l(x,T,M,B,m,6,a[56]),T,M,I,10,a[57]),x,T,g,15,a[58]),B,x,k,21,a[59]),M=l(M,B=l(B,x=l(x,T,M,B,b,6,a[60]),T,M,E,10,a[61]),x,T,d,15,a[62]),B,x,w,21,a[63]),o[0]=o[0]+x|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,I,x,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],I=_=T[4];for(r=0;r<80;r+=1)x=o+t[e+P[r]]|0,x+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?g(s,d,w)+M[3]:v(s,d,w)+M[4],x=(x=m(x|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=x,x=E+t[e+C[r]]|0,x+=r<16?v(S,k,A)+B[0]:r<32?g(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],x=(x=m(x|=0,O[r]))+I|0,E=I,I=A,A=m(k,10),k=S,S=x;x=T[1]+d+A|0,T[1]=T[2]+w+I|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=x},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function g(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],g=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+g+c[d-16]}var v=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var g=h[(l+4)%5],v=h[(l+1)%5],m=v.high,w=v.low;for(d=g.high^(m<<1|w>>>31),p=g.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var I=h[0],x=r[0];I.high=x.high,I.low=x.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,g=o.high,v=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,I=h.low,x=l.high,T=l.low,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=I,F=x,q=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],J=X.high,Z=X.low,Q=(J>>>1|Z<<31)^(J>>>8|Z<<24)^J>>>7,$=(Z>>>1|J<<31)^(Z>>>8|J<<24)^(Z>>>7|J<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),gt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),vt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=F+vt+((ht=q+mt)>>>0>>0?1:0),kt=gt+bt;F=K,q=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0
>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),v=o.low=v+O,o.high=g+R+(v>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),I=h.low=I+z,h.high=A+K+(I>>>0>>0?1:0),T=l.low=T+q,l.high=x+F+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&g(p)&&g(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var g=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(g[1]=e[b].add(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].add(e[y].neg())):(g[1]=e[b].toJ().mixedAdd(e[y]),g[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][I-1>>1]:I<0&&(c=h[u][-I-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),g=new i(1),v=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=g.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++v)break;u=c,d=l,l=c,y=p,p=f,g=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var g=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(g=g.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),v^=1),new f({r:y,s:g,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,g="-",v=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function I(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function x(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+I((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,v,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(g))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,v,m,w,_,E,I=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),v==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,I.push(k(B(p+E%_,0))),u=S(E/_);I.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return I.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return x(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return x(t,function(t){return v.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(I,t,e))}function I(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",g),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",v),m()}function v(){l("onfinish"),t.removeListener("close",g),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",g),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;g.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(e){if(a=a||t("./_stream_duplex"),!(d.call(g,this)||this instanceof a))return new g(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(g,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===g&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),g.prototype.destroy=p.destroy,g.prototype._undestroy=p.undestroy,g.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,g=2,v=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,I=30,x="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",g],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",F="[object Boolean]",q="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",J="[object Number]",Z="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",gt="[object Uint32Array]",vt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,It=/<%([\s\S]+?)%>/g,xt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,Ft=/^[-+]0x[0-9a-f]+$/i,qt=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Zt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Zt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ge=RegExp("['’]","g"),ve=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Zt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[gt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[F]=Ae[ut]=Ae[q]=Ae[V]=Ae[G]=Ae[X]=Ae[J]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var Ie={};Ie[H]=Ie[K]=Ie[at]=Ie[ut]=Ie[F]=Ie[q]=Ie[ct]=Ie[ft]=Ie[ht]=Ie[lt]=Ie[dt]=Ie[X]=Ie[J]=Ie[Q]=Ie[tt]=Ie[et]=Ie[rt]=Ie[nt]=Ie[pt]=Ie[bt]=Ie[yt]=Ie[gt]=!0,Ie[V]=Ie[G]=Ie[ot]=!1;var xe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,Fe=De&&De.isTypedArray;function qe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Ze(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+xe[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Ir(t,e){return function(r){return t(e(r))}}function xr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Zt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,xe=Buffer?Buffer.allocUnsafe:n,Be=Ir(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Zt&&Zt.now!==Ce.Date.now&&Zt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,Fr=oe.join,qr=Ir(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Zt.now,Yr=e.parseInt,Xr=te.random,Jr=oe.reverse,Zr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Zr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof gn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new gn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function gn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=Fo(t),y=b==G||b==Y;if(Ea(t))return Zi(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!Ie[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case F:case q:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case gt:return $i(t,r);case X:return new s;case J:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var g=s.get(t);if(g)return g;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Je,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Ze,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Jn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Zn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Ze:Je,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function Ii(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function xi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Ji=Lr||function(t){return Ce.clearTimeout(t)};function Zi(t,e){if(e)return t.slice();var r=t.length,n=xe?xe(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=gn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new gn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Je(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new gn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var Fs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var qs=lo(gs),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(va(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?qe(e,t,r):ii(t,e,r)}),o}),Js=oo(function(t,e,r){Rn(t,r,e)});function Zs(t,e){return(va(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,Io(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=xr(r,jo(na));n|=_}return Io(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|g;if(r.length){var i=xr(r,jo(ia));n|=_}return Io(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function g(){var t=ta();if(y(t))return v(t);c=os(g,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(g,e),l?b(t):u}(f);if(d)return Ji(c),c=os(g,e),b(f)}return c===n&&(c=os(g,e)),u}return e=qa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(qa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Ji(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:v(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,qa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ga=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},va=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&xa(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||qu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==q};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function Ia(t){return"number"==typeof t&&t==za(t)}function xa(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&Fo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==J}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&Fo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=Fe?yr(Fe):function(t){return Ma(t)&&xa(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=Fo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=qa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function Fa(t){return t?Ln(za(t),0,j):0}function qa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=qt.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):Ft.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Ja=so(function(t,e,r,n){io(e,ou(e),t,n)}),Za=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:gr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function gu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var Iu=ki(function(t,e){try{return qe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),xu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Jn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Jn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=vo(Qe),Nu=vo(Ye),Uu=vo(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Zn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function Fu(){return[]}function qu(){return!1}var Wu=go(function(t,e){return t+e},0),Vu=So("ceil"),Gu=go(function(t,e){return t/e},1),Yu=So("floor");var Xu,Ju=go(function(t,e){return t*e},1),Zu=So("round"),Qu=go(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Ja,pn.at=Za,pn.before=ra,pn.bind=na,pn.bindAll=xu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:Fa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),qe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return va(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:gr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return qi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return qi(t||[],e||[],xi)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=Iu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=qa(r))==r?r:0),e!==n&&(e=(e=qa(e))==e?e:0),Ln(qa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=gu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=qs,pn.findIndex=gs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&qo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&Fo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":Fr.call(t,e)},pn.kebabCase=vu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?Fn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?Fn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?Fn(t,Do(e,2),li):n},pn.stubArray=Fu,pn.stubFalse=qu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Ju,pn.nth=function(t,e){return t&&t.length?gi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Pu)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ca(Do(t)))},vn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof vn,c=a[0],f=u||va(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new gn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,g).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new gn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function I(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function x(t){return I(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=I,k.promise=I,I.race=x,I.all=q,I.reject=H,I.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=x,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function F(t,e,r){return k(t).dispatch(e,r)}function q(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(q(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return F(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===g(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,q(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=F,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=q,T.prototype.all=function(){return q(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return q(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=g.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=g.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),g.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=g.G15<=0;)e^=g.G18<>>=1;return e},getPatternPosition:function(t){return g.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return v.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)v.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):I(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?I(t,s,e,!1):P(t,s)):I(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var I,x;A<16?(I=p(r,n,i,l,m,t[s[A]],f[0],u[A]),x=v(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(I=b(r,n,i,l,m,t[s[A]],f[1],u[A]),x=g(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(I=y(r,n,i,l,m,t[s[A]],f[2],u[A]),x=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(I=g(r,n,i,l,m,t[s[A]],f[3],u[A]),x=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(I=v(r,n,i,l,m,t[s[A]],f[4],u[A]),x=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=I,w=k,k=S,S=d(E,10),E=_,_=x}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,g=0;g<16;++g)r[g]=t.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((e=r[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[g-7]+l(r[g-15])+r[g-16];for(var v=0;v<64;++v){var m=y+h(d)+u(d,p,b)+o[v]+r[v]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,g=0|this._fh,v=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,I=0|this._gl,x=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),F=c(w,_,E),q=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],J=u(a,g,v),Z=u(k,A,I),Q=x+G|0,$=m+V+y(Q,x)|0;$=($=($=$+J+y(Q=Q+Z|0,Z)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+F|0,et=q+z+y(tt,W)|0;m=v,x=I,v=g,I=A,g=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+I|0,this._hl=this._hl+x|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+g+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,I)|0,this._hh=this._hh+m+y(this._hl,x)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],g=u[3],v=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^g[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^g[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^g[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^g[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],g=i[11],v=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,I=f,x=h,T=l,M=d,B=p,P=b,C=y,R=g,O=v,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],F=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=F)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var q=P&R^~P&L,W=(H=E&k^E&I^k&I,S&A^S&x^A&x),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),F=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+q)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=F+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=I,M=x,I=k,x=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+x|0,i[4]=f+I+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,g=i[11]=g+R|0,i[10]=y+C+(g>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=v+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var g=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,x),D=B.slice(x+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(x=0,P=f.length;x0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],I=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,x=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),x++):x&&(S.splice(T,1),x--);if(!_&&!E)for(;x--;x)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),I&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u 300) { - // max inputs length - chunk = 300; + if (utxoArray.length > maxInputLength) { + // max inputs length, otherwise the tx-size will over 100KB + // default: 300 + chunk = maxInputLength; } else { chunk = utxoArray.length; } @@ -7438,7 +7439,7 @@ WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee } rawTransactionList.push(this.signTransaction(rawTransaction, temp)); } - console.log("rawTransactionList:",rawTransactionList); + console.log("raw transaction list:",rawTransactionList); return rawTransactionList; }; diff --git a/build/blocktrail-sdk-with-backup-generator.min.js b/build/blocktrail-sdk-with-backup-generator.min.js index c4adbf9..40154bc 100644 --- a/build/blocktrail-sdk-with-backup-generator.min.js +++ b/build/blocktrail-sdk-with-backup-generator.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).blocktrailSDK=t()}}(function(){return function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){return i(e[s][1][t]||t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=v.AES.encrypt(t.secret,t.passphrase).toString(v.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=v.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(v.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=v.AES.encrypt(t.secret,t.recoverySecret).toString(v.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,v,g,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=g,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function v(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function g(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(v,"cashaddr"),n||a(g,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,v=[],g=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return g.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?v.splice(r.random(0,v.length),0,n):v.push(n)}t()},function(t){v.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(g.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?g.reject(new u.WalletSendError(e)):g.resolve([d,t])}),g.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=v,l.ok=g,l.equal=function(t,e,r){t!=e&&v(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||v(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||v(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&v(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||v(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!v(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return v(i)||(i=f(t,i,n)),i}var o=function(t,e){if(g(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),I(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function g(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(g(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=v,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=g,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(g),o.rejectSeries=p(g);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),BigInteger.ONE.dlShiftTo(c,g),g.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,v,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,v=t.t-1,g=!0,m=new BigInteger;for(i=l(t[v])-1;v>=0;){for(i>=u?b=t[v]>>i-u&c:(b=(t[v]&(1<0&&(b|=t[v-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),g)s[b].copyTo(o),g=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;v>=0&&0==(t[v]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^v[u>>8&255]^g[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^v[e>>8&255]^g[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^v[o>>8&255]^g[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^v[a>>8&255]^g[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var v=t("./templates");for(var g in v)e.exports[g]=v[g]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),g={script:d,valueBuffer:v};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function v(t){return-1!==d.indexOf(t)}function g(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,g=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),g=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!v(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),g&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,v,g,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=b=a.scriptType,g=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,g=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,v=b=a.scriptType,g=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,v=u,g=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,v=u=h.P2PKH,g=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}v===h.P2WPKH&&(g=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(g))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=g,t.signType=v,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=g(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!v(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,v="...",g=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",x="[object Array]",I="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",F="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,Z=RegExp(Y.source),J=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[q]=yt[F]=!0,yt[A]=yt[x]=yt[L]=yt[I]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var vt={};vt[A]=vt[x]=vt[L]=vt[I]=vt[T]=vt[j]=vt[D]=vt[N]=vt[U]=vt[H]=vt[P]=vt[C]=vt[R]=vt[O]=vt[K]=vt[z]=vt[q]=vt[F]=!0,vt[M]=vt[B]=vt["[object Map]"]=vt["[object Set]"]=vt["[object WeakMap]"]=!1;var gt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,xt=Et[typeof e]&&e&&!e.nodeType&&e,It=At&&xt&&"object"==typeof t&&t;!It||It.global!==It&&It.window!==It&&It.self!==It||(kt=It);var Tt=xt&&xt.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function Ft(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!Fn(t)){if(t instanceof Le)return t;if(Jt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=Ie,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ve(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Zr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function qr(t,e,i,o,s,p,y,v,g,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,x=!E&&Kr(t),I=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=Ft(b,T);if((f-=M.length)=(e=+e)||!ge(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var v=e&u;if(!v&&!Yn(t))throw new xt(S);var g=i?i.length:0;if(g||(e&=~(l|d),i=o=null),g-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!v&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],v=(l?t:e)[8],g=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=g)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Jt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Jt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Jr(n)&&(Fn(t)||i.nonEnumArgs&&qn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Jt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=Fn(t)?qe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(Fn(t)?Fe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(Fn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?ze(t,e):sr(t,Rr(e,r,3))}function xn(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var In=Dr(function(t,e,r){Jt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(Fn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=Ie;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new xt(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function v(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),v=n<=0||n>l;v?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return v&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(v=!0,s=t.apply(u,i)),!v||c||o||(i=u=null),s}return v.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},v}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!qe(t,Yn))throw new xt(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new xt(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function qn(t){return Jr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var Fn=ye||function(t){return zt(t)&&Jr(t.length)&&$t.call(t)==x||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ge(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Zn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Jn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Zn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Jr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return vr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Jr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Jr(e)&&(Fn(t)||je.nonEnumArgs&&qn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=gn,Oe.chunk=function(t,e,n){e=(n?Zr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Zr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Zr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Jr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return xr(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Jt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=qn,Oe.isArray=Fn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==I||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Jr(e)&&(Fn(t)||ti(t)||qn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?gr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Jt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Jn(t)&&t!=+t},Oe.isNative=Zn,Oe.isNull=function(t){return null===t},Oe.isNumber=Jn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=xi,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ge(e))return t;var i=(e-n)/2,o=se(i);return(r=Fr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&Fr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+Fr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Zr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Jr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=vi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Zr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Je)).imports),i.imports,Je),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=gi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Zr(t,e,r)&&(e=null);var n=y,i=v;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||Fn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=It[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!Fn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(g,v),g.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[v++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[v++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[v++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[v++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[v++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[v++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[v++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[v++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return g(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function v(t,e,r){return y(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):v(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],v=t[y],g=257*t[p]^16843008*p;s[r]=g<<24|g>>>8,a[r]=g<<16|g>>>16,u[r]=g<<8|g>>>24,c[r]=g;g=16843009*v^65537*y^257*b^16843008*r;f[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,l[p]=g<<8|g>>>24,d[p]=g,r?(r=b^t[t[t[v^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],g=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=v,l=g}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],g=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:v}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,v.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],v=t[e+6],g=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],I=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,I=c(I,T,M,B,s,7,a[0]),T,M,u,12,a[1]),I,T,d,17,a[2]),B,I,p,22,a[3]),M=c(M,B=c(B,I=c(I,T,M,B,b,7,a[4]),T,M,y,12,a[5]),I,T,v,17,a[6]),B,I,g,22,a[7]),M=c(M,B=c(B,I=c(I,T,M,B,m,7,a[8]),T,M,w,12,a[9]),I,T,_,17,a[10]),B,I,E,22,a[11]),M=c(M,B=c(B,I=c(I,T,M,B,S,7,a[12]),T,M,k,12,a[13]),I,T,A,17,a[14]),B,I,x,22,a[15]),M=f(M,B=f(B,I=f(I,T,M,B,u,5,a[16]),T,M,v,9,a[17]),I,T,E,14,a[18]),B,I,s,20,a[19]),M=f(M,B=f(B,I=f(I,T,M,B,y,5,a[20]),T,M,_,9,a[21]),I,T,x,14,a[22]),B,I,b,20,a[23]),M=f(M,B=f(B,I=f(I,T,M,B,w,5,a[24]),T,M,A,9,a[25]),I,T,p,14,a[26]),B,I,m,20,a[27]),M=f(M,B=f(B,I=f(I,T,M,B,k,5,a[28]),T,M,d,9,a[29]),I,T,g,14,a[30]),B,I,S,20,a[31]),M=h(M,B=h(B,I=h(I,T,M,B,y,4,a[32]),T,M,m,11,a[33]),I,T,E,16,a[34]),B,I,A,23,a[35]),M=h(M,B=h(B,I=h(I,T,M,B,u,4,a[36]),T,M,b,11,a[37]),I,T,g,16,a[38]),B,I,_,23,a[39]),M=h(M,B=h(B,I=h(I,T,M,B,k,4,a[40]),T,M,s,11,a[41]),I,T,p,16,a[42]),B,I,v,23,a[43]),M=h(M,B=h(B,I=h(I,T,M,B,w,4,a[44]),T,M,S,11,a[45]),I,T,x,16,a[46]),B,I,d,23,a[47]),M=l(M,B=l(B,I=l(I,T,M,B,s,6,a[48]),T,M,g,10,a[49]),I,T,A,15,a[50]),B,I,y,21,a[51]),M=l(M,B=l(B,I=l(I,T,M,B,S,6,a[52]),T,M,p,10,a[53]),I,T,_,15,a[54]),B,I,u,21,a[55]),M=l(M,B=l(B,I=l(I,T,M,B,m,6,a[56]),T,M,x,10,a[57]),I,T,v,15,a[58]),B,I,k,21,a[59]),M=l(M,B=l(B,I=l(I,T,M,B,b,6,a[60]),T,M,E,10,a[61]),I,T,d,15,a[62]),B,I,w,21,a[63]),o[0]=o[0]+I|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,I,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)I=o+t[e+P[r]]|0,I+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?v(s,d,w)+M[3]:g(s,d,w)+M[4],I=(I=m(I|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=I,I=E+t[e+C[r]]|0,I+=r<16?g(S,k,A)+B[0]:r<32?v(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],I=(I=m(I|=0,O[r]))+x|0,E=x,x=A,A=m(k,10),k=S,S=I;I=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=I},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function v(t,e,r){return t&r|e&~r}function g(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+v+c[d-16]}var g=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],g=h[(l+1)%5],m=g.high,w=g.low;for(d=v.high^(m<<1|w>>>31),p=v.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var x=h[0],I=r[0];x.high=I.high,x.low=I.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,v=o.high,g=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,I=l.high,T=l.low,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=x,q=I,F=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],Z=X.high,J=X.low,Q=(Z>>>1|J<<31)^(Z>>>8|J<<24)^Z>>>7,$=(J>>>1|Z<<31)^(J>>>8|Z<<24)^(J>>>7|Z<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),vt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=q+gt+((ht=F+mt)>>>0>>0?1:0),kt=vt+bt;q=K,F=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0
>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),g=o.low=g+O,o.high=v+R+(g>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+z,h.high=A+K+(x>>>0>>0?1:0),T=l.low=T+F,l.high=I+q+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var v=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(v[1]=e[b].add(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].add(e[y].neg())):(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][x-1>>1]:x<0&&(c=h[u][-x-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),v=new i(1),g=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=v.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++g)break;u=c,d=l,l=c,y=p,p=f,v=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),g^=1),new f({r:y,s:v,recoveryParam:g})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,v="-",g=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function I(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,g,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(g=t.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,g,m,w,_,E,x=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&gS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),g==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,x.push(k(B(p+E%_,0))),u=S(E/_);x.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return I(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return I(t,function(t){return g.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",v),t.removeListener("finish",g),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",g),m()}function g(){l("onfinish"),t.removeListener("close",v),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",v),t.once("finish",g),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},g.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(e){if(a=a||t("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function g(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,g(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(g(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(v,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===v&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,v=2,g=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,I="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",v],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",q="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",Z="[object Number]",J="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",vt="[object Uint32Array]",gt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,It=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Jt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Jt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ve=RegExp("['’]","g"),ge=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Jt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[vt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[q]=Ae[ut]=Ae[F]=Ae[V]=Ae[G]=Ae[X]=Ae[Z]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[H]=xe[K]=xe[at]=xe[ut]=xe[q]=xe[F]=xe[ct]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[X]=xe[Z]=xe[Q]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[vt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Ie={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,qe=De&&De.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Je(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Ie[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Ir(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Jt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,Ie=Buffer?Buffer.allocUnsafe:n,Be=xr(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Jt&&Jt.now!==Ce.Date.now&&Jt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,qr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Jt.now,Yr=e.parseInt,Xr=te.random,Zr=oe.reverse,Jr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Jr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!ga(t)&&!(t instanceof gn)){if(t instanceof vn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new vn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function vn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function gn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=ga(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=qo(t),y=b==G||b==Y;if(Ea(t))return Ji(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case q:case F:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case vt:return $i(t,r);case X:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var v=s.get(t);if(v)return v;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var g=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(g||t,function(n,i){g&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Je,a=!1):e.length>=i&&(s=gr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Zn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Jn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Je:Ze,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function xi(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function Ii(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=gr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Zi=Lr||function(t){return Ce.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=Ie?Ie(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=vn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new vn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof gn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new vn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var qs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var Fs=lo(vs),Ws=lo(gs);function Vs(t,e){return(ga(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(ga(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Rn(t,r,e)});function Js(t,e){return(ga(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),gi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Ir(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|v;if(r.length){var i=Ir(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function v(){var t=ta();if(y(t))return g(t);c=os(v,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function g(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(v,e),l?b(t):u}(f);if(d)return Zi(c),c=os(v,e),b(f)}return c===n&&(c=os(v,e)),u}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Zi(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:g(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,Fa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&ga(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),va=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},ga=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&Ia(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||Fu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==F};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function xa(t){return"number"==typeof t&&t==za(t)}function Ia(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&qo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==Z}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&qo(t)==et};function La(t){return"string"==typeof t||!ga(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=qe?yr(qe):function(t){return Ma(t)&&Ia(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=qo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=Fa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function qa(t){return t?Ln(za(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):qt.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Za=so(function(t,e,r,n){io(e,ou(e),t,n)}),Ja=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:vr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function vu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ge,"")}var gu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var xu=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),Iu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=go(Qe),Nu=go(Ye),Uu=go(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Jn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function qu(){return[]}function Fu(){return!1}var Wu=vo(function(t,e){return t+e},0),Vu=So("ceil"),Gu=vo(function(t,e){return t/e},1),Yu=So("floor");var Xu,Zu=vo(function(t,e){return t*e},1),Ju=So("round"),Qu=vo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Za,pn.at=Ja,pn.before=ra,pn.bind=na,pn.bindAll=Iu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ga(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:qa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return ga(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=ga(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:vr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return Fi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Ii)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=xu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=vu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=ga(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=Fs,pn.findIndex=vs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=gs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&qo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":qr.call(t,e)},pn.kebabCase=gu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?qn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?qn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?qn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?qn(t,Do(e,2),li):n},pn.stubArray=qu,pn.stubFalse=Fu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zu,pn.nth=function(t,e){return t&&t.length?vi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=ga(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=ga(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){gn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new gn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},gn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;gn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");gn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");gn.prototype[t]=function(){return this.__filtered__?new gn(this):this[r](1)}}),gn.prototype.compact=function(){return this.filter(Pu)},gn.prototype.find=function(t){return this.filter(t).head()},gn.prototype.findLast=function(t){return this.reverse().find(t)},gn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new gn(this):this.map(function(r){return ii(r,t,e)})}),gn.prototype.reject=function(t){return this.filter(ca(Do(t)))},gn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new gn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},gn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},gn.prototype.toArray=function(){return this.take(j)},Yn(gn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof gn,c=a[0],f=u||ga(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new gn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new vn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(ga(i)?i:[],t)}return this[r](function(r){return e.apply(ga(r)?r:[],t)})}}),Yn(gn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,v).name]=[{name:"wrapper",func:n}],gn.prototype.clone=function(){var t=new gn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},gn.prototype.reverse=function(){if(this.__filtered__){var t=new gn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},gn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=ga(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof gn){var e=t;return this.__actions__.length&&(e=new gn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new vn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function I(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=I,x.all=F,x.reject=H,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=I,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function q(t,e,r){return k(t).dispatch(e,r)}function F(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(F(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return q(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===v(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=q,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=v.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=v.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),v.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=v.G15<=0;)e^=v.G18<>>=1;return e},getPatternPosition:function(t){return v.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return g.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)g.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new g);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):P(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=p(r,n,i,l,m,t[s[A]],f[0],u[A]),I=g(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(x=b(r,n,i,l,m,t[s[A]],f[1],u[A]),I=v(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(x=y(r,n,i,l,m,t[s[A]],f[2],u[A]),I=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(x=v(r,n,i,l,m,t[s[A]],f[3],u[A]),I=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(x=g(r,n,i,l,m,t[s[A]],f[4],u[A]),I=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=I}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,v=0;v<16;++v)r[v]=t.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((e=r[v-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var g=0;g<64;++g){var m=y+h(d)+u(d,p,b)+o[g]+r[g]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),q=c(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],Z=u(a,v,g),J=u(k,A,x),Q=I+G|0,$=m+V+y(Q,I)|0;$=($=($=$+Z+y(Q=Q+J|0,J)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+q|0,et=F+z+y(tt,W)|0;m=g,I=x,g=v,x=A,v=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+v+y(this._fl,A)|0,this._gh=this._gh+g+y(this._gl,x)|0,this._hh=this._hh+m+y(this._hl,I)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],v=u[3],g=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^v[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^v[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^v[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^v[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=g[o>>>24]<<24^g[s>>16&255]<<16^g[a>>8&255]<<8^g[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=g,f.delete=g,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var v=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var g=function(t){this.str=t,this.cursor=0};g.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,I),D=B.slice(I+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(I=0,P=f.length;I0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),I++):I&&(S.splice(T,1),I--);if(!_&&!E)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof c?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof c?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof c?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),c=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new u(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,c,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||u.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===u.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===u.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(u.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,c=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[c.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:c},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=v.AES.encrypt(t.secret,t.passphrase).toString(v.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=v.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(v.format.OpenSSL),t.recoverySecret=y(u.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=v.AES.encrypt(t.secret,t.recoverySecret).toString(v.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(u.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),c=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+c+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,c,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new u(e,t.identifier,u.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,c,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:u.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:u.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,c,f){var h={identifier:t,wallet_version:u.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:c||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||u.FEE_STRATEGY_OPTIMAL,s=s||{};var c=i.defer();c.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),c.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),c.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u={paths:r,two_factor_token:i};"string"==typeof e?u.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){u[t]=e[t]});var c={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(c.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(c.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",c,u,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||u.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:291,bip39:36,"bitcoinjs-lib":51,"bitcoinjs-message":80,buffer:130,"crypto-js":179,lodash:282,q:320,randombytes:327}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},u=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),u=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!u.length)throw new s.WalletDecryptError;return u}(t,e).toString(i.enc.Utf8)},c=function(t,e){return a(u(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=u,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(c(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=c,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:24,bip39:36,buffer:130,"crypto-js":179,q:320,util:263}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function u(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function c(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,u,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,bip39:36,buffer:130}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:24,buffer:130}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:130}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),u=t("create-hash"),c=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var c=o.parse(e,!0),f=p.qs(i.defaults({},r||{},c.query||{},this.params||{}));this.path="".concat(this.endpoint,c.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?u("md5").update(this.path).digest().toString("hex"):u("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=c(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:291,"create-hash":138,debug:205,lodash:282,q:320,querystring:326,superagent:367,"superagent-http-signature/index-hmac-only":363,url:379}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:282,q:320}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:28,lodash:282,q:320}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:282,q:320,superagent:367}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":51,lodash:282,q:320,superagent:367}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){c+=a.getLengthForVarInt(t)+t}),c+=a.getLengthForVarInt(s.length)),[u,c]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var u=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(u.m,u.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var c=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(c)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var u=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(u),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var c=n.script.types,f=[c.MULTISIG,c.P2PKH,c.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:24,"bitcoinjs-lib":51,buffer:130}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:28,lodash:282,q:320}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:291}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),u=t("./blocktrail"),c=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,u,c,f,h,l,d,p,y,v,g,m,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!m,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(c,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=u,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=c,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=v,this.upgradeToKeyIndex=g,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}function v(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function g(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new u.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=u.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=u.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=u.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=u.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=u.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=u.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new u.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new u.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(c.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(c.AES.decrypt(c.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(c.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new u.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new u.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new u.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new u.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new u.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new u.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new u.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new u.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new u.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=c.AES.encrypt(e.secret,t).toString(c.format.OpenSSL),n=d.entropyToMnemonic(u.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),u=s.script.multisig.output.encode(2,a),c=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&c===b.CHAIN_BTC_SEGWIT?(e=u,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=u);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new u.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new u.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new u.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new u.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new u.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new u.WalletAddressError("Failed to verify legacy address [hash mismatch]");var c=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!c&&!f)throw new u.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new u.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new u.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,c){var f=this;"function"==typeof e?(c=e,e=null):"function"==typeof r?(c=r,r=!1):"function"==typeof n?(c=n,n=!0):"function"==typeof o?(c=o,o=null):"function"==typeof s?(c=s,s=null):"function"==typeof a&&(c=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(c),f.locked?(l.reject(new u.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new u.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(v,"cashaddr"),n||a(g,"base58"),n)return{address:t,decoded:n,type:i};throw new u.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new u.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var c=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(c.address,e,r).toString("hex"),delete a.address}catch(t){throw new u.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new u.WalletSendError("Values should be non zero");if(a.value<=u.DUST)throw new u.WalletSendError("Values should be more than dust ("+u.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,c,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof c?(h=c,c=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,c=c||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new u.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,c,f).spread(function(t,n,f){var d,y,v=[],g=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*u.DUST&&r!==f)return e(new u.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=u.DUST)f=0;else if(!e)return g.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?v.splice(r.random(0,v.length),0,n):v.push(n)}t()},function(t){v.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(g.notify(b.PAY_PROGRESS_SIGN),r=0;ru.BASE_FEE)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new u.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?g.reject(new u.WalletSendError(e)):g.resolve([d,t])}),g.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var u=i.defer();return u.promise.nodeify(s),u.reject(t),u.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c=i.defer();return c.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){c.resolve(t)},function(t){t.requires_2fa?c.reject(new u.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?c.reject(new u.WalletInvalid2FAError):c.reject(t)}),c.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*u.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*u.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new u.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var c=s.script.decompile(a),f=c[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var h=c[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new u.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+u),c.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:u,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,u).then(function(u){return s+=Object.keys(u).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),c.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(u)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(u)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;pe?e:p.length,a=0,u=p.length;a=0;c--)if(f[c]!==h[c])return!1;for(c=f.length-1;c>=0;c--)if(a=f[c],!m(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&v(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),u=!t&&i&&!r;if((a&&o&&_(i,r)||u)&&v(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||v;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=v,l.ok=g,l.equal=function(t,e,r){t!=e&&v(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&v(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){m(t,e,!1)||v(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){m(t,e,!0)||v(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){m(t,e,!1)&&v(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&v(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&v(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&v(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||v(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":289,"util/":27}],25:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],26:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],27:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!v(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),g(n.showHidden)&&(n.showHidden=!1),g(n.depth)&&(n.depth=2),g(n.colors)&&(n.colors=!1),g(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,t,n.depth)}function u(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function c(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return v(i)||(i=f(t,i,n)),i}var o=function(t,e){if(g(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var u=e.name?": "+e.name:"";return t.stylize("[Function"+u+"]","special")}if(m(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var c,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return m(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?m(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),c=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),I(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=b(r)?f(t,u.value,null):f(t,u.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),g(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function v(t){return"string"==typeof t}function g(t){return void 0===t}function m(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(g(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=v,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=g,r.isRegExp=m,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function I(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":26,_process:291,inherits:25}],28:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,u=Array.isArray||function(t){return"[object Array]"===a.call(t)},c=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}c(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var g=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(g),o.rejectSeries=p(g);var m=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(m),o.detectSeries=p(m),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,c(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),c(r,function(r){var n=u(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};c(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(c(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){u(t)||(t=[t]),c(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;c(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&c(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],29:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*f+1>>>0,h=new Uint8Array(c);o!==s;){for(var l=e[o],d=0,p=c-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=c-i;b!==c&&0===h[b];)b++;for(var y=u.repeat(r);b0)throw"Invalid string. Length must be a multiple of 4";for(a=[],i=(s=(s=t.indexOf("="))>0?t.length-s:0)>0?t.length-4:t.length,e=0,n=0;e>16),a.push((65280&o)>>8),a.push(255&o);return 2===s?(o=r.indexOf(t[e])<<2|r.indexOf(t[e+1])>>4,a.push(255&o)):1===s&&(o=r.indexOf(t[e])<<10|r.indexOf(t[e+1])<<4|r.indexOf(t[e+2])>>2,a.push(o>>8&255),a.push(255&o)),a},e.exports.fromByteArray=function(t){var e,n,i,o,s=t.length%3,a="";for(e=0,i=t.length-s;e>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o];switch(s){case 1:n=t[t.length-1],a+=r[n>>2],a+=r[n<<4&63],a+="==";break;case 2:n=(t[t.length-2]<<8)+t[t.length-1],a+=r[n>>10],a+=r[n>>4&63],a+=r[n<<2&63],a+="="}return a}}()},{}],31:[function(t,e,r){"use strict";for(var n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i={},o=0;o>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function u(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var c=u(o),f=[],h=0;h=s.length||f.push(d)}if(1!==c)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=u(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var c=0;c<6;++c)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return c(t,8,5,!0)},fromWords:function(t){return c(t,5,8,!1)}}},{}],32:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)u[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)u[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)u[o++]=s;function c(t){return a.charAt(t)}function f(t,e){var r=u[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var h=f*(1<1?o[c-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(g,r)),BigInteger.ONE.dlShiftTo(c,g),g.subTo(o,o);o.t=0;){var m=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,m,r,v,0,c))0&&r.rShiftTo(u,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=c(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,g,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=c;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,v=t.t-1,g=!0,m=new BigInteger;for(i=l(t[v])-1;v>=0;){for(i>=u?b=t[v]>>i-u&c:(b=(t[v]&(1<0&&(b|=t[v-1]>>this.DB+i-u)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--v),g)s[b].copyTo(o),g=!1;else{for(;a>1;)n.sqrTo(o,m),n.sqrTo(m,o),a-=2;a>0?n.sqrTo(o,m):(y=o,o=m,m=y),n.mulTo(m,s[b],o)}for(;v>=0&&0==(t[v]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),u=o.slice(0,s),c=o.slice(s),f=u.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===c,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^v[u>>8&255]^g[255&e]^i[p],f=t[a>>>24]^y[u>>16&255]^v[e>>8&255]^g[255&o]^i[p+1],h=t[u>>>24]^y[e>>16&255]^v[o>>8&255]^g[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^v[a>>8&255]^g[255&u]^i[p+3],p+=4,o=c,a=f,u=h;for(l=0;4>l;l++)b[r?3&-l:l]=m[o>>>24]<<24^m[a>>16&255]<<16^m[u>>8&255]<<8^m[255&e]^i[p++],c=o,o=a,a=u,u=e,e=c;return b}function u(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],u=this.o[1],c=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:u[0][a[r>>>24]]^u[1][a[r>>16&255]]^u[2][a[r>>8&255]]^u[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],u=this.o[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,u=s.codec.base64.M,c=0;for(e&&(u=u.substr(0,62)+"-_"),r=0;r(i=u.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),c=i<<32-a):c^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,c,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=c+e|0,c=u,u=a,s=e+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15],E=s,S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=c.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),u=s.mode.ccm.s(t,u,r,e,o,a),c.concat(u.data,u.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,u=a.bitLength(r)/8,c=a.bitLength(e),f=a.clamp(e,c-o),h=a.bitSlice(e,c-o);c=(c-o)/8;for(7>u&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&c>>>8*e;e++);return e<15-u&&(e=15-u),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],u=s.bitArray,c=u.j;if(n=[u.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=u.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=u.bitLength(e)/8)?a=[u.partial(16,r)]:4294967295>=r&&(a=u.concat([u.partial(16,65534)],[r])),a=u.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/c),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:u.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var u,c=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=c(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,u=0;u+4i.bitLength(r)&&(u=o(u,n(u)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(u,n(u))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var u=e.slice(0),c=s.bitArray,f=c.bitLength(u);return a=a||128,i=i||[],a<=f?(e=c.bitSlice(u,f-a),u=c.bitSlice(u,0,f-a)):(e=u,u=[]),t=s.mode.gcm.s(o,t,u,i,r,a),c.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,u=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=u(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,u,c,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),u=1;ua;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=u),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,c,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,c,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&u("seeded",Math.max(this.n,this.g)),u("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=u.iter||64!==u.ts&&96!==u.ts&&128!==u.ts||128!==u.ks&&192!==u.ks&&256!==u.ks||2>u.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":345}],41:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],42:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":41}],43:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),u=t("./networks"),c=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||u.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||u.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":52,"./script":53,"./templates":55,"./types":79,bech32:31,bs58check:126,cashaddress:133,"safe-buffer":345,typeforce:376}],44:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),u=t("varuint-bitcoin"),c=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=c.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=u.decode(t,e),e+=u.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":46,"./transaction":77,"./types":79,"buffer-reverse":128,"merkle-lib/fastRoot":284,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],45:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":319,"varuint-bitcoin":382}],46:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":138}],47:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),u=Buffer.alloc(1,1),c=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(u).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(c.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=c.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),u=BigInteger.fromBuffer(t),l=c.n,d=c.G;return f(t,a,function(t){var i=d.multiply(t);return!c.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(u.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=c.n,s=c.G,a=e.r,u=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=u.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!c.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:c}},{"./ecsignature":49,"./types":79,bigi:34,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],48:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),u=t("./types"),c=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:u.maybe(u.Boolean),network:u.maybe(u.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(u.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=c.decode(t),n=r.version;if(u.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":43,"./crypto":46,"./ecdsa":47,"./networks":52,"./types":79,bigi:34,ecurve:219,randombytes:327,typeforce:376,wif:384}],49:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":79,bigi:34,bip66:40,buffer:130,typeforce:376}],50:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),u=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),c=t("ecurve"),f=c.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n);return new HDNode(new ECPair(u,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||u.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=c.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),c=i.slice(32),h=BigInteger.fromBuffer(u);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,c);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":46,"./ecpair":48,"./networks":52,"./types":79,bigi:34,bs58check:126,"create-hmac":140,ecurve:219,"safe-buffer":345,typeforce:376}],51:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":43,"./block":44,"./bufferutils":45,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./hdnode":50,"./networks":52,"./script":53,"./transaction":77,"./transaction_builder":78,"bitcoin-ops":41}],52:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],53:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),u=t("bitcoin-ops"),c=t("bitcoin-ops/map"),f=u.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===u.OP_0||t>=u.OP_1&&t<=u.OP_16||t===u.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?u.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?u.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var c=t.slice(r,r+a.number);r+=a.number;var f=d(c);void 0!==f?e.push(f):e.push(c)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==u[t]?u[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return c[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===u.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var v=t("./templates");for(var g in v)e.exports[g]=v[g]},{"./script_number":54,"./templates":55,"./types":79,bip66:40,"bitcoin-ops":41,"bitcoin-ops/map":42,"pushdata-bitcoin":319,"safe-buffer":345,typeforce:376}],54:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":345}],55:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),u=t("./scripthash"),c=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:u.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(c.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(u.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return c.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":53,"./multisig":56,"./nulldata":59,"./pubkey":60,"./pubkeyhash":63,"./scripthash":66,"./witnesscommitment":69,"./witnesspubkeyhash":71,"./witnessscripthash":74}],56:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":57,"./output":58}],57:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var u=Buffer.allocUnsafe(0);function c(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(u,t.map(function(t){return t===o.OP_0?u:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(c(t,e))},encodeStack:c}},{"../../script":53,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],58:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function u(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(t,e){var r=n.decompile(t);return o(u,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":53,"../types":79,"bitcoin-ops":41,typeforce:376}],60:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":61,"./output":62,dup:56}],61:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":53,typeforce:376}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":53,"bitcoin-ops":41,typeforce:376}],63:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":64,"./output":65,dup:56}],64:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":53,typeforce:376}],65:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],66:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":67,"./output":68,dup:56}],67:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),u=n.classifyOutput(s);return 1===r.length?u===n.types.P2WSH||u===n.types.P2WPKH:a===u}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":53,"safe-buffer":345,typeforce:376}],68:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],69:[function(t,e,r){e.exports={output:t("./output")}},{"./output":70}],70:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function u(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(t){return o(u,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,"safe-buffer":345,typeforce:376}],71:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":72,"./output":73,dup:56}],72:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":53,typeforce:376}],73:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],74:[function(t,e,r){arguments[4][56][0].apply(r,arguments)},{"./input":75,"./output":76,dup:56}],75:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":67}],76:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":53,"../../types":79,"bitcoin-ops":41,typeforce:376}],77:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),u=t("typeforce"),c=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),v=Buffer.from("ffffffffffffffff","hex"),g={script:d,valueBuffer:v};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function u(){return n(a())}function c(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(c.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function u(e){i=t.writeUInt32LE(e,i)}function c(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){c(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),c(this.ins.length),this.ins.forEach(function(t){o(t.hash),u(t.index),h(t.script),u(t.sequence)}),c(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;c((e=t.witness).length),e.forEach(h)}),u(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){u(c.tuple(c.Number,c.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){u(c.tuple(c.Number,[c.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":45,"./crypto":46,"./script":53,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376,"varuint-bitcoin":382}],78:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),u=t("bitcoin-ops"),c=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function v(t){return-1!==d.indexOf(t)}function g(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,u,c,f,l,d,p,b=!1,g=!1,m=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(m=!0,u=w[w.length-1],l=s.classifyOutput(u),r=s.scriptHash.output.encode(o.hash160(u)),n=h.P2SH,a=u);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(c=e[e.length-1],f=s.classifyOutput(c),g=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(c)),n=h.P2WSH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(c)),!u.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(c)))throw new Error("unsupported witness script");a=c,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==u)throw new Error("Redeem script given when unnecessary")}else{if(!u)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!u.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(u){if(!v(l))throw new Error("Bad redeemscript!");a=u,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return m&&(A.redeemScript=u,A.redeemScriptType=l),g&&(A.witnessScript=c,A.witnessScriptType=f),A}function m(t,e,r){c(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],u=o.hash160(r);a.equals(u)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,u,l,d,p,b,y,v,g,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,v=b=a.scriptType,g=i}else if(r){if(w(t,p=o.hash160(r)),!(a=m(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');u=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,g=r,E=(v=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=m(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');u=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,v=b=a.scriptType,g=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(u=t.prevOutType,l=t.prevOutScript,!(a=m(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,v=u,g=l}else a=m(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,v=u=h.P2PKH,g=l;if(void 0!==n||E){if(c(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}v===h.P2WPKH&&(g=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(g))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=g,t.signType=v,t.prevOutScript=l,t.prevOutType=u,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||u.OP_0}),n||(e=e.filter(function(t){return t!==u.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(c(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){c(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,u=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,c){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!u.verify(f,h.signature)&&(o[c]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=g(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=m(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!v(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,u=e.getPublicKeyBuffer();if(!k(s)&&(_(s,u,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!u.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":43,"./crypto":46,"./ecpair":48,"./ecsignature":49,"./networks":52,"./script":53,"./transaction":77,"./types":79,"bitcoin-ops":41,"buffer-reverse":128,"safe-buffer":345,typeforce:376}],79:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:376}],80:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,u){Buffer.isBuffer(u)||(u=new Buffer(u,"base64"));var c,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(u),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(c=d,f=i("sha256").update(c).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:83,buffer:130,"buffer-equals":127,"create-hash":138,secp256k1:347,"varuint-bitcoin":382}],81:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;u>0;)i.push(255&u),u>>=8}for(var c=0;t[c]===n&&c0;)n.push(s%r),s=s/r|0}for(var a="",u=0;0===e[u]&&u=0;--c)a+=t[n[c]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],82:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":81}],83:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:82,buffer:130,"create-hash":138}],84:[function(t,e,r){(function(r){(function(){var n=t("async"),i=t("lodash"),o=t("fs"),s=t("./branding-logo"),a=t("./qrCode-browser"),u=t("./pdf_writer"),c=t("bowser"),f=function(t,e,r,n){var o=this;e=e||{},r=r||{},n=n||{},o.identifier=t,o.backupInfo=e,o.extraInfo=r,o.network=n.network||"Bitcoin",o.options=i.merge({page1:!0,page2:!0,page3:!0,brandingLogo:s},n),o.blocktrailPublicKeys=[],e.blocktrailPublicKeys&&i.each(e.blocktrailPublicKeys,function(t,e){o.blocktrailPublicKeys.push({keyIndex:e,pubKey:t,path:"M/"+e+"'"})})};f.saveAsSupported=function(){if(c.browser.ios||c.browser.blackberry||c.browser.firefoxos||c.browser.webos||c.browser.bada||c.browser.tizen||c.browser.sailfish)return!1;if(c.browser.android){if(!c.browser.chrome)return!1;if(c.browser.version.split(".")[0]<41)return!1;if(c.browser.osversion.split(".")[0]<=4)return!1}return!0},f.prototype.generateHTML=function(t){var e=this,s={identifier:e.identifier,backupInfo:e.backupInfo,totalPubKeys:e.blocktrailPublicKeys.length,pubKeysHtml:"",extraInfo:i.map(e.extraInfo,function(t,e){return"string"!=typeof t?t:{title:e,value:t}}),options:e.options};n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);var a;i.each(e.blocktrailPublicKeys,function(t){s.pubKeysHtml+="

",s.pubKeysHtml+="KeyIndex: "+t.keyIndex+" ",s.pubKeysHtml+="Path: "+t.path+"",s.pubKeysHtml+="
"});try{a=i.template(o.readFileSync(r+"/resources/backup_info_template.html",{encoding:"utf8"}))}catch(e){return t(e)}t(null,a(s))})},f.prototype.generatePDF=function(t){var e=this,r=new u,o=function(){r.YAXIS(30),r.IMAGE(s,"jpeg",154,30)};try{r.setFont("helvetica"),o(),n.series([function(t){e.options.page1?(r.FONT_SIZE_HEADER(function(){r.TEXT(e.network+" Wallet Recovery Data Sheet")}),r.TEXT("This document holds the information and instructions required for you to recover your BTC Wallet should anything happen. \nPrint it out and keep it in a safe location; if you lose these details you will never be able to recover your wallet."),r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Identifier ("+e.backupInfo.walletVersion+")"),r.HR(0,0)}),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(e.identifier)})}),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info"),r.HR(0,0)}),e.backupInfo.primaryMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Primary Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.primaryMnemonic)})}),e.backupInfo.backupMnemonic&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Mnemonic")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupMnemonic)})}),e.backupInfo.encryptedPrimarySeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Primary Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedPrimarySeed)})}),e.backupInfo.backupSeed&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Backup Seed")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.backupSeed)})}),e.backupInfo.recoveryEncryptedSecret&&r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Encrypted Recovery Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.recoveryEncryptedSecret)})}),r.NEXT_PAGE(),o(),r.YAXIS(10),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("BTC Wallet Public Keys")}),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.blocktrailPublicKeys.length+" in total")})}),r.YAXIS(20),n.forEach(Object.keys(e.blocktrailPublicKeys),function(t,r){var n=e.blocktrailPublicKeys[t];a.toDataURL(n.pubKey.toBase58(),{errorCorrectLevel:"medium"},function(t,e){n.qr=e,r(t)})},function(n){if(n)return t(n);Object.keys(e.blocktrailPublicKeys).forEach(function(t,n){var i=e.blocktrailPublicKeys[n],o=n%3;n>0&&0!==o&&(r.YAXIS(-180),r.YAXIS(-3)),r.IMAGE(i.qr,"jpeg",180,180,180*o),r.YAXIS(3),r.FONT_SIZE_SMALL(function(){r.TEXT("KeyIndex: "+i.keyIndex+" Path: "+i.path,180*o+20,!1)})}),r.YAXIS(20),e.extraInfo&&i.each(e.extraInfo,function(t,e){var n,i;"string"!=typeof t?(n=t.title,i=t.subtitle,t=t.value):n=e,r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT(n)}),i&&r.FONT_SIZE_SMALL(function(){r.TEXT_COLOR_LIGHT_GREY(function(){r.TEXT(i)})}),r.YAXIS(3),r.FONT_SIZE_NORMAL(function(){r.TEXT(t)})})}),t()})):t()},function(t){e.backupInfo.encryptedSecret&&e.options.page2&&(e.options.page1&&(r.NEXT_PAGE(),o()),r.FONT_SIZE_HEADER(function(){r.TEXT("Backup Info - part 2"),r.HR(0,0)}),r.TEXT("This page needs to be replaced / updated when wallet password is changed!"),r.FONT_SIZE_SUBHEADER(function(){r.TEXT_COLOR_GREY(function(){r.TEXT("Password Encrypted Secret")}),r.YAXIS(5),r.FONT_SIZE_NORMAL(function(){r.TEXT(e.backupInfo.encryptedSecret)})})),t()},function(t){e.options.page3&&(r.FONT_SIZE_HEADER(function(){r.TEXT("Wallet Recovery Instructions"),r.HR(0,0)}),r.TEXT("You can recover the bitcoins in your wallet on https://recovery.blocktrail.com using this backup sheet.\nFor a more technical aproach on how to recover your wallet yourself, see the 'wallet_recovery_example.php' script in the examples folder of the Blocktrail SDK.")),t()}],function(e){if(e)return t(e);t(null,r.doc)})}catch(e){return void t(e)}},e.exports=f}).call(this)}).call(this,"/node_modules/blocktrail-sdk-backup-generator/lib")},{"./branding-logo":85,"./pdf_writer":86,"./qrCode-browser":87,async:28,bowser:102,fs:240,lodash:89}],85:[function(t,e,r){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/8AAACpCAYAAAB9PY0hAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQl8VcX592fOvTcJu7IokAQSQBIIohbcW0lYRFFECLGuFWvVvq1au/0VUHtbNrXW7nWprfuaBFQERJaA+4YoEEgQSCAhIIiyBXKXc+b9nWAsSxLucpaZe5/jB5OcM/M8z3zn3HPPM/PMM5zRQQSIABEgAglHwO/3ay98eqBduKFtGyMcaiO8RhsmUtM0FvIaYc3j4YbH4JqHCfyfsbAuNN1j/vTquiY8utBFUPOJA2ncV18fYAeql/kbEg4SNYgIEAEiQASIABEgAklEgCdRW6mpRIAIEIGEIpBX5E9p2BPsr+tskDDYQMZEHyZ4b85FL8FYOhMM/rw1B+c8KJj4igu+BbI34Mtjg8b4BsPLNrbz+NaXL/R/bY0mkkIEiAARIAJEgAgQASJgBwFy/u2gSjKJABEgAhYTKCp62fPJV6sHCRE+hzF+juDsLDj3/eHwey1WFZM4fJlUC8Y/4ZpYoWmeT9qltluxet7kb2ISRpWIABEgAkSACBABIkAELCfAs/L9J1guNUkFat6DQvO1ER788+49KDp266jvZXv1gWygXlx8hZ6kWKJu9rlFD7XZ9c3eHgGhn6wJwxe1AKqgLAHuYQc2LZrxibINsNjwfiMmDwwL7UKE5o8Sgl8AR7+9xSrsFIfxCf45ogUWYzBgUfcund9+v/hXB+1USLKJABEgAkSACBABIkAEWibAe+dPRgQnHXYTwKxYCG/CO/FzJ3R9KZhWozGxGb9vNjTPFx7ebu2mxXftsdsOGeVnXe4/QewJjuFMXIabcSRmM7vIaCfZZD8BOIvrqpfNRPh6ch75fr93yzvhfCNsFOJ5MZYJkZ4oJDhnAXy+39W4Nkek+Uqq5/u3J0rbqB1EgAgQASJABIgAEVCBADn/MvUSZ3VwflZjhu9jjeOfz/vBxjf9O2Qy0Upb8kb7Ox8IBadgrfLPMTuYZqVskqUmgWR0/gU+8H2HTx1uMHENwubHweHvrGbvRWE15wYGQt9Ge1/2+nwlifyci4IKFSUCRIAIEAEiQASIgK0EyPm3Fa8FwjlfCyllcIoWdWnvW7Rirv+ABVJdF5E9fMptcHqmCcE6uW4MGSANgWRy/rMu8mexYHASIl0m4bPQW5pOcNwQHobKV7ya9vCGJdPKkFiQotEc7wNSSASIABEgAkSACCQDAXL+1eplc73sEkQFFLftmjK7vNi/Xy3zGcua5E8TmwOPweG5TjXbyV77CSSD89+nYMoIXYg7QPMS/MMEOB1NBLA0YD2QPKJ5Ov43WZdBNbGgn0SACBABIkAEiAARsJoAOf9WE3VKHucH4DW8gszaj1QtmfW2U2rj0YNtydrXfxVYjNn+s+ORQ3UTl0CiOv9Dbn7U99UXm6/jcPoxrX1q4vagNS3DIMAeIbS/t/G0+0vFkim7rJFKUogAESACRIAIEAEikNwEyPlPgP5HmOwqxrW/dOmX+eyKx24Jydgkv9+vPbks+ArW9o+V0T6ySQ4Cieb8m07/119suQH3/ZTkDu2P9f7i+xEb8bDXl/Ig5QWIlSHVIwJEgAgQASJABIjAIQLk/CfQnYDZsi14Ub6vS7+sx2UbBOhdMOUBJDL7bQLhpqbYQCBRnH9zsOupZYEbBOf3kNNvxY3C9+P5NpP1Tvlz9ZP+BiskkgwiQASIABEgAkSACCQbAS3ZGpzI7UU4fS9kzv/XrvWby3sPnzpelrZmjZpyOmz5tSz2kB1EwE4CfUbePfLJ5cGVBmOPk+NvFWnRHixnss3BiuyCKVdYJZXkEAEiQASIABEgAkQgmQiQ85+AvY0Q41OYYczOKpjyRs6Fd2e73UQRFn/CrD/da253BOm3lUD/kf4+iHB5XQ/ri+CoDrZVWZIKNwdTDCFewrNteZ8R/v5JioGaTQSIABEgAkSACBCBmAiQQxYTNjUq4UV5dEPIWJM9fOqtblmcPWLKKGT2H+6WftJLBOwmkO/3e7OGT74rEA6swSCXmcGfDpsJ4Nl2gaEHP0cUwG+Lil722KyOxBMBIkAEiAARIAJEICEIkPOfEN3YSiOEaGsYxt/NGcn+Y/1dWylpyyWhs6ttEUxCiYAEBDCwdlb1ssCnWG4zC+a0kcCkpDEBEU5piAJ44OOdK9/vN2LywKRpODWUCBABIkAEiAARIAIxEiDnP0ZwylXDjGRwf2BF75H3nOGU7Wamc7ygj3NKH+khAk4RMGebs/Kn/M4wxLu0dZ9T1JvXA/5nhnT2SXb+5BubL0FniQARIAJEgAgQASJABEwC5Pwn0X1gJgRkuv6OU8kAd31RfR7wnphEiKmpSUCg72h/v4+/WgmnX/gZE94kaLIKTWxjJljsnT/lmbwif3sVDCYbiQARIAJEgAgQASLgNAFy/p0m7rY+LANgwijOHj7lJ3abwjk/xW4dJJ8IOEkge8TkiXoAYf6Cne2kXtIVKQFxbf1XwU96j7x7QKQ1qBwRIAJEgAgQASJABJKFADn/ydLTh7dTMA/Clf+dNfzuGw4/bfXvhsF7Wy2T5BEBNwiYSf0wYPagobNihJl3cMMG0hkZASQDzOG6/n5jstHIqlApIkAEiAARIAJEgAgkBQFy/pOim5tvpDCMx7Bl1ujmr8Z/lnMjM34pJIEIuEvATJRZvTy4BANmv3bXEtIeKQFEZnTCQM38rOFTfxppHSpHBIgAESACRIAIEIFEJ0DOf6L3cKvtE168JJdkF9xzWqvFYr0oeGqsVakeEZCBgLmXfGBf4H1zazkZ7CEboiGA55thPGxGbKD/eDQ1qSwRIAJEgAgQASJABBKRADn/idirUbVJtBdCL6YkWVFBo8JJQADb+F2gG8H30dR+SdDchG2iGbGBJU7/9vv99H2XsL1MDSMCRIAIEAEiQAQiIUAvQ5FQSvAyyFp+yv6dwYcTvJnUPCIQMYGsEZMvx2zxIiZE54grUUF5CQjjxieXBZ8zczfIayRZRgSIABEgAkSACBABewmQ828vX4Wki2t7F0y5WiGDyVQiYAsB83MgdF4M5z/FFgUk1BUCGOS8snp5oHTIzY/6XDGAlBIBIkAEiAARIAJEwGUC5Py73AEyqedC/Knfxf6OMtlEthABJwlkD598E/Q9w5igGWInwTukCzlOLtv1xebnaAmAQ8BJDREgAkSACBABIiAVAXL+peoOd43BFmbdwwcDv3fXCtJOBNwhYG59aRjsUYT603PRnS5wRCsiOoqeXB78NyUBdAQ3KSECRIAIEAEiQAQkIkAvuRJ1hgymCMZvNTOcy2AL2UAEnCKQlT/1h0IYj0MfZYV3CrqLeuD4/zi7YMpDLppAqokAESACRIAIEAEi4DgBcv4dRy67QuE1jOCdsltJ9iUsgT1Ot6zPiLsvZcx4hmb8nSbvrj5EOt2RVTDll+5aQdqJABEgAkSACBABIuAcAXL+nWOtjiYhrsPa/wx1DCZLE4YAZ1ucbEufUVOH6obxEhxBSgLnJHhJdKHfH8SWjmMlMYfMIAJEgAgQASJABIiArQTI+bcVr5rCTUdIDwTvUNN6slplArj3NjtlP5y+3kbImIsZ/7ZO6SQ9khFAfgfDEM9nF9xzmmSWkTlEgAgQASJABIgAEbCcADn/liNNDIHIin1tUdHLnsRoDbVCFQKaxlY5Yau5q4UhjHkYbOjuhD7SITMB0V4IfW6/iyd3k9lKso0IEAEiQASIABEgAvESIOc/XoIJWh8JsU7+5OvPhido86hZEhJApr2Q6JDyut2mmVneww3Bp5lgeXbrIvlqEBBMZIYPctoCUI3uIiuJABEgAkSACBCBGAmQ8x8juGSoJgxxTTK0k9ooCwG+uPoV/267rckeMeVODACMs1sPyVeLAAYARj25PPQ7tawma4kAESACRIAIEAEiEDkBcv4jZ5WMJS9OxkZTm90hILgwt9qz9ehTMGUElrRMt1UJCVeWAAYA7s4efveFyjaADCcCRIAIEAEiQASIQCsEyPlvBU6yX4KTdFLWhZNzk50Dtd8BApy/u7ls1mw7NfUf6+9qCPEswv0pl4WdoBWWzYUo5x5WpXATyHQiQASIABEgAkSACLRIgJz/FtHQBZMAD2kXEAkiYDMBoXH+K5t1sOD+4OOU4M9uygrL5+yZLh1Sz9m0aPoXCreCTCcCRIAIEAEiQASIQIsEvC1eoQtEAAQQBns+fjxGMIiAXQQ447+vWjrjI7vkm3Kzh0/5CbZ0o3X+dkJWVDbnPMi4uKN66ayHHdtnUlFWZDYRIAJEgAgQASKgNgFy/tXuPyesp7B/JygnqQ7O2QvVZTN/b2fz+4z099LDwT/bqYNkq0kA998WTfNM3LRk2sdqtoCsdpPA2fN3ddx7MNAPg0ddmDDa64y354K1x7B5e+xe0vhTMG6+ZwWY4AGmGQFusAaEOn3DhbaDc7HTy3w7UlL07SvG9jzgZltId/QEzJ1jTn+9tmcgxPphmWQ/ZoieiJdEv/P2ghntMbDYDlIb7wP8bIPZlAOM83r8vh8TK/s1xvejHv4W+7EYrdajezcIzbdhXWG3bdFbQzWIwPEJnDlvR/d9oVAfzRDpwjC6Gpx1xTOpE+7BFDyrUpiG55UQISyBC3GuNeAW382ZsRu/f6VzvlVjgdqTO2dvXVbAw8fXlhglhsyt69pw0MjQuZ4hPLybZmgngNUJjOnmZx3chBefa18jN6YdBEs87/Gc5+yApvEvhW5s9/n4Nm/Qu33lFT12ykCFnH8ZekFiGxAm3U9i88g0hQngxehV1jvlx3Y3QdeD/zJfxu3WQ/LVIoD7b2Ga1v6aiiVTdqllOVnrNIH+JXW5nBuD4NCfIgx2CmPGKfhuPOWb+vqTj7QFr4Hfnmj6iWfP/84Y3/5lmOX0xj90jAsEGhjLKd5ShxdJc8nJF4yz9Xjp/rTDCW0/WTGq854jddBfbhAYXFqbEWTiAvT/aWbf417ol1ta2xcDAG2PtMfs70N9jmtHXjL/Ouyc8d29gfO4HcL4jxlhllNScwCXNqL2BgxQbtA08alPaO+sKsyoPVYgnSECzRPILxPeL7+uOU8XPB+DksPwXDlzz4GGDmZpPIoOHbjJDt2luKPNA88m84Bz++29euhvDG42FtSZl9Xtqgn0L675HMU+ROTm22287RZ9Nv5E23dqajTM5v+ZA7q76xsKMFB7LiAMxWd46L6GcCcTB57PjZ9T/X/0cK6JTxO378ge4qUfOh8ICRbgIda/ZAsGU/iH6I8PhId90Ia3/8ANdrx3/uRvLbeZqBXiMerEmTBvOKcPjISxFPQ7Rm55Zyjvhq9ujPokx9GxXcfOq+dN/iba1mblT3kBnK6Mth6VT3gCAqPI06qWTvfDAbP1+ZNdMOUKJPl7KeGJUgMjJwAvDl++0ycN8/3e7/cf9k0duQgqmbgEzNncgXNq8nSDDeOCD8PszTA4bCe50mI8H/G6aQ4IfMQ09kZKSof5qy89IervYldsV1zpgJKaU/CggLMvLkAf/ABfVNluNwl2VGGG8R38fNtgnrfXT+xZ4bZNiaLf/NyPWYD3fIeOLb2ZKM/DkjOLjyIhPGtmb71IF0YRnh5j8Q5u+iw2HxxBAeIDOMfFPl/Ki2vGnfylzQotFZ/3ak0/PcivwI5Tl0DwWbgXHJsYxztwGPrKNE0r9Xp9rzjFTinnHyOgT1WXzZpkaa/HKKzPyPs66ay+Dzf00zCQOxQuzAh8yBIyRB5RQKdXlU2LetCFnP8Yb64EroaXltVc8/wGjv+bdjfT/Iwa4T0VeGnrbrcukq8IAc6/xj14NZaaLFTEYjLTAQI5r+7soOmB8bouLsd7xgV4GevigNqoVZgviqi0HDa+6knxvFo+tueWqIVQhWYJ+IXQXiypvQAO/1UIeb5Mie8NznegMa9yjb84eHz68mLOET9Ax/EImJ93Hm4Yi3f34ZiePQM/+2JQpSMG+fD14NixZ31RL8smEdGmnjzUcAsm7m9Em9Ida8UxinAPcrZQY+Jv6woz37R7gucY9RGeGLLo6071e+t/hGf9JPT/9yKsZnMxc2KCLWNM+9tVE3vOxeyYbZMT5Pxb2JU5F96d3RA0rkZ0wk/wxZFloWhXRXm82g82LZ7xTrRGkPMfLbHELY8H2mp8CTx4/bCUZ52abe1dMOUBfJn/NnGpHr9lcBICeBatwUy3OXi3AbOHVR6sNTYE34VBmIOGjwV5IJwqvEYbj87b4pumC8L+eiE0oxcGM/uaL0aIeupzfE3yl8A9+DHXtCIkl9wsv7Vkod0EhnwifPXVdRch/P4avPNfhnu9jd06rZaPz/enCM991ef1lpRf3mOt1fKTQd7Akpqz4TFfhf6/Ak5AD4Xb/CUc2GKmeV6qHN/jXVmdLjf55s6u7Y9IjjvRz2Z/u/15t8T5z3ltezYLBO/EsMUkfFenusn3GN2crdMYm4ZBgBdluR9zXt2aw4LGbzBAcTUc/6OW7BzTAhdP8A3IJfOXtA4pT64a3d3ME2LpQc6/pTgPCcv3+72blwevxov0TDgfLo7AWdM4fGgvimWmLKtgylN4GF1hjRVuSBEeOE4+NzTHqhMOTgihV66N/iNsSkcUjJnQZBscyDr8/nZqivZa5ZvTq2JtUyz1zIG4QEhfhy95ub4MY2lMtHU4/xROwVyE4S1p2zn1w/Jif1yhhadeMuvEfQf2nQUzRuPzfLGKEU4Y/HjE26b7HRsW3B6IFieVTywCuXPqhohw+CY8J4ucCYl1hh++pxfC+bu/sjCjzBmN6mo5Y/62bgfrwz9H//8I3/HZ6rakBcs5r0XI95O+FN8/nAojbsESKU4jYVvbfQ3GH/Cd+As4fI6FdB+n8XE5/3lv1HQO72f3wsf4mezvqXg2rUJY+2/WTUhfdBwmtl0eMHvLIEPn94JVIQZ+MCahxoF3uW1gd9fa8enPWDmAQs6/jf2fV+RvX78z+Hd8wUyyUY3toj1cm7ipbEap7YokU5CdP+XnSMjzD8nMatUczOb+uHrp9CdaLZQEF3vnTynGA35iEjS1sYn4gtiBF/8nvEz794al0zfa2e4+o+4+RQ+JHyEiDSFzrJeduuKWzfkBfMv/v6qymU/HLYsEKE0gZ3btcGS3nowBrJFKN+Q4xuMF8WMMAt9/ZWHGHL+NYaPHMUPKy43r+Jn4FZ5bk2BgmpRGWmkUIr8w8PmsT/P8ac2EnuusFK2KLHOmV4T0Unzu8ySzOSbnH4MXfMDsrTfhWXYfHNkTJWvTcczRXvS1Tfll+SUnbT9OQcsum8shWKjhD/jM36CS038MAM4/RCTAbesLe318zLUYTigz+hFD21yvghm3/dXLZt6AURulQ4+F5np4lOt9SQaoQyB7+FTMUieH44+X/JV4vlzR5ZSsjOqlM++y2/E374JNi6Z/sXnZjHsmDUvN9nB+KV4u35bx7oBdX3g8nnPI8Zexd5yxqfFFubRmPDJTf4jtlpYkuuNvUkWbz0SS05IXSmsrcktqbrp4vki+6Kejbq8BpbXn9C+pKUXi7Qo4AT/F5cR3/BtvBpaK++HGoKGX4zPwem5xTf5RaBL6z7w5NWexkPGuhI5/TNwHzfmyb25JbZlhGI+q5/ibTTauDB8MrMkp3YplVvYeZuLD3NItv2bBBuycIm5U2vE3UQlxNjP4BzklW6abbYuXHjn/8RKMoD7WmD6IF1F/BEXlLGKwuMKG5WwUWZWoBIQwfpeobfuuXZxv5B5+FRzbIXi+FK947BYs93D2MHM3bCqbOQ8DnBd4Ne18DEQsc9aClrXheTvH2yZl6KbF01a3XIquJDIBODoTckprynVDzMabk7lsJakOvPCegkGAxzYeqP0Czu8lSdX4bxubN7v2NGybt1Q3jPfx8jxBeQcg1k5sTGQnLkEkYxm2lHzbXPoSqyhV6g0s2ZYXDos38DmQMnlntBxxH18b0oMrEUk8LNq6MpU3+0MY+qtoz1/NrQjtsC1vTu3pq0prPjIM9iB4tbNDhzsyMRUr2NTPS2uXnja3Jq4l5eT8O9SDVWUz/oCw3CUOqbNWDecHrRVI0oiAPQTMWX88HMfYI10KqQcZ137d9ZTeA6qXzJQmic7GpTPeq142q4B72HhQ2uAaKc50jfP/w4DEhA0L/Htds4MUu0bATOqFF8s34OiYob4DXDNEFsVCZML5fb1/ce0Lg2dvP0kWs+y0o//cuq6YIXs4pItP4WwU2KlLNdmYMf6+oesf5xTX/jdv3o6E3AnHzOYfFuFX1JwdP/KOMiN38Dz7D+7jZ/Cvw5FX1f0Lbbm97qua+WbWfataAZkcrH4bDhsf4j1Qkgz+VrXuMDlCXNDQwD7rP7vu+4edjepXcv6jwhV74cZEDR7tNgwA2LZ1Q+zWtV4T28iQ8986IroqCYFEnvXHuv4PNe45Y3PZjIfcmOmPpIurl8x6hWelnsq59gCy6TqaeBKRB9vxbwSiIf4Yia1UJrEImEm9+pdumYHw/tV4CRydWK2zojXGlQEjtHbA7NofWSFNRhnmTCJe/m/nDWGE+prh/eok9nKUJ5wkwYwbEIK9Pqe45s6EWxoSbHgIfd/PUaY2KBtQurMHIneW4Xn2YxvEyyBy1P499e9YMShpJvHMLa1dBFYPYNAnRYbG2WkDIhq6Yqv5hbklW2L6riPn387eOUr25sXT1+HldO5Rp+X/k4vd8htJFiY7gX4F9+Ql6Kw/dvHh/jO7nnF+Vdn0Stn7ufpJf0N12Yw7Na6dhwGAcifsBZ+326Ty71WXzVruhD7SIReBnOKt4/Y36OuYwaYkw4tfrPTxYtxF142n+hdvebNxi7BYBUlYz5wFw0zi52jjXxNhxtcJxGDVAU7EfRsP1JQnSj6AnJK6ofjCxBpvtY/+JXW5hmgwl6uco3ZLWrce9+AgDEouNwc6Wi/Z8lUM+p5ZfyC8ArJGtFwq8a6gvW3xzvsacrsURts6cv6jJRZvecFfiFeE0/UNn6/WaZ2kjwhESyAk9DuirSN9eWSrx24bRQhj/31x8RWOzqTHywa5CD7ypfUYomn8T3ZGPGmcPZSVnzJ83cKZ2+K1meqrRQAzvWlYw/yIYDpCfIXcO0/IhXYUC4RWm4MmcpkVvTWNib1Kan7PdH0Zag+MXgLVwPKYvghJXQInYtaQT4RS2xsf23thc/s7zLOpe5iJCrFr8rtw7nqr24rILUc7zYGON2NZAoAt/K7E/fs2+jwzco2JU9Ic7DYEeym3ZOvYaFpFzn80tCwom+Zpt9gCMY6JwBM0VDXvd186ppAUEYEYCPQf6++Ke/XaGKrKW4WzOi/zXKDyNpsbFtweqFo68zcezXMO+mellbCxlGqvuQ1pVdmsXy/z+8NWyiZZ8hMw1/bX7ar9AC8/t8hvrXwWmomwEPo9O7d4y2/ksy4yi3LnbMtaVVr7FhIb3osw77gzYEemNVFLCQ0c79pfXfOeuSWiiq3Mm1vXSzB+qYq2N9lsJmMMhcWb+Hx2bjqXDD8xADAISwBeySsXEYfsYwePu3SDPw/nPzUZGLXcRuHBktfnzQSnLZc58go5/0fysP2viiVTduGlVRlnWnC+pTFfge1kSAERiJ1AYF/wFnxZJs72TZxv9XHPBRvLpq2InYo8NTctmfbxpPzUoYgAMMMx444kMsP8WWrKaSoPjMjTO+pZkjO75hqhixWY7Yn4ZUe9VjphMRw+xv6Idd//Vm3GF2tdrzLCoc/gNJznBKlk0YEw4qGYSVyJnTKUC50PB/QfqjzrbzpvIqy/iXutU7Lcb4e3E5/l/PDarX8+/Fxzv6Mcx9aVf0Nfz1K5v5trW6zn8P7bPmSIuZEm8STnP1bS8dQToi6e6k7WxWzd507qI11EIFoC5hcB44mTEMccHNSYNmLD0ukbo2Uhc3lza8DNZTP/275bal/kA7glpnwAnG3SNO1H2D1lWPUb/mqZ20u2WU/AdFBNRxWO/7Pmy471GpJTIlj+ZH9V7Runvr77RNkJNCb1wz0AB/V52JqUTpLdfYT7oZ0wxOPIDfGUWoNCYqTdbOyS37g1oS4Wg31SzfgfzRPRSD8zB/aOPt/096FlPlv/g0if25rO0c9vCWDpQ/hgQ4lfHD/RKTn/rtw1fL8ramNQyrlYGUM1qkIEHCOQPeqeYQj76uOYQjsVcf61x8dGqpDYL1YM5cX+IJz3xzaXzRrEPN7zzDX7jPE1kIcI7mMPjOzsRsRAKdO0CdnDUnOQS+AZikY6llOinxm8cHs7OKivmY5qorfVjfaB6/DgwX3vD5rzZV839Eei09zCbduumnl0D0RCy5IyPzIHhWJZi22J9qiF8CFRV5GggrlcQRch0/HvKoE5rpuAgb1HBr2y9Zg1/KZTu6qk9ilzpwrXjZTUAETunP9iSc2vjmee93gF6LotBJRJqCK45xNbCJBQImARAaHrP7ZIlLtisA2oprErN74503SEk+LYvGTa+2io+Y/lXHZ/h/C+/f3DXD8Jg46pmsH3IUKg+toLvFVm1IBZZvNS8/90JBsBrO/v0rAvNA/jQ2cnW9udbC+cj5ygHizDi/f5ay5Pr3FS9/F0wfHvKUIN8zFEeNrxytJ16wiYg0L79ux/Fw7qmPKxPbdYJ9laSUUvC8/noqaLtVLtl5ZXtqN9eFdgLka+u9uvTRkNHUNh41FYO6bJYjPCE0ntHsf9eE3TOfrZPAG8LE3LeXXr3Mpx6S3uDkXOf/PsbD2LIOWOzc9x2ao2auGYXQt29HR6O+qKVIEIOERg8IV/bLcn9A22OWl20tghK6xRA4d3atWSWYuskaaelMrX7twHq4/JceAnh1+9zrTQYnMGKBjWF+IjPsBCsSSqJQIIHTV5Y8DlBxUTMna1VMzJ88joPUhvdPyTM6O3k6yb1SVYXjgQ/mBgydZL1k5MlzIadFMfprGqZq2X9qQ5k/1CSc1zeHsZLK2RLhkGZ/9iM5P/ugm9XjRNyCmt/Rve82jGP7L+SGNB4wkwPL+lKEkK+48MpGWlMIOlIUFFtmUCbRSEEbZ3Vr3523obVZBoIhAXgX3h3WPweWoblxAJKuMBPbt66az7JDCFTCAC0hAw97oOho13yfF3uEsw0GLoYr651MJhzceoG1hc9wNdZ+/gOX9MGPAxhemEbQQQTtxDF8ZbubNrhtmmJA7BfTYhi4xixwuza2fC8b9MMbMdM9cw+H2N27mW1E7F5/9WxxQngCL4b+cOnFPzw5aaQs5/S2RsOv/sct2cvWhjk3hLxWKt7euWCiRhRMBiAhjZnGixSMfFcc52tEtJuclxxaSQCEhM4NCaT30ROX1udZI4C7uozHYz4VtOSd1QnetY7kGJ/dy6Cw7XC4eivTDYXLNfDj8vxe95UlgRuRGcd0RSxTsjr5B8JfF+13vbV7XzsI3d9ORrffwtxuDJ780Eic1JIue/OSo2nguz8CU2irdONGc6a5PygnUCSRIRsJbAuUUPtcHLiBqfp1aajkG228oX+r9upQhdIgJJRcDMOh8M6W/A8c9IqoZL1ljM9l64r2rr0/4IskdbbXreK9sGMqa/AQegg9WySV7sBA71h/6GmZ0+dik21Cy3QaadIs1diug4LgG84w0/biEq0CwBfFb7ryqtub65i+T8N0fFpnOHQv65EpmKueBvVs/3b7cJBYklAnET2L5r10iEA7eLW5CLAhDu/2pV2cyXXTSBVBMBqQiYYZ7Bhr1zYRScPzrcJ2Bc+XxJjaMzbzmvbc8Oh0KL8PKqXAI39/vLfgvMftFZaNGppV/2sV9bhBrkGoqI0GgqRgTsJsDvbW72n5x/u7kfJv+p5cFrMYp1ymGnpP2Vc+0RaY0jw4gACBiGcaHKIBDuH9A8Kber3AaynQhYScB8Sdm2q/YFc7siK+WSrHgJ8DtzZtc6MgM3oHRnDxEMYtsz1jNeq6m+fQTMHABBI7DY3IXBPi1RSFZt5j+KplFRIhArAQzU9V41u+6YCFly/mMlGmW9nFH+nti78k9RVnOnOGflm5ZOM2de6CAC0hKA86y08w+wj25a7N8iLWAyjAg4TODz0tq/4GXlcofVkrrjEhAa041nzC0Xj1s0jgJD5ta1NUQDlnuwPnGIoaoOEcAATTYLHZx78XyR6pBKUkMEiECUBIRh3Hx0FXL+jyZiw9/m/tUNoeCr2Kaiqw3iLRepafy+lraHsFwZCSQCMRDIHj61N2Ye+sdQVY4qnNVzjc+Uwxiyggi4TwBbOU2kjM7u90NLFpgz8XiJ/E9L1604v68h/DAGf2jbMytgOiQD38Pf23ig9u8OqSM1RIAIRE/gosGltUfkzyHnP3qIUdXIGuPv3rBvdxkcf/myozbTEmQgWXn9D1Keb+YSnSIC0hAwhBghjTExGMKF9veqJTO/jKEqVSECCUcgd862LGR0/nfCNSzBGgRHb1xOSe3/s6NZuaW15uzUj+yQTTJtJiDETbkltdfbrKV18bTmv3U+dDWJCQhPwDBuOBwAOf+H07D4994FkyewA8FVCGEbYrFo28RxD/sFEhMatikgwUTACgKCnWuFGFdkYCcNbxvfP13RTUqJgGQEkODPa+jhF/A9eYJkppE5zRDAzPyfrM70PqC07nuGMP7WjDo6pQgBDMg/nFNS417UBq35V+ROITNdIjDucL3k/B9Ow6Lf+4y8e2RW/uQyvMyUIsFfN4vE2i4GW449WbVk1tu2KyIFRCB+AufEL8IdCdhJ47UNC/y17mgnrURALgLbd9VOQ7i/sp9nuWjabw1yrYgwC1mWuPj0Od+cYBjhErwv0bpx+7vPRg2iDYSXnD1/V0cblZBoIkAEYiAgOP9e3rwd3Zuqept+oZ+xE8BIOO876t5BQtcvR1jcVXpYHxC7NHdqIty/2tsm5RfuaCetRCByAv0u9ncMNQQH4mVRyQPRNQ8raTgZTQQsJoB1/gWYMbzTYrEkzj4Ca71eb1H55T3WWqXioL7/cTzKs62SR3LcI4B34VN2HzjwZ1hwo3tWkGYiQASOIQA/NRxouBjnnzCvkfN/DKGWT5xb9FCbXbt2dQ5qLBMzFVnCYAMxCH5adsHUc1Wa4T+2hTysefl1mI3ce+w1OkME5CIgAuGh+PwpGbVkDrJtWjxjMadcf3LdVGSN4wSGfCJ8+6pr/olBPHws6JCeAGdPdUj1/mzF2B4HrLI1t2TrWEPohVbJIznuE8BAzg0Di+ueXFvUk6JI3e8OsoAI/I+AzsfgD/Wcf8yqX4F19KP+1xL7f8NbiZcJnsK4aFO3c+ehsLTDVsTjQYfj0P/tt8YeDVwTt29aPPMde6STVCJgLQHdME61VqKj0l6hnTQc5U3KJCVQv7nmdnx1KhclJylO28zC8+oAlgT+rGJixlNWKhm8cHu7wN7QP6yUSbIkIGDOMLLwIxjcO33FUB5yzCIz4Z9l8SiOWU2KiIBjBOCpDmtSptrMfxu8LJjrihw7vnPu1fbvW+bF+T+rl86kMOSWCdEVyQhg7VIeZv4lsypCczh7JcKSVIwIJCyBAaU7e2A/99+pPnCesB3U1DDOyhHmf4WVYf5NogP7Qn5ETPZq+pt+JhSBgfVVW3+LFjm3na2Z8I9iiBLqJqLGWE1AdDO3/FtVmFGrZOis1TiSVx5/9oZhKbcnb/up5SoS4MIYpKLdeDHZdWbXMyjCRsnOI6OtJADH/wGsD+5gpUySZS0BzrQnEOZ/lh2O/7dZ4e+w1mKSJhMBg4m7Ty39so9MNpEtRCDZCQQY/57JgJz/JL0TEMr38lndTp9E2/ol6Q2gcrM5G6ii+QidXVhcfIWuou1kMxGwikBO6dbz4fhfa5U8kmMtATyn6j0e7frKoowfrxjb07L1/U1WmgmSEbf1KH6qFnna1AT6GREB0SYggn+NqCgVIgJEwBEC3DDI+XeEtIRK4Pg/PGlYylXkiEjYOWRSqwSGFN3XCRH/nVotJOlFfO7el9Q0MosIOEfAMGY4p4w0RUMAz6g1Po/nzHUTMp6Opl40ZXNKa8bR1o7REFO4rBCX5pTUDXWkBeaafzqIABFolQCWWp1hFqCR11YxJdhFzg3OxVSs8b/PX5ZgbaPmJAWBPXvrM1RtKLb4+0BV28luImAFgYElNWeHhRhmhSySYS0BOP7/7dyT3fr+eT0PWiv5SGlYln0PZv7pSBYCInwPmjrO9ubSmn/bEZMC9QkIzvqarSDnX/2+jKwFnH+NL92rq5fOWhhZBSpFBOQjoIdEunxWHd8ihNI2nJjd6/Pjl6QSRCBxCWDNy12J2zoz3xivRPtW47u2HIlJt3Nm7BHCc4BxowPn7ERDsBOxPXB3RL4PwQ5CpyGB8aEdhFyEYob5w/CfVk7MfNZuMwaU1l6C3Voaw07t1uWKfMyuoO8rEZ22TuOsEuveaz2atk/oYn+jPRrviCSXHQyD90b/D0DZPCx/6O2KrQ4pxUDPZXlzak8vH5/xmUMqSQ0RIAItERDYqh4HOf8tAUqg8/iCWaZ5Uq7ftNi/JYGaRU1JQgJI9qfmzD9nq1Y8dotz2x4l4b1BTZabQP+SulzBdPtnAJ3E0OjsiUVw9IvbpLAFn4/N3Bqp+rxykRKqqDkNifXGIgz+R244gXD8VwvuuWL9xJ4VkdodTzndEPfGU1/GumC4H1kMStGP80WqtrRybM+vorEzd862LKaHR2EH6cswGHQxBgc80dRXoWxIF+bsf6EKtpKNRCDBCXTsN/+LVHL+E7mXzf15OZ9atWT6X/GTIu0Sua+TpG24ibuo2VSxUU27yWoiYA0BDNz9H9YbYiw6EQ6uY2b3EY+P/aV8XK8NsbSoPI8HUe9j8x8c/98NKKkdBgcQu++I8bHIi7YO3gn+gzD/2+wO82+yK7dky2hDiLOa/lb+J2ebcDPP8HZJfbm84KRDM/sxNKpifI9qVPu3+c/cAlOwwCTDMH6Bv0/Gv0Q5xg+YvWXQugm91tjWIHPN/1rbpEshGNFD1XgHWo4Bp0+RrX2DzsXOFO7dH9Z0LwtpHbhH76UbvD+ii85HHNL38VxpK4XhEhhhDtIhwuld8HvPo4n1QvdsEdzY79M8oZDB2mlMPwnP335ghqgsXoAB2cYZcglMt9yEDqx9R3L+Lccqh0Dc6HMw23+HOdvPOeVXkqNXyIp4CeDBfWK8Mtyoj1mhKjf0kk4iIAOBnFd39mTBg4mR4Z/zD30e/lMrw5i/HZxfhr5alju79lyhGw/gWfd9O/qu8SXYgzD/CZnP2SG/JZkG41MwsNHSZWXOg1891/iM7DbpDy0YwwNWGr6usNs2yJs1ZG7dX/cH9VvhiEwGshOs1OGKLKxzwVIHc2vHn7iiX22lDXD6n0Cg9n8rJ/b85DhNea/p+uCF29sF9oXGw4m9A5+6IU3nk+0nnq3LMOb8rx5d0+cuK+ANkbY/t3jreQbXb8bn/Rp8DhPKVw4FNHL+I70RlCnH2QqPx3PXpsXTFytjMxlKBCInoOaLEBdVkTeRShKBxCLAgwevxqyKT+lWcbYbg3iTrypMf8yP5Ll2taViQoa5K8gPzPXxmCl/EC+euVbpghPxJhzX26BjvVUyI5GT92pNv1BQXBBJWWnLHFrP/xzzpd1ZMa5bnZ3rJL7dYvGBvHk7ng4dCPzLqWgQO9njPi46970aRJpk2ppQ0s42OC6bs6d8bdLuKr/kpO3R6l41uns96jxr/htQWjNeN9jfcR8pmTMp2rab5eH0r/IIz61rJ/Z82/zbTMYSzVFRlG4OpLyHZ9f0UIg9jEG4kdHUl7kshuJSETlCRyIQQPjZas3DipDJ/0xy/BOhR6kNLRBQcps/hJttbqE9dJoIJDwBzPpeo3gj17ZJ5YMqJ2Y8YqfjfzijdYUZ83p0yTgVL7EIAecxLS0w5eHdIIR/r+G3MZUTe4122vE3bQgH+fXmT1UP9MEBD+djkRTxuko4/k61w3T61hdlTsCgzY2wIeyUXpv0dPxmG3NkSYtN9jsnFgONuN8uWT+x16RYHP+jDV1XmDmnwwnt8nAfzT36WsL9fWiJ8yw8O4esLTrk+MfTxvJxmRvQD6MY136NZ6htg77x2Bh1XUP3kfMfNTXJKmDdGdP4mOplswZXLZlVgi8IRPjQQQQSkwDu7g4qtowzz24V7SabiUC8BAbNrhuAGafT45XjVn28MH/K0rzDoknmZ5WtCFMNw+H8GxzAU3we7XREHkzHd/wSvIS2mFgQ1/dh2mslyv6Le/i1bdv50iuLeo2DjAVW2RWNHMz4InJWXBdNHZnKwvivNc5HmIMxbtmFQZv/Yh33pbAl5twCbtl+uF7cC0oPAh3eFtt+57zGw/hZ6yZmzrdSx4pRnfdcVZh5OZ5nj1gpVyZZ5gAZ1vNfvb6o1xTz2WmlbesnZjwEh7nI1GGlXDdk6VzzJtQ6Bjcguq5TsD54sfpj74LJZ6T5PC9Uvjmdwotd7xQywC4CgnGEDqs3vqWxsBmCRwcRSDoCId24WtVG40Xvvfad2o0xX5zdbkP5hIzPYYP5r/FAHoUOPsM4KajrGBcIewXTgp4TU+riST7XJNvKn7mzt+bD6ettpUzHZHFe6/V6R5df3sP1VHIVE3stHFBaN0w3wqZTqGQyQIwDjTxtbk26GwNpjt0z8Sn6MsWTUrBm/Mm2JAg2o5bwWfxZbkltByRfVT0a6yjSmJUX/Op1EzKLj7pg2Z8VRZmzB8yuvVHXxVOWCXVBEBJw+Mj5dwG85SoFM/OczmgI6jOy8icvYx7+aLvOKbPLi/1mNmE6iEDCEMCWSj4FfX8W9qUeSJhOoIYQgSgIYH3h1Sp+ZhEq/05qB99FcPylHLhD+Pk+dIP5T+pDGMYkqQ1swTj0f5XPqw1bc3mPmhaKOH56XWHPT3Ne236uCAYX4TPV13ED4lYotIYGfi3E3B+3qAQT0DhrLTxFdjn+TbigRyD3wk1f1/FTMRAwuOm86j/RrnuxLMs2x7+Jz7oJGU/nlGw5Vwj206Zzqv3UMPNPYf+q9dpx7MWcaL7QxQv1O4O1WQVTZmaN8Xc/ThW6TASUIcCFSFHG2MMM9fKAlA7EYSbSr0TAcgJ5c2rOgpOC6DS1DjPUOy2NX/lt0iy1jJfI2vwykQaWhRKZFJEppiPm9fIr11yeLo3j32R45WXdqzQvx9p5rmbiPM6Uux+a2Nv6U/D7rFijHomNZtJFr8Z/hHtIj6S87GXwjFleUZg+0yk726d6f42lVdI9GyJtvyHCGjn/kdJSrBxCerphVG8yOxioxiDAo31H+/sp1gQylwgcS4CbYf/qHW20jsqvE1OPOlnsNgE9zNXMkKzxWyg0Of67p+6rrefjXaRd/JIcliDY3eXjMz9yWGvE6iouz1zNPeLnEVeQqCBmTIecPucbNXftsYsjcnf1aZc+3S7xzck1lxFpCbD+HxE6IeQ2udmMaGiunXacM3fjQG6B/7NDtlMyyfl3irRLevCgTcUgwM3hYKCid8HUx3JG+Xu6ZAqpJQJxE8DTXUknOhgMtIm78SSACChGwGBGvmImIzu+9kRlYUaJanZLaa9mDJfSrtaM4mxxxcSMB1orIsO1ygm9njDvVRlsic4GoR3Q9+VHVyeC0uURlJG0CMKwpy0YwwNOm5eaymbBeVZ6ebDg/Ak3djD54fjMlzHg8IXTfWaVPnL+rSIpuxzBPEwYNzWEg19kD58yfchYf1vZTSb7iMDRBDC2Gzr6nAp/h1hYvdkvFcCSjdISQMi3F+GY50lrYHOGYQbO2zXl9uYu0bkYCAg+IoZarlXBy/wu7Kt+nZOziPE0tnO6+Dk+Y6vjkeFKXcGtHxTKc6UlFijlW7t3Tn/WAkFRi2iMbuL85agrSlOBG5rHO8sNc8zkidg54e9u6I5XJ/d4BTn/8VJUrb4QbQ1DTP1qX3BN1oi7L1LNfLI3yQlwrqTzL8KcBtuS/NZNtuZ/+fXWoaqFfHONTZctW76q983Z83d1RL6HoSrZzwV/yIp91Z1qs7l2W9PErU7ps06PsH5QSNmZf/G01dvSRdNPmqY9HU15mcoi0n9xxfge1W7ZlMJ9L2GgUMloVHL+3bprXNcrsoWuL8AWgc/2u9jf0XVzyAAiEAEBJPxT0vnXuEEz/xH0LxVJHAIYZB6mUmsQ/lrnzcl8TiWbZbZ198GGfGzL6pHZxsNtw0v8vjRvu38dfk6F39cV9noLti9TwdbDbByYN2+HtcmoFZ3513z8hcO4OP7roPE9l+LZ943jii1QiIELV5/XqyZ034EBznctaIqzIkJhRs6/s8jl0ybYNaGGwMo+o6YqNUIvH0iyyAkCgjPH18VZ0S6dGydZIYdkEAFlCHCmmvP/5/I8rvT6V6nuDaHcev9HPht/4m6pGEZoDJbD/T7CotIU0w8GzrfUGAVn/s0BRzN5o6UcohRWzLmOdfNlUVZzvzim/X3M+4b7hogl7tsQnQUU9h8dr8Qtja2YjJDxXlb+5FsSt5HUsgQhoOTLGTN4doLwp2YQgYgIINmsSntI7xEpbR6NqGFUKFICp0Va0PVyGFTWeNqfXbcjRgMqijKXYeuxt2Ks7ko1wcUASxWrOPMvScQGIkfetrQvHBCGAa81jTPvDuhqVYVHU2/mHw2imf9WezV5LgrGfPj3SFbB1PuxOwAGJOkgAvIRQHIjNZ1/JrLko0kWEQF7CAxeuB3LXES6PdKtl4otr/5TOa7bPuslJ7NEkaNM6wV7aV1ht23K2NucoYL/obnT0p4T3Nr7Q8WZfyFWStI/n0tiR8RmYPDo04gL21iwbZrH1ciNWJoWQt5scv5jIZfAdYQw/g+7ATxXVPSyMmv1Erg7qGlHE+Bqrk1DM7KObgr9TQQSlYBeH+6nUtsMoc1XyV7ZbTWT/SHyo4fsdjbZx7k2r+l3VX+uL8pYghnczQrZb63zr+TMP5PCcfR5fWsVum++NVVbJYPNK8f02InP3S4ZbInUBi4o23+krJKqHL60r/po52dP+v1+GhxKqp5XoLGcK5mYhgneXwG6ZCIRsIRAWLBTLBHkjJCGnl3TlQzddAZP9Fq+OVhvrWMXvQmR18Da4bZtPeqteW6+hcXNn5bvLCJMrb1HFJz592reLTL0zOrLTtqBcF+lkilrTMg00LVVhn6M3AZK+Bc5q6QrKa59YnnokaRrNjVYagJ4T9sutYEtGIctz3L6jLyvUwuX6TQRSCgC3GDKDHZh1uZdbLXVkFAd4HpjtFzXTYjcgFXm7F3kxeUtyYU2R17rjrGs44DSndZFhyg4898uLVUKpxHPQKz65duO6SGJT2BmslYi85RiZ3KjmV2J7h7pTBHGTb0Lpv5KOrvIoKQlgAeWFF+WMXQABtb3nxlDPapCBJQjYHDjFFWMxouvctma5WdrKOP8YwYxYfrfM7DnJ3DiDsp/fxyyUBgN1s3+qzbzD4f7g4s7S5NnBGvopbElkvtX0zx7IynnSBnBlGJH2f4duStUV2I80KdgygjVW0H2JwgBn0+m0d6ooOph4+yoKlBhIqAoASTm7K2K6R4tcZw/WZhzQ53+x3r/pbJwi9eOxq0qOfs4XjlO1Rca7+qULun0CBE4NOMuh2WY+1cq+kkX7IAc5GAFV4sdC1HCP2nuHWkNEcyDD9mL/S6e3E1aG8mwpCGQcTbbjgetrmKDMdB/nop2k81EIAYC7WOo406VE1IVTHblDqrItYoOkZd1t6QutI3uWmCtdkQyrLBWoo3SuGHdfaJY2D9CASWL0OBBG3vaBtE+meyVyZaIWFPYf0SYkr2Q6BpuYH9PdgrUfvcJLPP7wxhmrXbfkhgsEHz4kLH+tjHUpCpEQDUC1r3U29pyvrO84KT9tqpIRuGcK9L/WPuqGQmx3r/pNjMYU2cww7DwPlEt7J+Z6+wlOjiTyx6J0CScKR6v8KrUKIyUreQamy2DzYJxLz4qKbAlDf+6YE9jM3wpXQjeF7+rM+sRIUzsAPDDrIKpL1SXzXg1wipUjAjYQgDPgTX4lsLnTK0DSf/Sdh0IXAirX1HLcrKWCERHAJ9PJb4D8b67JbqWUenICKgy88/1dePTv8Z3SsIcmNHbgAEARQ4LnX9FWkxmEgEZCCjl/CPcd1XV0lnTZQDXmg05o/w9g3poCAYBzjYMNho/8TusV/yA8/KnfL9/3qHZV8UbQ+YrS4BzOP+CjVOyATo37SbnX8nOI6MjJ6DIADjn8iSNihyu/CWF6dSpMJEovpJp3bUVHasxzw5DlZVxXJVBIit6hmQQAXkIqOX8y8OtVUsqF/nrUMD8Nxf/7s4a4+/OG0LXCmTPh9PSv9XKMl8Uou/m5aEfw8THZDaTbEtsAgLOv6otxOvwpXlF/pTyYr9ya8RUZU52O08ACf/aY7DYecVRaoSF9VFWoeIREVDDqYPjn1Ah/2bXGJqoV8X3Z1aG/Ud0X0pUiMLsJeqM5DIFC04Erfl3oM+r5/u3Vy2d8eCkYakDONOuRBBAlQNqbVFhMHGv6bzYIpyEEoEICAiufR5BMUmLiK71XwcnSGocmUUE4iaQXybShFBjSaFqGa7j7hynBCiy5h/vwN84hcQpPcKTqkwOC8ENyoHj1I1BeojAYQTI+T8Mht2/+v1+o3rZjJd6duuahzUAf7Fbny3yhUiv3xUqtEU2CSUCERCoXjStAjOLuyMoKmcRg/1UTsPIKiIQP4FAaq06S9w4UyYxXfw946AEJEVyUFscqnjCTWRoYQVCbr7tMdwkSm0vF8eNRlWJgFQEyPl3oTveL/7Vwepls37JOL8GUQDIXq7YIQQ5L4p1WSKZe2iNpvhA1TZhVnRYvxGTB6pqP9lNBFoj8P55mdjCiquxHadoTNTbWnPoWiwEuNgXSzXn6yiSmyIKMJq3oV0UxV0uyhW5T1zGROqJgIUEuEdQ2L+FPKMWtbls5vOYwbwWFeVfHHlY6+C8XJB14eTcw07Rr0TAWQKcve+sQmu1hXT+S2slkjQiIBMBoUjoMe8mE7XEsYUr0f+8MTFh4lBvbInO1XH+hSqDRAl2j1BzkpsAppxp5t/lW8BcBoAIgAddNiNq9SLIKfQ/ampUwSoCGuPvWiXLJTmT+o7293NJN6klAjYTUMP5Q3B6V5tBJKl4RZw6znoiR0VCJb42hEIDWpqWvDP/KmRETdKnVzI0m5x/CXqZ9065F2ufqiUwJWITYO+lERemgkTAYgJaWvd3IBLhxaoewhsOBvyqWk92E4HWCGA7TiVe6hHF1vbc92ratNYWuhYDAaFGOLeZmHLX1zt6xdBCaatgV6lsaY07xjBFBomOsZtOEAF1CXAPZfuXoveqn/Q3cK7NksKYCI3Admtn9bt4MoVMRsiLillLYMOC2wMYgFpurVSnpfGr+oy851SntcqsL3v41KKsgskLc0b5e8psJ9l2PAKqhP0ztnub56TjtYauR0cA7wdKDP6YrQoYwZzoWid96T7SW9hkoMH3Nv1KP4kAEXCOAM38O8e6VU2d2/ueRfj/gVYLyXQR+SL0IBsmk0lkS5IR0LSFSrfY/Azp+iPYBYSew+jIPqOmDjUM4ykh2IUN4cCqrBGTL1e6f5PaeDVmfs0uwj13VlJ3lT2NV8b55xo/1x4E7kg1GDvPHc3Ra9U0nnBbLUZPgWoQAWcJhAxK+Ocs8Va0rZjrP8CZWNZKEekuCV0bIp1RZFDSEECypgXKN1aI8556K/hz5dsRZwOyLvJnGSFjLsQcCsEWrIvQ2ZysgimPDhnrp72g4+TrQvVaF3TGqjI/1opUr3kCXLCa5q9IeNYQ50toVUwm5ZXtaM+FUGgwg38RU0OpEhEgAnERoBmnuPBZXVn7xGqJdsoTzBhqp3ySTQRaI1BVNr0S0TJrWyujwjXDYDMR7t5bBVvtsDFvtL8zawguwJYn3Y+WjzW5N+/aH/y03/Ap3zv6Gv0tMQEu1kts3RGm4Xss/4gT9Ef8BLiojF+IMxLw3Dl38MLt6mTIbwWL/qoZyowAACvkSURBVFUwH+3xtVJEokv84NoJPbZIZBCZQgSShgA5/xJ1NZIkbZDInOObwtkZxy9EJYiAfQTwmSm2T7pTkkV7wxDPDrn5UUVe2qzjMvjCP7arDwTnIfFxi1uHYgAgJ2yID5AL4P9oiYR17O2UJJhHpRm9gYNnb6d1/xbeEFx4KiwUZ7Mo0aZhv54QCYwFF6NshmWdeM7Wc44YkSQ90PCkbXuSdrk0zeZeryDnX5rugCGC75HJnOPagtDci2/7W+pxy1EBImATAa/wJIDzb8IR3/9qffVDNmGSUmzWJH/antDXr8HxP+d4BpqzWcgFcP8TywOL+g+fmn688nTdXQJewZSZ+TdJBYxwvrvEEky7R52Z/0bywrgiEXoAz1JlnH8sc1UmOiQR7g1qAxE4nAA5/4fTcPl3JGoJu2xC1Oq3Vn7dKepKVIEIWERgQ9m0cuzVXW6ROLfF3JqVP/V6t41wQr/p+LPqwBzMfQyPSh/KB4RY1adgamFU9aiwowR4F59KM/8YexMTHQWU4MoqJmTswqzuLmWaKdi4vFdr+iljbzOG5s2pOQvP0wHNXJLyFGdcoegQKRGSUUQgNgKhMCPnPzZ0ttTSmNHeFsE2Ct0vwuT828iXREdAQPAnIiilRhFuPNpn5N0j1TA2NivNBH6iOjAXs/kXxSRBiM66MEp6F0x93Fw2EJMMqmQrgfKCk/ZjSc42W5VYKBz34oTcOduyLBRJophQyLkTnlBITFW508Jh1exX6f5Q+c4g24nAkQS4h8L+jyTi9l+cney2CdHq1wRXbsAi2jZSebkJ+NqIpzljIbmtjMw6hLan6rrxKta3D4ushlqlzOR+X+0PLoLV8Q9wCOPGvcFvVvYZcc+ZalFIDmtxL69Rp6XCI/TwHerYq4Slq5Ww8lsjMRN9bc5r27NVsrnJ1txXak4VnI9t+luFnyIl5QMV7CQbiUAiEvAmYqNUbRNelpQJ2WpirBtG0iUpa2o7/ZSDwIYFs3ZiS7i5CN2dIIdFcVohRFvB+Ot9h08dvXHpjPfilCZNdXM7v3pk9UeMdYvJ/aI1FmtcTzH08Lvo/99NGpZyPxICYvVU4hz5ZSJt+1e152BpyyA0LAfrZDORG6YDZqrb4/cgY3w/rn0tkDzLgwzrXpH60erCkzfJQIBzbbkQhjJrkBEyfePpc77xfzb+xN0y8FPfBq2MMeOnqrQDiUW9PBCaAntvUsXmJjuNEIfdBsbA1TgQFVRdeVn3KjWstclKPMBtkkxiicBxCIQYOf/HQeToZcHyHdVngTJNaOT8W8CRRMRHAI7Go0LoieH8N6IQ7cOCLcoeMfn6qiWzSuKj437trJF354uGIJIziq5WW4M3KB8GfmY+uTw4uu+FU6/b+OYMdfYYbwZG/7l1XbWAfiXaVVi3q8bcszu16TXx0NviUf83/8Q/HT90FmA5JTWb8edCJMN8tnxij3dcy6jN+bImu5tppnSnMJDU/qCx/2YY9oB0xrViUE5pbYFXE/Xl4zM/aqWY45fatvWU1R/AlIbA0JQyh7g+59WtD1aOS1cmGV3/krpcJnTFEhbyJcrcEmQoEUgwAtzwUbZ/Wfo068LJufiWVG7mn3sEOf+y3ERJbEfV0ulvJlDiv0M9iQgAQ2cvZw+ffLeqXYvZNN47f8qvRdhAqL/1jv/hXKBrmB4Uq7ILpij2InyoFWbIcU5xzbO8IVxnCPF3tCcfznPUu6mgXm84XDeHWfitnNKaDbmltZP8wvnvem9uz48RmXDw8D6S/Xewmzy4tDZDdjub7MNAz2BhGK9gvfc7uHfuhP3SONorx/TYCWOUCv3HoJlPhIyXzIibJsYy/8wrFymchZ/Bs1Wp/F2Y9CbnX+Ybi2xLeAJKPTASuTd4iN+mYvsM3fCoaDfZnIgEeCJulccNg02DA11srpdXqdeyxvi7Zw+f8gZeTB/EP0eizDCAegIc55eQM+HJnMvu76ACr9zZtV1yirf8mQWCFbD/GtMBscxuwfoYhvHECyW1nw0oqRljmdwIBJXn8SDCe9VatiLYCdhN4mmZnOiWUJ82tyYd98o8XO/Y6LQycR8GehYNKN3Zo6U6jp8XYqnjOuNVKMRpdbtq/xavGCfqh9fVPoDYiqFO6LJSh9eXqt59YSUAkkUEXCUQpGz/rvL/Vnl2wd05eNlQbp2Zab7m0cxoUzqIgOsEfGndn0OI85euG2KLAWJifSBQjmfFZbaIt1Co6Thl50++URwIrMWL6YUWio5YFPRe37Bvz8qsgnvOjriSwwVNTrnFW36DAdRNcN7uwL8Uu0zAoMKpuhDzMFNchrDmHLv0HCNXiOXHnJP8BPqlAAMlv5bZzDPmb+vWEGBvIMLjiCgF2D7CMBpW5RbXXiqD/Zxpas7w4n0sZ3bNNTIwbMmGnOKt49Dfv2jpuqzn8R29Zs24kxP0e1pW6mQXEfgfAe6lsP//0XDpt7wifwqSIj1pjty7ZEJcanXByfmPiyBVtorAhgW3BxAm/Wer5MkmB8+I7obQX+1dMPlZrG3PlM0+0x7T2c4qmPoWktM9jj9PdNVGIfoiD8Q75rKJoqKXpYpQGrxwezvM0haD0x/BqKNTnOAs5Iug/mFuyZbRTujkzKOk84fP2oy82bWnOcEoWh2m43/gQHgp+nJQc3Ux0NPVYMbc/sU1f7t4voh62UhzMmM916ldm7cQ+o/ElAoeOntkwOwtzTJ2uzUDSut6I8PHE27bEYt+3LdzY6mXcHUAIuHaRA1ShgCF/bvYVchMre3/KvA4vqzPcdGMuFR7uJEQW6zFBYEqS0OgY8qJ/8CWTTulMcgOQwS7Rg8ZXyDD/UP9x/otT6AXi8lZo6acbi5NECKM7ZvE92ORYU8d4TWXTXy087Nl2cOn4oXZ/SNvbl2vhr2hd/DuV+iSNZ0Mwef1L6n9pd36103s+T4+j1vs1mO1fLyVp4QMo/SQk2W19NjlDXr1y5PrD4TKcO9E4JSK2zYdqP0o75VtA2PXGF/ND8d02cs4V9LZw3tZe8Pgy7Asx0y6Kc1hJvjDIPBy3KPuDq7GSISneJ6KsSpVIwJEwAoCoRCF/VvBMRYZQ8b62z65PPA8Ziqvi6W+LHUQSnpAFlvIDiKw6s3f1uOl6P5EJ4E5g1Q4AL8M7gtsysqf/Od+IyY7/oKf7/d74VCPxfr6hSIkVsLpnygvd/F9RFh9njV86lVu2jiwpObsUEBHIjxxupt2QL+HCeMhLAP4j53JAM2dBrDu/3l32xqjdsH66ogccXSZRCummnu5h0LBD/HOkNdKsSMu4RkxOBQKf4Iok5uPuODgHwj9V9bZA78uhi6W5JRulWK5lTkQwZluDhxKMZAZ9W3E+Qcq7aQQdfuoAhFQgAD3eNXKEKoA04hM7DNq6tBd+wIf4AX+hxFVkLiQJ0Wrl9g8Mi0JCfTs1vVfyDK+LRmajoEOc8/3O0I6K+9dMOXdrOF332BnYkAzfB4O/wXZBZP/VL0sUINkcq/hOebKuv5o+xd2dkJm9OcRofBMv4v9joXaN9mZO2dbli7Y61infVLTObd/won48fMlWx+w1Q6vos6/CQVr6pH9/a28ObWuDtaYzqcIsfdic/pEG3xOH+1fUlN66uu7HZ8t7t6l5wI8jxWOxhJt8NyYnVtS42peptySrWPNgQhzQMLWz6uNwhEFpOxAkI1YSDQRcJwAhf07iLzvaH8/hOr+Rw+LD/HCfqqDqm1TpXm9e2wTToKJQAwE3i/+1UFs+3d3DFXVriLEecLQ/7s/GNiB58zyrOFT/H0KpoyIZzCgz8j7OvUdPvU8c7u+rPwpsz/66rMdcCSWG4L9Cs+w7moCE9eGDgY/M9vllP15ZTvaCz0811yP7ZTOyPUYvza3A4y8fHQlKy7PXI2X/tXR1ZKoNAZrQrpRlltc5/gg15C5dW0RnfFXRK28Yoahx0VFiAmBhn2fDyjdckFccqKsvKyAh7G123NRVpOsuPBgF5HHcopr/2l+lp00rvEeKK39gyGMORiNauOkbkt1cRZISWv/kqUySRgRIAIxEXBk+6WYLEuQSubLsyH2Xsx0cX04GBiFkD2pEk/FhZlzo+cQtnu9kiv64mo5VZacwA3DUp58Ynnw55i5+57kplpvHp4xcBQuwLPmAjMb5/5AgPXOn1yLEOyNeHmsFozv4ILtwqUGpokgtoj24eU8FXXMF0vMKnHTqe+OmfJT9PCe77YNg7OP6ub/EuEQ2WEh3sIAyfQzu5w+rbj4ChOVLQdm6jhmDZ8DugjWadtiwnGFYmbz0dziresritLfO27h2AqYzt99sVWVoBa2ADRYeGFOyZaX01L5rz4fm7nVbqtyi2vy9wXCj+Mz19cyXUJkIknvUtyPM04tzPhDMXcmYa+He54OC/0Oy9rhkiDBjJ+FdwUuwW4Kt1YUZbxutxm5pTVX7wvo95sRKHbrsls+FgC9tvrSE76xWw/JJwJE4DgE8LJHzv9xGEVz+dRLZp1YH9zfFzP7/ZHhdihe9s7Ww3vPwhvzIc4J8+L8HZWqZX5/+Lu/6BciIAkBJNM0skdMvsPQ2VuSmOS2GRlwQs0XyGGmB//dowjp5hkz/vd3o5XfXW38K2H/Zw6SCPG7j3euvDDnwruvqXxzepUdbYWjdTeISrFmuKX2wb4UwfTZ/efWDVo/tudXLZWL9bzPpz0fChvTwVvpdw4MiF3R0MDGYDb+D+2zMv6yYii3POHtgNLaczDLfC/+XXzUBzNW/EfVM2ex2b2rSmtGIKHhNesKe24+qoDlf66dmL4Syw5Wwok9w3LhDgvEPdwbT9C5OcU172uadu+6wvTFVpuQN6fmrHCY/cUwhFTJBuNpJ/ewf8ZTP9HqwkdIki/aROu5xGiPWl/Ego9Bciu7Ziai7FGkMTJny7i5NzM/ATNnXffW7/1uW52k+FQLhiRfdBABOQlULZn1NsLfn8fL2tVyWkhWyUAAz+pzAyHjM+QyuLVq6YxnrLTptLk16Qcb2GRF3vNO5gH9HrT/F1YyMGWtuTy9Bg7zi/j1WqtlOy0Pjl97vLY/sK+q9ubc0i2PGCnep+IdMMl5dWcHHm4YC4f/Bt0wRjrRJgxknK+z8Gc5JbW3VE7MeNlunZj5nQV2tuuxux1N8tGWc3VDX4T7uoIL8Z/UNP5CPBEhGHjrygMGkqaKH4fC4swmPQnxk/O3KiZkLk+ItlAjiEACEFDK+cfDthuYm/8kOL517xt/wDIJLHLaBK6JFU7rJH1EIBoC3jRxR6iBjcYHVNkkSdG0l8rGRgADRB3x72nsXHCx5un0/zYtvsuSXCYNAfZ7vMyrs05XiP93aumXf11dePKm2Ei2XIt72QMizK/B7C8GzhPhEP2wjeSDvCE8s3/Jlrc0wRYK7l3WPpWtXTG2Z6u74AxZ9HWnA3v3n4YtF81EggUiePAivEOkOU4FyxkQyv4SHNgLUzv4frFqdPd6u2y4amJ66fOlNevwLB5glw435OK5kYu+++PBBvFH3AflWFK1SGjap1xo65jPV1k5rtu+o+1qHOwxQv2ZoedgEOYM1B/BAvrpkJUgn40jW+zh2rQjz9BfRIAIuEUg7PGpHYLnFjjSe4gAXnRoJJduBqkJbFgwaydmdH+JZElPS20oGScFAbyIX2Xoe8/rN/Ke8RsWT4srssncXx3brE2SomERGgEnxBcwQjNQ3PItEc3Ef/2La+ZD9iURmqNEMTBLgUM7EitoRjIRZvsCXMCZ3oJBn1omuOn47WfczKnBO+F381/nfXvqM1AHjh5qS3DA6bwxsDf0fexqcGX5+IzP7DDJjxxBWMM+HdENiif/a4UOtmFEj+YxjAphUIWxYJjhXghjwMu8Dw7CtW+L5JftMdjjlaPnW2mLRZfQ3vftWBphkXkkhggkH4FQkFG2/+TrdotazPdn/8CD/arpIAJyEzBDufGW/YbcVpJ1shCAI9RbhDErF+cRDoeQ4E6ol+CVix/mzqkbEmfzm6/u8aib9K/5Fh17FrO3jfcQwuoRE4gZfTERg0pj4QAiCac4Df8y8U+6GV7YmRMOGx/mlNbeYdcM9KkTMl5C4tH1x0JL3DNgaTr6J+JfT4wInGD+nbitbaZlHvaHZs7SKSJABFwkQM6/i/BVVo2MB29Ssj+VezC5bG+Tyn+M3ByWJzJLLorJ0Vo4Jy9vXHZfXFtS5by2PRsTu5cqSQyOqaGHb7PD9vUTer4DvpLk7bGjhWrLhIOagp0f/oytH+cNnr39JKtbY+4ugJngmVbLJXmyEuAfVU7IpIH35roHicKaO03niIDdBLjXJ8j5t5tygsrXBJ+doE2jZiUggXULZ27TuHZjAjaNmmQtgQ3etJSb4hUpgqHrZJzdjbRdSM5WaO4vHmn5qMpxfndU5amw4wQwO31xQA9+nltcd6HVyrt3SX8OA0BrrJZL8iQjwJH1wMOV395RMqpkDhGwgECIwv4toJh8Ijg/4OvY8bXkazi1WGUCVWXTX8Os0yMqt4Fst48A7o0G7uNFGxb498arBTHdRfHKcLM+QsDb1wf0i+2wobIwowyRYwmT9d0ORjLIxLRkd4Prb2DN+h+HfCJ8Vtm0rICHGdd+yuAcWiWT5MhHAGtfHquYkPG+fJaRRUSACNDMP90DURPAV/bLla/deUwG26gFUQUi4DABb5vumIngnzisltQpQAD7UN9UvWhm3MnOzHBpzJwOUqDJrZqI6P/hrRaI46LP6/kNZn9bzYgfh3iqahWBQ/kLfrO/qub9ASU1p1gltrIw/V3IetwqeSRHOgJftvF2uEs6q8ggIkAEGDco7J9ug1gIcA/NnsbCjeq4TmDDgtsDHm9KIa3/d70rpDKAc+2BqiUzn7XCqIAeHmaFHLdlIFt5vl02rLk8vQafQVr7bRdgi+Viin6IIdinuSW111slOjWtw52Y/d9hlTySIw8BjbNffjb+xN3yWESWEAEi8D8ClO3/fyzot4gIIDT27eqyaR9GVJgKEQEJCWxa7N/i1bQfYqMtXULzyCSnCXA+b9Iw32TL1GrsVMtkuSqI5+SVixS7TOjTNv1BfAY32iWf5FpLwFwKgi1Tn+xfUvP82fN3dYxX+upLT/gGy2N+Ha8cqi8dgUUVE3u9IJ1VshmED5RsJpE9yUOAwv6Tp6+taalHo9kaa0iSFBcJbFw6fSlme2910QRSLQMBzsp9aSlX+/1+bMpt0SGMHIskuSxGeHjltr52GbFgDA9wjdNn0C7AdskV4qrd9fWfDSit6x2visqJmWa0zaJ45VB9SQhwtpunptwiiTVkBhEgAs0QoGz/zUChUy0TwBrN5dVLptO2LS0joisKEaheOuMRM9xbIZPJVGsJ1PrSUi+yIsHf4WZhi7+4naLD5bn5e4jptrbF3AYM3yt/c7ONpDsWAnzLoAk9amOpeXSdlJTU6xABUHf0efpbMQJI4MiFZ1LlZd2rFLOczCUCyUUgyCjbf3L1eByt5dzQvPw3cUigqkRAOgJVS6ffhaUsL0pnGBlkN4FvfNxrOv6WODBHGiviDok+Up6Lfxnc9rb0aZvxf1j7vdLFVpLqqAjwnSwl7epizi1ZNrVm3MlfCo/3hxgECkdlBhWWigASQf+xsij9VamMImOIABE4hgD3MkFh/8dgoRMtEHh406IZlCW9BTh0Wk0CeOEU7bqlXI+tx+ar2QKyOloC5pZ+Xs7GbiibVh5t3cjK8/aRlVOhlGF7W8zwf03jV6Jf6lUgktQ2mnu3c3Fd5bhuls7Ur5/Q8x2Ipuzwit5c+OwuHzwxY4qi5pPZRCDpCJDzn3RdHn2D4Rht8Xg6To2+JtUgAvITKC/2B1nv1ELMPi6R31qyMB4CGOwJCq4VbiybZW41ZsuB/a0TZgZT0zRH2oL9wNejb35uS4eQUOsICHEfkrkttE7g/yRVFPb6E3aAmPO/M/SbCgSwZGO7t23qlVZFgqjQZrKRCKhOgJx/1XvQbvsR7o910ddtWnzXHrtVkXwi4BaB6if9DZ18J47DDMbbbtlAeu0lYDr++MKbsLlsur1RHpzvs7clDkoXwrG2VEzMeArZ/59ysHWkKgoCcPLeOW1i5j1RVIm66Int2k7CM7gy6opUwSUC/CDTPBPLLzlpu0sGKKsWuWGEssaT4WoTCNJWf2p3oAPW42XZX7V0xlsOqCIVRMBVAqve/G19lw4pFyHS5U1XDSHllhNodPw1rXBT2cx5lgs/WqBg3xx9StW/heFsWzpkZd6EAYDFqvJKVLvhkH+VqmlX2T27++GYLnt9Pm0U9G1JVJaJ0i4MBoXQlsLKwnTboqgShRW1gwjIRgC+HR1EoHkC+AKes2npjOnNX6WzRCDxCKyY6z/QrmvqWDiLsxOvdcnZIjzHGhC+XrhpyfTXHSHA2QZH9DigJEXjjrZlxVAe4r42ExD+/ZkDzSMVERDA56few9mlqwozbEiOeawBay5Pr+EePgrLsHYce5XOyEGAG4xr164vylwghz1kBREgApESoK3+IiWVhOUw+/khZkGvhRNEoUlJ2P/J3GQzB8CZXU+/Ai83/0lmDonQdjguu7FLySjHHP9D0BIibNl0+j6fkL7V6fsAyeT2ebS0MfgOqnZaN+k7kgBmd4OaRxu/dmLmh0desfcvMweET+MXIgpkt72aSHpMBDR2S+XEjJdjqkuViAARcJkAhf273AGSqud8bZrW4RJzFlRSC8ksImArgeLiK/TNZTN+AgfIzEBNA2C20rZNeK2Xe76/afGMd2zT0IxgDJd+3MxpFU994tbg77rCbtuYz4MlOHyXiuASw2bM7jLt2nUT0he50Z7yCRmfI2JnjDkI5YZ+0tk8AU1jv1lfmPl481fpLBEgAioQ0PDlGlTBULLRGQIY6V/t9aUUVCyZQi9dziC3WItosFhgUourXjbzfsw+TQSEg0kNQrXGc1buTdHOs287v5aBZLfLeB9Xlf8cCs6WttxK+69Ujkuv5B7PaDh/X9mvjTQcTQDbL/6ssiij+OjzTv6NCID38U5yKXRSwmEnwTerixu4J24/tCtDswXcPZnnrvpotSOo1syZQEeMBPSUEPGLkV2YeXUNc1r0UI0RYKJVw5fs+2meDgUb3/TTWjtFO9cjDEqUZHHfbS6bNZv7+HkYBNhksWgSZwMBOItz0jqccO7GN2fU2CD+uCLNfesxqL78uAUlL+Dh3PXElxXje65gKdr3sf7blb6UvItsM09j2tSKwoxHbVMQheCKosxlXu47H59r+m6Lgpu1RZHVn4vCisLMv1srN4mliQTaFcaFbuzr6eHYTjQuNM9elTyEnY84q7JXC0lXggDnpSwrdTjN+CvRWy0aydNSN7d4kS7ETKB60czPeKfUIXDqXo1ZCFW0lwC2JUVI6j1VZTMKK1+709UXA8H5c/Y21mbpnG1cV5jxgc1aIhJvRgCkeLXz8dmriKgCFYqLAGfa9IqijJlxCbG48tqJPcpZStq5lAjSYrARieM7vZwVrJ/Y65WIirtVqNwtxbHpxVpCGsyKDR0eA3yHOcgea/Vkr4cdVfZo2Gvy82QHkdTt50zHS9WU6qUzisy9zpOaheqN56z+2rNZnerNkNX+6lf8u7Ht5XisQ/0tPjO0XEqujvrGw9hlVUtnTUffuJ6jIa29dzZmKvfLhSgKazh/JorSthc1M8CLVM8P0LeJkk/BdmbRKkDkXwhJFm9EqP890dZ1ojwSQdb5uqb+AJ+rN5zQRzpMH4t/keJNOdfphI8xsVct7J8xxYYrYuoVWyrhWUXsYiRrvpesuqTXbqz5Z2UxyqBq6hOoZRofVV02c5YML8zq43S3BXggvu73+5GkiQ67CJifEwwAPMiZ5yy8Gq2xSw/JjYIA1qb72qQO3lQ2c14UtWwtump093o8W/9sqxK7hCPDuq8dky68d/3Ynl95u6QOx3PuNbuanqxywfQbpmmjKyf2+q/MDMoLTtrfo2vGWHil/5DZzoSwjfP5XOPnrhl/8kYl2qOYO6hxtlwJrhIaiXw0xC7WfuHsbfM9Vktt3/F1yKBkVrGCVLYef5afkHrq5iUzafBH2T480nCusZIjz9BfdhGoKpv2ua9N96GQ/yCWTul26SG5LRPAwDXC/vhvqpfOHLlhgd+RPchbtqaZK97UP8K+nc1ckfoUF/y+8osyv5bRSNP5qyzqNc7MOI4XmLCMNipnE5Z4sBTPuZWFGUq8Cywr4OH1EzNv45pnHGaxKBmk1Tccnqv4bP0CjC9BwkV1Ej+rNfO/94SeNPEa663r41zuJSixNsyBevhsNy5d1cy1kXiJetEBnaRCDgIbNA+/cPOymdeZYcxymERWxE2A8687t02dH7ccEhAxgQ0Lbg9sXjbrt17mPRszUZ9GXJEKxk8AvDErdRaeY38yR7HjF2i9BHO/eszu/MF6yTZK5Ly2czr7m40aLBFtZhxH/1+Azx0lAoyDKGb832Gp3nPMvApxiHGlamVh+mualjYYyl3ZitCVRtutFLukaF5+ZuXETOmfAXajsFU+5y++f14mTbrGApnzleY2oLFUTfY6GCytT9PavWRy0Mz/IYTV3M6KZq9MGIl7fGOuVfa16TGoaslM+rJMsH7Gh/r3K+b6DyRYs5RozsayaSvO6nr6WeiDO/Ay7WqiOSWAxWEkBqr34Dl22w3DUs7Ec2xVHKIcqdouy8yYzjc4oswCJVwT96ryUmpuA4etx87AAAANekbd9xzLw/jf+7TLHGkup4i6uiQV1hV22wZHdXRjJAhjlIcljn7BGuB/9uySObTi8szVcYihqsclwHWfjyEqjI6YCHDt/pjqUSV8VYpHPxt/YuOkb6PzX1U2vRKzJ7SGKgFvDvTrXo1rMzu269jXXKtszlYmYDOTuklwiNZ3OaXXw0kNweXGFxdfoVcvm/lX7uGn4DP3KA2m2tAhnD3H2qTm4jn2D1VyW6wYykOYob4Z94QKIeqLrhqf+ZQNPWebSDMsGeHql2Ia4+f4zFEkWwSkcS9WYCu/H6wvyrw9ETJmoz2ice95zs/EPfB2BAioyGEEwG8N92gjKiZm3oolFeomfVZlzT9nD5ePy1RmQPiwW8X9Xzn/oHJCz5fdN0Q9C/A534W8Lt/t4tLo/JvN6Og9cSouKhf6pV4XOGUx32Zue8U6pfTG1ldTV8+b/I1TmkmPcwTwmQ1irf9PVjx2S8g5raSpJQKYjf4SCTR/6tPYYAzK0IxkS6CiOI97fLlX087fXDbr2ur5/u1RVJWiqLmWWnDxCymMacEIMF7f1tvhCj+2S2yhiLSnYbtYX9jrX2laSg5+l2qXApmggU0YgyQz+7TNOL2iKP09mWyzwhZEAKzCdnQXcK79EFFYW6yQmcgywOhrDJbcOrgw4/TKCRlLlW+rAmv+8U5Q3aFTu7uVZ+1OAxo8mrjJfN67o15trbj3bj88h8d3zv+qN39b72WeQjwQaPRc3T5GEky2DLEd13Tt37u3ue0VretXtzMjslzwm6uWzKLZjohgOVdow5JZa6vLZl3CufccPFMXOKc5cTThWfaxmZ8Egyn5G5fOUNpZMZ1TfPnKGZ1jzpj7tMv+f3vXAhvFcYZnZvfuDGdDsQPGZxsw8TMESJsoQB8p5hXFJBC/klClqEnTtGqqtE1VqSGgXIIAUUVNIyVSW5UkStKkODY1VRrkAgbnRUA4D4wDtrFr1yZgG0z8ANvn25l+65oIwdmczrfr3btZydrz7s4/M9/8M/P///zzz2V3QLty0LGCmR1QANeDZ5aiDl/YtR5GlBu894nK6G3gw6ciYbV/LIzqilJKELciG3LQ01AU5Fa4a8CiGrB5UY0jGTCWvPQ2xf/yMgEBij3+anH1yvhuEzKLuCyoQn5+omDW8YirmAkVwvj/p5OFqW9emdXXyr/+8NSBzbUKFXfjQ8mcV6Jk8d9QLk7AtfQZl+pKbz64LbflwNY35UqwxRstDMXTPTuaD26xlZtuGKptKxLNBzYfxnaAPEVR9ZgA5RC6bLeyajrglH6I1bt7MZbdHknxSZISUh+HMmKxiOpUY0K9344B30bjy5MFqVVxaam3EMp+g/7WMdp3UfEc9df3wy8oTL09moJk6XErEK3+WYfKYAQgr8KQKD3jCOWYg0pVqi7UT0uw6okekdgvwX8+hdHiuiLP0Uisn9F1gjywsa5g1itG5xOZ9Ok/MP7/4uq6gSevvdJyNy0Uwl8O34o5176VTyYcgeHgjPRjIsgeB1XKdaPNhJcpAguQtnTDY5wIK8bC6Mfe8oeb92+Vp3TYjO8yV3jn+jSfPhD/WAgxxWbFN6y4unAOt6USRWV/bNq7JWIFpAUVZ90DvUOvESEKDAMzeMIw8tN12PsdsZ4pSz5qnXThDHmEC/JbYJ4aPDT2/hILOM2Q355L8NCX7RLA0UjEs3Z3eohv4JeCiJ8in6lG5mU12sPeD4K+6lAdfzien9hotfKFqzzFtcL5+RetVoxphXGWFdYXp+wPV12NoJNV2vohZJJvG0E7dJpUw1j2hNVPnwB2O4Ddw6HX05iU6Ps7khJSfqYfj3p1DgGVf/2j+au3Teu51PMCFMwfXp1I/m8yAlD2sctFj2xdRRRSFRczpUru4Te+DSyp/FNSTVX6SPPerZ8Zj4DMwSgEstZsj/P19qzDhPEQBNLFRuVjebqUNmJyf8OlOP9St9f7peXLG4YCos1p9q7TzwjON4WBXEgkIBQ0CKKsqS/ynAyJgM0S3XpUOPpa2tYLTn5HiEi3WfGDLi5WdmsgI2xPmpayM5DAFzShCP0QRoA4MTT4E/DAryLfGEQ74fXwIk7EeOnKvb4R2rTEiso/+uMhJ3M+WFOY2GR13K2m/GOOamFUrD9ROOs9G2BnKeUf2PWi7/+6rjB1x2jYjar8X05wY+6T3/EL4sX/Ky4/k3cjEaB9EIb1/YrHYXg5hm0YR2fcMP2TQ28/gf1C8jITASsp/5hEGsAXG5sqt2CLngx4YiYfGJ3XnFVPZhM//REUk/sglKYZnd/E06fnGFb5OVPeaNm/+dDEl2diSpBV2qa39yswBkw2tQSU7HPFTLmv5u5vRF0Q2GIhlJrStrUIwLge82seVscdpmJvUGYQ5D6ghG0/UZT8Lzk/XB/kpQeEeubc6XxCxQ9gfL0LvOC6firrfwE+gAcV3Yv7W/EeUhZNXh9WUv51xRXK12YYXV62S3+0kPLfjWMnX3C7lO3V93hsEbPDKiv/ev/HVrfXGY3ZqB+DOtaIhW+Du+au3Jgh/PwBuM+twoD5TQyW7uBSyq9GEICcgaMWKOmgQnTg3i4I9uNR0SE4a6UKb3IyV+PJfz99xi6DRaS37EQq/1D04b5G66D0vyMI++d/Kp89Ivki0jmOkPRlG76lCVoIhbAAQml2pNRYN15h3oB7OX03IWN2pYxJ8v+WzSltzUAQiG1o70Kj2xqT/VnKmHd+QfJfZZAvQrJ3tSVwwe/HTugH0deWGI1/OOljLtDdOPVAr+WqSymvvcfz33DSjyZai949P6X7Un8++uADkMtW4K7aq/76Xn5yEDLD35VYUhate/ktoPzr26gqYdj+28yElN1287yZUOUf8i5khI8wru2cOmnSW4fzEnrs1AcnVvlH/6fiMypYmZOR144VprQFg13Qyv/VxOYVe50xA0Qd6MXhMfIaRkBxuoXDdVHEJRDe1h4vXLFdYvo8wqfX3iRKSorRQHLF1k6skrZ8QyIRdLaZZVYEu+hyKmdqK7xdZuYr87IeAmnLngLv8VXwEl8Jy+FyuKnGW6+UgUuEibwTbz7GBFPhUJ176vd5Le/2GLgm5jzNKWtbrAmxHW18R7hzxLwDF0Dxe1es8/ljd868GG76kUBv3u7WdL8fyp+gy4cNARZcCUY7XhKCVCgKLWeTxTvRquQZyW+6QQgLW7rxFeOu+C7ySjQyv9BpD7v0w/gjKh2TYspqV8+w3RGoodc9cEqv18t2zn/0lsBvjXjqI6qmDHEX6XdrUy/k5cdd8No4oG9WyeksnJRi0qKujyhC8Q9xNuhwqV/dsGbGeVivrtmXbkSrGUEzp+xLXU9IMIJ2IJqMcg2eXj6fQ+vxnPOfP/hQ2kCg78Z6FrLyPxZR+U4iIBGQCEgEwocABFE6Z+WmbJwVsBi/l1AiFkFRzIFRYOLdlimBQkk/h0fTEaLQw07qPCKV/dDaHkaA1VyIx6DkrYJgr4RGZSQVpW3gkdfdbsfzn+Yl6cYYeQWBAFzCY86ea1uMVeBcBHzNhcl+EfqZM4ikYf1k2GhDSDWUUXh9sQ+mefi+aHLjDiuYIRKDMSAT4+339D/wwR3gg7QQSY0rGXihBQTeh8D+HifK+9ESq2NcoMnEEgGJwKgISOV/VGjkC4mAREAiYF0Ebn30z47uxuYMjdObsYVoHgTUuRjQZ2OVdzaE1GQoDeNTHkeqDsHTB3qdI9uVWvF/A1ZI64VC611UrY+WQH1mcsLNu9sT/f6he4Xgy2AI+D7yvu4KJNpFXzn5FEprJYwxFesKkqvsvBJlJt5j5TV8YkC7chPR/Jlw38uEEpgJwwyUQv1Oxnlih370p+hE2zXC46ABqzkNoNngYKymKD+pTrbfWC1j/rucss4kTgazMRamo/3TcUJJOsbcdIy1N6L9xrVqCm+pi+i74ANyCi78CMhJTjGO3yym7nr7d81HQuYoEZAI2BkBqfzbufVk2SUCEgGJQAAEYAigC+98brLP3RXDu1kMYQ6XIH4XZ6rCNcI41RQVdz+8FhXi8DOFcAQXheezqqnCrxGhDjqdA/393HPp1J7HrXh8UoBaR+6jYXdkjWZRRZslOI3jhMZiSwjOjma9QiNdwkkbYpM9TdW3UXmeuYlssGDX2RkDnMdDkIrFMepxVKBdcIfxJRbxkdzw0NHw24ceN4h3g4QT3T2zi1G10zWZdKy9a+Z5qeCb2GAGZqUb7HxD2jSdFyjT3DovaOADSngsjAMjhgHRh2Pf+hgRfYLBY4oquIs+B1G/Or42sd3A4knSEgGJgETgawT+Bzh8e+ML3fmIAAAAAElFTkSuQmCC"},{}],86:[function(t,e,r){var n=function(t){var e=jsPDF;if(void 0===e)throw new Error("jsPDF not found");t=t||{},this.doc=new e("portrait","pt","letter"),this.docWidth=612,this.margin=void 0!==t.margin?t.margin:30,this.bodyWidth=612-2*this.margin,this.yPos=0,this.fontSize=[14],this.lineMargin=[[2,2]],this.textColor=[[0,0,0]],this.font=["helvetica"]};n.prototype.setFont=function(t,e){this.font.push(t),this.doc.setFont(this.font[this.font.length-1]),e&&e(),this.font.pop(),this.doc.setFont(this.font[this.font.length-1])},n.prototype.setFontSize=function(t,e,r){this.fontSize.push(t),this.lineMargin.push(e),this.doc.setFontSize(this.fontSize[this.fontSize.length-1]),r&&r(),this.fontSize.pop(),this.lineMargin.pop(),this.doc.setFontSize(this.fontSize[this.fontSize.length-1])},n.prototype.setTextColor=function(t,e){this.textColor.push(t),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1]),e&&e(),this.textColor.pop(),this.doc.setTextColor.apply(this.doc,this.textColor[this.textColor.length-1])},n.prototype.TEXT=function(t,e,r,n){var i=this;"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r=null),void 0!==r&&null!==r||(r=!0);var o=i.doc.splitTextToSize(t,2*i.bodyWidth);if(r){var s=i.fontSize[i.fontSize.length-1],a=i.lineMargin[i.lineMargin.length-1];o.forEach(function(t){i.YAXIS(a[0]),i.YAXIS(s),i.doc.text(t,i.margin+(e||0),i.yPos),i.YAXIS(a[1])})}else i.doc.text(o,i.margin+(e||0),i.yPos);n&&n()},n.prototype.HR=function(t,e){var r=t||0,n=this.docWidth-this.margin-this.margin-(t||0),i=e||0;this.LINE(r,i,n,i)},n.prototype.LINE=function(t,e,r,n){this.doc.line(t+this.margin,e+this.yPos,r+this.margin,n+this.yPos)},n.prototype.IMAGE=function(t,e,r,n,i){i=(i||0)+this.margin;var o=this.yPos,s=r,a=n;this.doc.addImage(t,e,i,o,s,a,void 0,"none"),this.YAXIS(a)},n.prototype.YAXIS=function(t){this.yPos+=t||0},n.prototype.NEXT_PAGE=function(){this.doc.addPage(),this.yPos=0},n.prototype.FONT_SIZE_HEADER=function(t){this.setFontSize(24,[12,8],t)},n.prototype.FONT_SIZE_SUBHEADER=function(t){this.setFontSize(18,[8,5],t)},n.prototype.FONT_SIZE_NORMAL=function(t){this.setFontSize(13,[2,2],t)},n.prototype.FONT_SIZE_SMALL=function(t){this.setFontSize(10,[2,2],t)},n.prototype.TEXT_COLOR_BLACK=function(t){this.setTextColor([0,0,0],t)},n.prototype.TEXT_COLOR_LIGHT_GREY=function(t){this.setTextColor([150,150,150],t)},n.prototype.TEXT_COLOR_GREY=function(t){this.setTextColor([51,51,51],t)},n.prototype.TEXT_COLOR_RED=function(t){this.setTextColor([255,0,0],t)},e.exports=n},{}],87:[function(t,e,r){var n=t("qrcode-canvas"),i=function(){};i.prototype.init=function(){this.qrcodedraw||(this.qrcodedraw=new n.QRCodeDraw,this.canvasEl=document.createElement("canvas"))},i.prototype.draw=function(t,e,r){this.init(),this.qrcodedraw.draw(this.canvasEl,t,e,r)},i.prototype.toDataURL=function(t,e,r){this.draw(t,e,function(t,e){if(t)return r?r(t):null;r(null,e.toDataURL("image/jpeg"))})},e.exports=new i},{"qrcode-canvas":322}],88:[function(t,e,r){e.exports=t("./lib/backup_generator")},{"./lib/backup_generator":84}],89:[function(t,e,r){(function(t){(function(){(function(){var n,i,o,s="3.1.0",a=1,u=2,c=4,f=8,h=16,l=32,d=64,p=128,b=256,y=30,v="...",g=150,m=16,w=0,_=1,E=2,S="Expected a function",k="__lodash_placeholder__",A="[object Arguments]",x="[object Array]",I="[object Boolean]",T="[object Date]",M="[object Error]",B="[object Function]",P="[object Number]",C="[object Object]",R="[object RegExp]",O="[object String]",L="[object ArrayBuffer]",j="[object Float32Array]",D="[object Float64Array]",N="[object Int8Array]",U="[object Int16Array]",H="[object Int32Array]",K="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",F="[object Uint32Array]",W=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,G=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39|#96);/g,X=/[&<>"'`]/g,Z=RegExp(Y.source),J=RegExp(X.source),Q=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,rt=/\w*$/,nt=/^\s*function[ \n\r\t]+\w/,it=/^0[xX]/,ot=/^\[object .+?Constructor\]$/,st=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,at=/($^)/,ut=/[.*+?^${}()|[\]\/\\]/g,ct=RegExp(ut.source),ft=/\bthis\b/,ht=/['\n\r\u2028\u2029\\]/g,lt=(i="[A-Z\\xc0-\\xd6\\xd8-\\xde]",o="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(i+"{2,}(?="+i+o+")|"+i+"?"+o+"|"+i+"+|[0-9]+","g")),dt=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎              ",pt=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","document","isFinite","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","window","WinRTError"],bt=-1,yt={};yt[j]=yt[D]=yt[N]=yt[U]=yt[H]=yt[K]=yt[z]=yt[q]=yt[F]=!0,yt[A]=yt[x]=yt[L]=yt[I]=yt[T]=yt[M]=yt[B]=yt["[object Map]"]=yt[P]=yt[C]=yt[R]=yt["[object Set]"]=yt[O]=yt["[object WeakMap]"]=!1;var vt={};vt[A]=vt[x]=vt[L]=vt[I]=vt[T]=vt[j]=vt[D]=vt[N]=vt[U]=vt[H]=vt[P]=vt[C]=vt[R]=vt[O]=vt[K]=vt[z]=vt[q]=vt[F]=!0,vt[M]=vt[B]=vt["[object Map]"]=vt["[object Set]"]=vt["[object WeakMap]"]=!1;var gt={leading:!1,maxWait:0,trailing:!1},mt={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},wt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},_t={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Et={function:!0,object:!0},St={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},kt=Et[typeof window]&&window!==(this&&this.window)?window:this,At=Et[typeof r]&&r&&!r.nodeType&&r,xt=Et[typeof e]&&e&&!e.nodeType&&e,It=At&&xt&&"object"==typeof t&&t;!It||It.global!==It&&It.window!==It&&It.self!==It||(kt=It);var Tt=xt&&xt.exports===At&&At;function Mt(t,e){if(t!==e){var r=t==t,n=e==e;if(t>e||!r||void 0===t&&n)return 1;if(t-1;);return r}function Lt(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function jt(t,e){return Mt(t.criteria,e.criteria)||t.index-e.index}function Dt(t,e){for(var r=-1,n=t.criteria,i=e.criteria,o=n.length;++r=9&&t<=13||32==t||160==t||5760==t||6158==t||t>=8192&&(t<=8202||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function Ft(t,e){for(var r=-1,n=t.length,i=-1,o=[];++r>>1,Pe=be?be.BYTES_PER_ELEMENT:0,Ce=wt.pow(2,53)-1,Re=pe&&new pe;function Oe(t){if(zt(t)&&!Fn(t)){if(t instanceof Le)return t;if(Jt.call(t,"__wrapped__"))return new Le(t.__wrapped__,t.__chain__,Ke(t.__actions__))}return new Le(t)}function Le(t,e,r){this.__actions__=r||[],this.__chain__=!!e,this.__wrapped__=t}var je=Oe.support={};function De(t){this.actions=null,this.dir=1,this.dropCount=0,this.filtered=!1,this.iteratees=null,this.takeCount=Ie,this.views=null,this.wrapped=t}function Ne(){this.__data__={}}function Ue(t){var e=t?t.length:0;for(this.data={hash:ve(null),set:new fe};e--;)this.push(t[e])}function He(t,e){var r=t.data;return("string"==typeof e||Xn(e)?r.set.has(e):r.hash[e])?0:-1}function Ke(t,e){var n=-1,i=t.length;for(e||(e=r(i));++nn&&(n=i)}return n}function Ge(t,e,r,n){var i=-1,o=t.length;for(n&&o&&(r=t[++i]);++i=200&&Ur(e),u=e.length;a&&(o=He,s=!1,e=a);t:for(;++ic))return!1;for(;h&&++uo?0:o+e),(n=void 0===n||n>o?o:+n||0)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i=200,a=s&&Ur(),u=[];a?(n=He,o=!1):(s=!1,a=e?[]:u);t:for(;++r>>1,s=t[o];(r?s<=e:s3&&Zr(arguments[1],arguments[2],arguments[3])&&(e=2),e>3&&"function"==typeof arguments[e-2])var n=Rr(arguments[--e-1],arguments[e--],5);else e>2&&"function"==typeof arguments[e-1]&&(n=arguments[--e]);for(var i=0;++ii)||u===n&&u===o)&&(i=u,o=t)}),o}(r,n,e)}}function qr(t,e,i,o,s,p,y,v,g,m){var w=e&b,_=e&a,E=e&u,S=e&f,k=e&c,A=e&h,x=!E&&Kr(t),I=t;return function c(){for(var f=arguments.length,h=f,b=r(f);h--;)b[h]=arguments[h];if(o&&(b=Lr(b,o,s)),p&&(b=jr(b,p,y)),S||A){var T=c.placeholder,M=Ft(b,T);if((f-=M.length)=(e=+e)||!ge(e))return"";var i=e-n;return pi(r=null==r?" ":r+"",ie(i/r.length)).slice(0,i)}function Wr(t,e,n,i,o,s,f,y){var v=e&u;if(!v&&!Yn(t))throw new xt(S);var g=i?i.length:0;if(g||(e&=~(l|d),i=o=null),g-=o?o.length:0,e&d){var m=i,w=o;i=o=null}var _=!v&&Gr(t),E=[t,e,n,i,o,m,w,s,f,y];if(_&&!0!==_&&(function(t,e){var r=t[1],n=e[1],i=r|n,o=b|p,s=a|u,f=o|s|c|h,l=r&b&&!(n&b),d=r&p&&!(n&p),y=(d?t:e)[7],v=(l?t:e)[8],g=!(r>=p&&n>s||r>s&&n>=p),m=i>=o&&i<=f&&(r-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}function Qr(t){return t==t&&(0===t?1/t>0:!Xn(t))}function $r(t,e){t=un(t);for(var r=-1,n=e.length,i={};++r0){if(++en>=g)return t}else en=0;return Ar(t,e)});function on(t){var e,r;return Oe.support,!(!zt(t)||$t.call(t)!=C||!(Jt.call(t,"constructor")||"function"!=typeof(e=t.constructor)||e instanceof e))&&(pr(t,function(t,e){r=e}),void 0===r||Jt.call(t,r))}function sn(t){for(var e=si(t),r=e.length,n=r&&t.length,i=Oe.support,o=n&&Jr(n)&&(Fn(t)||i.nonEnumArgs&&qn(t)),s=-1,a=[];++s>>0,i=r(n);++e-1:Yr(t,e,r)>-1)}var _n=Dr(function(t,e,r){Jt.call(t,r)?++t[r]:t[r]=1});function En(t,e,r){var n=Fn(t)?qe:ur;return"function"==typeof e&&void 0===r||(e=Vr(e,r,3)),n(t,e)}function Sn(t,e,r){return(Fn(t)?Fe:cr)(t,e=Vr(e,r,3))}function kn(t,e,r){if(Fn(t)){var i=hn(t,e,r);return i>-1?t[i]:n}return fr(t,e=Vr(e,r,3),sr)}function An(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?ze(t,e):sr(t,Rr(e,r,3))}function xn(t,e,r){return"function"==typeof e&&void 0===r&&Fn(t)?function(t,e){for(var r=t.length;r--&&!1!==e(t[r],r,t););return t}(t,e):ar(t,Rr(e,r,3))}var In=Dr(function(t,e,r){Jt.call(t,r)?t[r].push(e):t[r]=[e]}),Tn=Dr(function(t,e,r){t[r]=e});function Mn(t,e,r){return(Fn(t)?We:wr)(t,e=Vr(e,r,3))}var Bn=zr(Ve),Pn=zr(function(t){for(var e=-1,r=t.length,n=Ie;++e0?t[Sr(0,i-1)]:n}var o=jn(t);return o.length=_e(e<0?0:+e||0,o.length),o}function jn(t){for(var e=-1,n=(t=an(t)).length,i=r(n);++e0?r=e.apply(this,arguments):e=null,r}}function Hn(t,e,r){var i,o,s,a,u,c,f,h=0,l=!1,d=!0;if(!Yn(t))throw new xt(S);if(e=e<0?0:e,!0===r){var p=!0;d=!1}else Xn(r)&&(p=r.leading,l="maxWait"in r&&we(+r.maxWait||0,e),d="trailing"in r?r.trailing:d);function b(){var r=e-(Nn()-a);if(r<=0||r>e){o&&oe(o);var l=f;o=c=f=n,l&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}else c=he(b,r)}function y(){c&&oe(c),o=c=f=n,(d||l!==e)&&(h=Nn(),s=t.apply(u,i),c||o||(i=u=null))}function v(){if(i=arguments,a=Nn(),u=this,f=d&&(c||!p),!1===l)var r=p&&!c;else{o||p||(h=a);var n=l-(a-h),v=n<=0||n>l;v?(o&&(o=oe(o)),h=a,s=t.apply(u,i)):o||(o=he(y,n))}return v&&c?c=oe(c):c||e===l||(c=he(b,e)),r&&(v=!0,s=t.apply(u,i)),!v||c||o||(i=u=null),s}return v.cancel=function(){c&&oe(c),o&&oe(o),o=c=f=n},v}function Kn(){var t=arguments,e=t.length-1;if(e<0)return function(){};if(!qe(t,Yn))throw new xt(S);return function(){for(var r=e,n=t[r].apply(this,arguments);r--;)n=t[r].call(this,n);return n}}function zn(t,e){if(!Yn(t)||e&&!Yn(e))throw new xt(S);var r=function(){var n=r.cache,i=e?e.apply(this,arguments):arguments[0];if(n.has(i))return n.get(i);var o=t.apply(this,arguments);return n.set(i,o),o};return r.cache=new zn.Cache,r}function qn(t){return Jr(zt(t)?t.length:n)&&$t.call(t)==A||!1}var Fn=ye||function(t){return zt(t)&&Jr(t.length)&&$t.call(t)==x||!1};function Wn(t){return t&&1===t.nodeType&&zt(t)&&$t.call(t).indexOf("Element")>-1||!1}function Vn(t){return zt(t)&&"string"==typeof t.message&&$t.call(t)==M||!1}je.dom||(Wn=function(t){return t&&1===t.nodeType&&zt(t)&&!Qn(t)||!1});var Gn=Se||function(t){return"number"==typeof t&&ge(t)};function Yn(t){return"function"==typeof t||!1}function Xn(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}function Zn(t){return null!=t&&($t.call(t)==B?ee.test(Xt.call(t)):zt(t)&&ot.test(t)||!1)}function Jn(t){return"number"==typeof t||zt(t)&&$t.call(t)==P||!1}(Yn(/x/)||de&&!Yn(de))&&(Yn=function(t){return $t.call(t)==B});var Qn=ae?function(t){if(!t||$t.call(t)!=C)return!1;var e=t.valueOf,r=Zn(e)&&(r=ae(e))&&ae(r);return r?t==r||ae(t)==r:on(t)}:on;function $n(t){return zt(t)&&$t.call(t)==R||!1}function ti(t){return"string"==typeof t||zt(t)&&$t.call(t)==O||!1}function ei(t){return zt(t)&&Jr(t.length)&&yt[$t.call(t)]||!1}function ri(t){return tr(t,si(t))}var ni=Nr(Qe);function ii(t){return vr(t,si(t))}var oi=me?function(t){if(t)var e=t.constructor,r=t.length;return"function"==typeof e&&e.prototype===t||"function"!=typeof t&&r&&Jr(r)?sn(t):Xn(t)?me(t):[]}:sn;function si(t){if(null==t)return[];Xn(t)||(t=Et(t));var e=t.length;e=e&&Jr(e)&&(Fn(t)||je.nonEnumArgs&&qn(t))&&e||0;for(var n=t.constructor,i=-1,o="function"==typeof n&&n.prototype==t,s=r(e),a=e>0;++i2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(e,n,r,i,o)},Oe.bindAll=function(t){return function(t,e){for(var r=-1,n=e.length;++r1?hr(arguments,!1,!1,1):ii(t))},Oe.bindKey=function t(e,r){var n=a|u;if(arguments.length>2){var i=xr(arguments,2),o=Ft(i,t.placeholder);n|=l}return Wr(r,n,e,i,o)},Oe.callback=_i,Oe.chain=gn,Oe.chunk=function(t,e,n){e=(n?Zr(t,e,n):null==e)?1:we(+e||1,1);for(var i=0,o=t?t.length:0,s=-1,a=r(ie(o/e));i=120&&Ur(e&&s)))}r=t.length;var a=t[0],u=-1,c=a?a.length:0,f=[],h=n[0];t:for(;++u-1;)le.call(t,i,1);return t},Oe.pullAt=function(t){return function(t,e){var r=e.length,n=$e(t,e);for(e.sort(Mt);r--;){var i=parseFloat(e[r]);if(i!=o&&Xr(i)){var o=i;le.call(t,i,1)}}return n}(t||[],hr(arguments,!1,!1,1))},Oe.range=function(t,e,n){n&&Zr(t,e,n)&&(e=n=null),t=+t||0,n=null==n?1:+n||0,null==e?(e=t,t=0):e=+e||0;for(var i=-1,o=we(ie((e-t)/(n||1)),0),s=r(o);++i3&&Zr(e[1],e[2],e[3])&&(e=[t,e[1]]);var i=-1,o=t?t.length:0,s=hr(e,!1,!1,1),a=Jr(o)?r(o):[];return sr(t,function(t,e,o){for(var u=s.length,c=r(u);u--;)c[u]=null==t?n:t[s[u]];a[++i]={criteria:c,index:i,value:t}}),Pt(a,Dt)},Oe.take=function(t,e,r){return t&&t.length?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,0,e<0?0:e)):[]},Oe.takeRight=function(t,e,r){var n=t?t.length:0;return n?((r?Zr(t,e,r):null==e)&&(e=1),xr(t,(e=n-(+e||0))<0?0:e)):[]},Oe.takeRightWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];for(e=Vr(e,r,3);n--&&e(t[n],n,t););return xr(t,n+1)},Oe.takeWhile=function(t,e,r){var n=t?t.length:0;if(!n)return[];var i=-1;for(e=Vr(e,r,3);++i=0&&t.indexOf(e,r)==r},Oe.escape=function(t){return(t=Ct(t))&&J.test(t)?t.replace(X,Ut):t},Oe.escapeRegExp=hi,Oe.every=En,Oe.find=kn,Oe.findIndex=hn,Oe.findKey=function(t,e,r){return fr(t,e=Vr(e,r,3),br,!0)},Oe.findLast=function(t,e,r){return fr(t,e=Vr(e,r,3),ar)},Oe.findLastIndex=function(t,e,r){var n=t?t.length:0;for(e=Vr(e,r,3);n--;)if(e(t[n],n,t))return n;return-1},Oe.findLastKey=function(t,e,r){return fr(t,e=Vr(e,r,3),yr,!0)},Oe.findWhere=function(t,e){return kn(t,_r(e))},Oe.first=ln,Oe.has=function(t,e){return!!t&&Jt.call(t,e)},Oe.identity=Si,Oe.includes=wn,Oe.indexOf=dn,Oe.isArguments=qn,Oe.isArray=Fn,Oe.isBoolean=function(t){return!0===t||!1===t||zt(t)&&$t.call(t)==I||!1},Oe.isDate=function(t){return zt(t)&&$t.call(t)==T||!1},Oe.isElement=Wn,Oe.isEmpty=function(t){if(null==t)return!0;var e=t.length;return Jr(e)&&(Fn(t)||ti(t)||qn(t)||zt(t)&&Yn(t.splice))?!e:!oi(t).length},Oe.isEqual=function(t,e,r,i){if(!(r="function"==typeof r&&Rr(r,i,3))&&Qr(t)&&Qr(e))return t===e;var o=r?r(t,e):n;return void 0===o?gr(t,e,r):!!o},Oe.isError=Vn,Oe.isFinite=Gn,Oe.isFunction=Yn,Oe.isMatch=function(t,e,n,i){var o=oi(e),s=o.length;if(!(n="function"==typeof n&&Rr(n,i,3))&&1==s){var a=o[0],u=e[a];if(Qr(u))return null!=t&&u===t[a]&&Jt.call(t,a)}for(var c=r(s),f=r(s);s--;)u=c[s]=e[o[s]],f[s]=Qr(u);return mr(t,o,c,f,n)},Oe.isNaN=function(t){return Jn(t)&&t!=+t},Oe.isNative=Zn,Oe.isNull=function(t){return null===t},Oe.isNumber=Jn,Oe.isObject=Xn,Oe.isPlainObject=Qn,Oe.isRegExp=$n,Oe.isString=ti,Oe.isTypedArray=ei,Oe.isUndefined=function(t){return void 0===t},Oe.kebabCase=li,Oe.last=function(t){var e=t?t.length:0;return e?t[e-1]:n},Oe.lastIndexOf=function(t,e,r){var n=t?t.length:0;if(!n)return-1;var i=n;if("number"==typeof r)i=(r<0?we(n+r,0):_e(r||0,n-1))+1;else if(r){var o=t[i=Pr(t,e,!0)-1];return(e==e?e===o:o!=o)?i:-1}if(e!=e)return Kt(t,i,!0);for(;i--;)if(t[i]===e)return i;return-1},Oe.max=Bn,Oe.min=Pn,Oe.noConflict=function(){return e._=te,this},Oe.noop=xi,Oe.now=Nn,Oe.pad=function(t,e,r){e=+e;var n=(t=Ct(t)).length;if(n>=e||!ge(e))return t;var i=(e-n)/2,o=se(i);return(r=Fr("",ie(i),r)).slice(0,o)+t+r},Oe.padLeft=function(t,e,r){return(t=Ct(t))&&Fr(t,e,r)+t},Oe.padRight=function(t,e,r){return(t=Ct(t))&&t+Fr(t,e,r)},Oe.parseInt=di,Oe.random=function(t,e,r){r&&Zr(t,e,r)&&(e=r=null);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var o=Ae();return _e(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return Sr(t,e)},Oe.reduce=Rn,Oe.reduceRight=On,Oe.repeat=pi,Oe.result=function(t,e,r){var i=null==t?n:t[e];return void 0===i&&(i=r),Yn(i)?i.call(t):i},Oe.runInContext=t,Oe.size=function(t){var e=t?t.length:0;return Jr(e)?e:oi(t).length},Oe.snakeCase=yi,Oe.some=Dn,Oe.sortedIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e):Cr(t,e,i(r,n,1))},Oe.sortedLastIndex=function(t,e,r,n){var i=Vr(r);return i===er&&null==r?Pr(t,e,!0):Cr(t,e,i(r,n,1),!0)},Oe.startCase=vi,Oe.startsWith=function(t,e,r){return t=Ct(t),r=null==r?0:_e(r<0?0:+r||0,t.length),t.lastIndexOf(e,r)==r},Oe.template=function(t,e,r){var i=Oe.templateSettings;r&&Zr(t,e,r)&&(e=r=null),t=Ct(t);var o,s,a=Qe(Qe({},(e=Qe(Qe({},r||e),i,Je)).imports),i.imports,Je),u=oi(a),c=Mr(a,u),f=0,h=e.interpolate||at,l="__p += '",d=St((e.escape||at).source+"|"+h.source+"|"+(h===tt?et:at).source+"|"+(e.evaluate||at).source+"|$","g"),p="//# sourceURL="+("sourceURL"in e?e.sourceURL:"lodash.templateSources["+ ++bt+"]")+"\n";t.replace(d,function(e,r,n,i,a,u){return n||(n=i),l+=t.slice(f,u).replace(ht,Ht),r&&(o=!0,l+="' +\n__e("+r+") +\n'"),a&&(s=!0,l+="';\n"+a+";\n__p += '"),n&&(l+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),l+="';\n";var b=e.variable;b||(l="with (obj) {\n"+l+"\n}\n"),l=(s?l.replace(W,""):l).replace(V,"$1").replace(G,"$1;"),l="function("+(b||"obj")+") {\n"+(b?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var y=wi(function(){return mt(u,p+"return "+l).apply(n,c)});if(y.source=l,Vn(y))throw y;return y},Oe.trim=gi,Oe.trimLeft=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(Wt(t)):t.slice(Ot(t,e+"")):t},Oe.trimRight=function(t,e,r){var n=t;return(t=Ct(t))?(r?Zr(n,e,r):null==e)?t.slice(0,Vt(t)+1):t.slice(0,Lt(t,e+"")+1):t},Oe.trunc=function(t,e,r){r&&Zr(t,e,r)&&(e=null);var n=y,i=v;if(null!=e)if(Xn(e)){var o="separator"in e?e.separator:o;n="length"in e?+e.length||0:n,i="omission"in e?Ct(e.omission):i}else n=+e||0;if(n>=(t=Ct(t)).length)return t;var s=n-i.length;if(s<1)return i;var a=t.slice(0,s);if(null==o)return a+i;if($n(o)){if(t.slice(s).search(o)){var u,c,f=t.slice(0,s);for(o.global||(o=St(o.source,(rt.exec(o)||"")+"g")),o.lastIndex=0;u=o.exec(f);)c=u.index;a=a.slice(0,null==c?s:c)}}else if(t.indexOf(o,s)!=s){var h=a.lastIndexOf(o);h>-1&&(a=a.slice(0,h))}return a+i},Oe.unescape=function(t){return(t=Ct(t))&&Z.test(t)?t.replace(Y,Gt):t},Oe.uniqueId=function(t){var e=++Qt;return Ct(t)+e},Oe.words=mi,Oe.all=En,Oe.any=Dn,Oe.contains=wn,Oe.detect=kn,Oe.foldl=Rn,Oe.foldr=On,Oe.head=ln,Oe.include=wn,Oe.inject=Rn,Ai(Oe,(bi={},br(Oe,function(t,e){Oe.prototype[e]||(bi[e]=t)}),bi),!1),Oe.sample=Ln,Oe.prototype.sample=function(t){return this.__chain__||null!=t?this.thru(function(e){return Ln(e,t)}):Ln(this.value())},Oe.VERSION=s,ze(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){Oe[t].placeholder=Oe}),ze(["filter","map","takeWhile"],function(t,e){var r=e==w;De.prototype[t]=function(t,n){var i=this.clone(),o=i.filtered,s=i.iteratees||(i.iteratees=[]);return i.filtered=o||r||e==E&&i.dir<0,s.push({iteratee:Vr(t,n,3),type:e}),i}}),ze(["drop","take"],function(t,e){var r=t+"Count",n=t+"While";De.prototype[t]=function(n){n=null==n?1:we(+n||0,0);var i=this.clone();if(i.filtered){var o=i[r];i[r]=e?_e(o,n):o+n}else(i.views||(i.views=[])).push({size:n,type:t+(i.dir<0?"Right":"")});return i},De.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()},De.prototype[t+"RightWhile"]=function(t,e){return this.reverse()[n](t,e).reverse()}}),ze(["first","last"],function(t,e){var r="take"+(e?"Right":"");De.prototype[t]=function(){return this[r](1).value()[0]}}),ze(["initial","rest"],function(t,e){var r="drop"+(e?"":"Right");De.prototype[t]=function(){return this[r](1)}}),ze(["pluck","where"],function(t,e){var r=e?"filter":"map",n=e?_r:Er;De.prototype[t]=function(t){return this[r](n(e?t:t+""))}}),De.prototype.dropWhile=function(t,e){var r,n,i=this.dir<0;return t=Vr(t,e,3),this.filter(function(e,o,s){return r=r&&(i?on),n=o,r||(r=!t(e,o,s))})},De.prototype.reject=function(t,e){return t=Vr(t,e,3),this.filter(function(e,r,n){return!t(e,r,n)})},De.prototype.slice=function(t,e){var r=(t=null==t?0:+t||0)<0?this.takeRight(-t):this.drop(t);return void 0!==e&&(r=(e=+e||0)<0?r.dropRight(-e):r.take(e-t)),r},br(De.prototype,function(t,e){var r=Oe[e],n=/^(?:first|last)$/.test(e);Oe.prototype[e]=function(){var e=this.__wrapped__,i=arguments,o=this.__chain__,s=!!this.__actions__.length,a=e instanceof De,u=a&&!s;if(n&&!o)return u?t.call(e):r.call(Oe,this.value());var c=function(t){var e=[t];return ue.apply(e,i),r.apply(Oe,e)};if(a||Fn(e)){var f=u?e:new De(this),h=t.apply(f,i);return n||!s&&!h.actions||(h.actions||(h.actions=[])).push({func:mn,args:[c],thisArg:Oe}),new Le(h,o)}return this.thru(c)}}),ze(["concat","join","pop","push","shift","sort","splice","unshift"],function(t){var e=It[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:join|pop|shift)$/.test(t);Oe.prototype[t]=function(){var t=arguments;return n&&!this.__chain__?e.apply(this.value(),t):this[r](function(r){return e.apply(r,t)})}}),De.prototype.clone=function(){var t=this.actions,e=this.iteratees,r=this.views,n=new De(this.wrapped);return n.actions=t?Ke(t):null,n.dir=this.dir,n.dropCount=this.dropCount,n.filtered=this.filtered,n.iteratees=e?Ke(e):null,n.takeCount=this.takeCount,n.views=r?Ke(r):null,n},De.prototype.reverse=function(){if(this.filtered){var t=new De(this);t.dir=-1,t.filtered=!0}else(t=this.clone()).dir*=-1;return t},De.prototype.value=function(){var t=this.wrapped.value();if(!Fn(t))return Br(t,this.actions);var e=this.dir,r=e<0,n=function(t,e,r){for(var n=-1,i=r?r.length:0;++n=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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?""};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"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:c[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,u="le"===e,c=new t(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(g,v),g.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new g;else if("p224"===t)e=new m;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],91:[function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}e.exports=n,n.from=t("./from.js"),n.to=t("./to.js"),n.is=t("./is.js"),n.subarray=t("./subarray.js"),n.join=t("./join.js"),n.copy=t("./copy.js"),n.create=t("./create.js"),i(t("./read.js"),n),i(t("./write.js"),n)},{"./copy.js":92,"./create.js":93,"./from.js":94,"./is.js":95,"./join.js":96,"./read.js":98,"./subarray.js":99,"./to.js":100,"./write.js":101}],92:[function(t,e,r){e.exports=function(t,e,r,i,o){if(r=arguments.length<3?0:r,i=arguments.length<4?0:i,(o=arguments.length<5?t.length:o)===i)return;if(0===e.length||0===t.length)return;o>t.length&&(o=t.length);e.length-r0&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r,n=[],i=0,o=t.length;i>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},{"base64-js":30,"to-utf8":373}],101:[function(t,e,r){e.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=t("./mapped.js")},{"./mapped.js":97}],102:[function(t,e,r){!function(t,r){void 0!==e&&e.exports?e.exports.browser=r():this.bowser=r()}(0,function(){var t=!0;function e(e){function r(t){var r=e.match(t);return r&&r.length>1&&r[1]||""}var n,i,o,s=r(/(ipod|iphone|ipad)/i).toLowerCase(),a=!/like android/i.test(e)&&/android/i.test(e),u=r(/edge\/(\d+(\.\d+)?)/i),c=r(/version\/(\d+(\.\d+)?)/i),f=/tablet/i.test(e),h=!f&&/[^-]mobi/i.test(e);/opera|opr/i.test(e)?n={name:"Opera",opera:t,version:c||r(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(e)?(n={name:"Windows Phone",windowsphone:t},u?(n.msedge=t,n.version=u):(n.msie=t,n.version=r(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(e)?n={name:"Internet Explorer",msie:t,version:r(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(e)?n={name:"Microsoft Edge",msedge:t,version:u}:/chrome|crios|crmo/i.test(e)?n={name:"Chrome",chrome:t,version:r(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:s?(n={name:"iphone"==s?"iPhone":"ipad"==s?"iPad":"iPod"},c&&(n.version=c)):/sailfish/i.test(e)?n={name:"Sailfish",sailfish:t,version:r(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(e)?n={name:"SeaMonkey",seamonkey:t,version:r(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(e)?(n={name:"Firefox",firefox:t,version:r(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(e)&&(n.firefoxos=t)):/silk/i.test(e)?n={name:"Amazon Silk",silk:t,version:r(/silk\/(\d+(\.\d+)?)/i)}:a?n={name:"Android",version:c}:/phantom/i.test(e)?n={name:"PhantomJS",phantom:t,version:r(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(e)||/rim\stablet/i.test(e)?n={name:"BlackBerry",blackberry:t,version:c||r(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(e)?(n={name:"WebOS",webos:t,version:c||r(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(e)&&(n.touchpad=t)):n=/bada/i.test(e)?{name:"Bada",bada:t,version:r(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(e)?{name:"Tizen",tizen:t,version:r(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(e)?{name:"Safari",safari:t,version:c}:{name:r(/^(.*)\/(.*) /),version:(i=/^(.*)\/(.*) /,o=e.match(i),o&&o.length>1&&o[2]||"")},!n.msedge&&/(apple)?webkit/i.test(e)?(n.name=n.name||"Webkit",n.webkit=t,!n.version&&c&&(n.version=c)):!n.opera&&/gecko\//i.test(e)&&(n.name=n.name||"Gecko",n.gecko=t,n.version=n.version||r(/gecko\/(\d+(\.\d+)?)/i)),n.msedge||!a&&!n.silk?s&&(n[s]=t,n.ios=t):n.android=t;var l="";n.windowsphone?l=r(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):s?l=(l=r(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):a?l=r(/android[ \/-](\d+(\.\d+)*)/i):n.webos?l=r(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):n.blackberry?l=r(/rim\stablet\sos\s(\d+(\.\d+)*)/i):n.bada?l=r(/bada\/(\d+(\.\d+)*)/i):n.tizen&&(l=r(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(n.osversion=l);var d=l.split(".")[0];return f||"ipad"==s||a&&(3==d||4==d&&!h)||n.silk?n.tablet=t:(h||"iphone"==s||"ipod"==s||a||n.blackberry||n.webos||n.bada)&&(n.mobile=t),n.msedge||n.msie&&n.version>=10||n.chrome&&n.version>=20||n.firefox&&n.version>=20||n.safari&&n.version>=6||n.opera&&n.version>=10||n.ios&&n.osversion&&n.osversion.split(".")[0]>=6||n.blackberry&&n.version>=10.1?n.a=t:n.msie&&n.version<10||n.chrome&&n.version<20||n.firefox&&n.version<20||n.safari&&n.version<6||n.opera&&n.version<10||n.ios&&n.osversion&&n.osversion.split(".")[0]<6?n.c=t:n.x=t,n}var r=e("undefined"!=typeof navigator?navigator.userAgent:"");return r.test=function(t){for(var e=0;e>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[v++],s=c[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[v++],a=c[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[v++],u=c[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[v++],d=o,p=s,b=a,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[v++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[v++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[v++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[v++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=t[s],h=t[f],l=t[h],d=257*t[c]^16843008*c;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][c]=d<<24|d>>>8,o[1][c]=d<<16|d>>>16,o[2][c]=d<<8|d>>>24,o[3][c]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(t){this._key=n(t),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u],u^=s[o/e|0]<<24):e>6&&o%e==4&&(u=a.SBOX[u>>>24]<<24|a.SBOX[u>>>16&255]<<16|a.SBOX[u>>>8&255]<<8|a.SBOX[255&u]),i[o]=i[o-e]^u}for(var c=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},u.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},u.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},{"safe-buffer":345}],105:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),u=t("./incr32");function c(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(a);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,c=Buffer.alloc(8);c.writeUIntBE(a,0,8),n.update(c),t._finID=n.state;var f=Buffer.from(t._finID);return u(f),f}(this,r,c),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(c,i),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":104,"./authCipher":105,"./modes":117,"./streamCipher":120,"cipher-base":134,evp_bytestokey:238,inherits:279,"safe-buffer":345}],108:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),u=t("evp_bytestokey");function c(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r)}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":345}],110:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],111:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":129}],112:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":129,"safe-buffer":345}],113:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,u=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,u+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return u}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(N(t,ArrayBuffer)||t&&N(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+h<=r)switch(h){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(N(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),u=this.slice(n,i),c=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return v(this,t,e,r);case"latin1":case"binary":return g(this,t,e,r);case"base64":return m(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function B(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function P(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function C(t,e,r,i,o){return e=+e,r>>>=0,o||B(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return P(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return P(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":131,buffer:130,ieee754:278}],131:[function(t,e,r){"use strict";r.byteLength=function(t){var e=c(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=c(t),s=n[0],a=n[1],u=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,u[f++]=e>>8&255,u[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,u[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,u[f++]=e>>8&255,u[f++]=255&e);return u},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],132:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),u=t.slice(n+1);if(u.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=u.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=c(r).xor(new BigInteger(""+u)),s+=n.charAt(u)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var u=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==u)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:u}}(u[0]);if(1+c.hashSize/8!==u.length)throw new Error("Hash length does not match version");return{version:c.scriptType,prefix:e.prefix,hash:Buffer.from(u.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(u(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":132,buffer:130}],134:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:279,"safe-buffer":345,stream:259,string_decoder:260}],135:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:u(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,c=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+r:u+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 c=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[c-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,h=67108863&u,l=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=l;d++){var p=c-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],v=8191&y,g=y>>>13,m=0|s[3],w=8191&m,_=m>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],M=8191&T,B=T>>>13,P=0|s[7],C=8191&P,R=P>>>13,O=0|s[8],L=8191&O,j=O>>>13,D=0|s[9],N=8191&D,U=D>>>13,H=0|a[0],K=8191&H,z=H>>>13,q=0|a[1],F=8191&q,W=q>>>13,V=0|a[2],G=8191&V,Y=V>>>13,X=0|a[3],Z=8191&X,J=X>>>13,Q=0|a[4],$=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,z))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,z))+Math.imul(b,K)|0,o=Math.imul(b,z);var vt=(c+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,z))+Math.imul(g,K)|0,o=Math.imul(g,z),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var gt=(c+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;c=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,K),i=(i=Math.imul(w,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var mt=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,J)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(k,K)|0,o=Math.imul(k,z),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0;var wt=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(I,K)|0,o=Math.imul(I,z),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0;var _t=(c+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;c=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(B,K)|0,o=Math.imul(B,z),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(c+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;c=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(R,K)|0,o=Math.imul(R,z),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(B,F)|0,o=o+Math.imul(B,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(c+(n=n+Math.imul(h,ut)|0)|0)+((8191&(i=(i=i+Math.imul(h,ct)|0)+Math.imul(l,ut)|0))<<13)|0;c=((o=o+Math.imul(l,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(j,K)|0,o=Math.imul(j,z),n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ct)|0;var kt=(c+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;c=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,z))+Math.imul(U,K)|0,o=Math.imul(U,z),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(C,G)|0,i=(i=i+Math.imul(C,Y)|0)+Math.imul(R,G)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(B,Z)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(I,$)|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(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,ct)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(c+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;c=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(B,$)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,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(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(v,ht)|0,i=(i=i+Math.imul(v,lt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,lt)|0;var xt=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;c=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,G),i=(i=Math.imul(N,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,J)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,J)|0,n=n+Math.imul(C,$)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(k,ut)|0,o=o+Math.imul(k,ct)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var It=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,bt)|0)+Math.imul(g,pt)|0))<<13)|0;c=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,Z),i=(i=Math.imul(N,J))+Math.imul(U,Z)|0,o=Math.imul(U,J),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,$)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(x,ut)|0,i=(i=i+Math.imul(x,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(c+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,tt))+Math.imul(U,$)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ct)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,lt)|0;var Mt=(c+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;c=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(C,ut)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,lt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,lt)|0;var Bt=(c+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ut)|0,i=(i=i+Math.imul(L,ct)|0)+Math.imul(j,ut)|0,o=o+Math.imul(j,ct)|0,n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,lt)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,lt)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(B,pt)|0))<<13)|0;c=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ct))+Math.imul(U,ut)|0,o=Math.imul(U,ct),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Ct=(c+(n=n+Math.imul(C,pt)|0)|0)+((8191&(i=(i=i+Math.imul(C,bt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,ht),i=(i=Math.imul(N,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Rt=(c+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;c=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863;var Ot=(c+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,bt))+Math.imul(U,pt)|0))<<13)|0;return c=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=yt,u[1]=vt,u[2]=gt,u[3]=mt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=kt,u[9]=At,u[10]=xt,u[11]=It,u[12]=Tt,u[13]=Mt,u[14]=Bt,u[15]=Pt,u[16]=Ct,u[17]=Rt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function v(t,e,r){return y(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):v(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},g.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==f||c>=i);c--){var h=0|this.words[c];this.words[c]=f<<26-o|h>>>o,f=h&a}return u&&0!==f&&(u.words[u.length++]=f),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<=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<=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>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),u=new o(1),c=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(h)),a.iushrn(1),u.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(u)):(r.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),a=new o(0),u=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(e.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return m[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var c=e.words[n],f=u-1;f>=0;f--){var h=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:239}],159:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),u=s.toRed(r.mont(e.prime2)),c=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=u.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(c).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":158,buffer:130,randombytes:327}],160:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":161}],161:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],162:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],163:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),u=t("./algorithms.json");function c(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new c(t)}function l(t){return new f(t)}Object.keys(u).forEach(function(t){u[t].id=Buffer.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t]}),o(c,i.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r()},c.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":161,"./sign":164,"./verify":165,"create-hash":138,inherits:279,"readable-stream":343,"safe-buffer":345}],164:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),u=t("./curves.json");function c(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,u,c){var f=o(r);if("ec"===f.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,u=r.data.g,c=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===u.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(c.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=Buffer.concat([c,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],v=t[y],g=257*t[p]^16843008*p;s[r]=g<<24|g>>>8,a[r]=g<<16|g>>>16,u[r]=g<<8|g>>>24,c[r]=g;g=16843009*v^65537*y^257*b^16843008*r;f[p]=g<<24|g>>>8,h[p]=g<<16|g>>>16,l[p]=g<<8|g>>>24,d[p]=g,r?(r=b^t[t[t[v^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var u=this._invKeySchedule=[],c=0;c>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,u,c,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var u=this._nRounds,c=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&c]^r[d++],v=n[h>>>24]^i[l>>>16&255]^o[c>>>8&255]^s[255&f]^r[d++],g=n[l>>>24]^i[c>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];c=b,f=y,h=v,l=g}b=(a[c>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&c])^r[d++],v=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[c>>>8&255]<<8|a[255&f])^r[d++],g=(a[l>>>24]<<24|a[c>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],172:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,u=(a.Utf8,a.Base64),c=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?m:v}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(u)},parse:function(t){var e=u.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},v=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=c.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},m=n.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=v.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,v.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":173,"./evpkdf":176}],173:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},c=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(c.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return c.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,c=t.min(4*u,i);if(u){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|u)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],176:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,u=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,u=s.words,c=0;c>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],181:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var u=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],u=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],v=t[e+6],g=t[e+7],m=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],I=o[0],T=o[1],M=o[2],B=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=c(T=c(T=c(T=c(T,M=c(M,B=c(B,I=c(I,T,M,B,s,7,a[0]),T,M,u,12,a[1]),I,T,d,17,a[2]),B,I,p,22,a[3]),M=c(M,B=c(B,I=c(I,T,M,B,b,7,a[4]),T,M,y,12,a[5]),I,T,v,17,a[6]),B,I,g,22,a[7]),M=c(M,B=c(B,I=c(I,T,M,B,m,7,a[8]),T,M,w,12,a[9]),I,T,_,17,a[10]),B,I,E,22,a[11]),M=c(M,B=c(B,I=c(I,T,M,B,S,7,a[12]),T,M,k,12,a[13]),I,T,A,17,a[14]),B,I,x,22,a[15]),M=f(M,B=f(B,I=f(I,T,M,B,u,5,a[16]),T,M,v,9,a[17]),I,T,E,14,a[18]),B,I,s,20,a[19]),M=f(M,B=f(B,I=f(I,T,M,B,y,5,a[20]),T,M,_,9,a[21]),I,T,x,14,a[22]),B,I,b,20,a[23]),M=f(M,B=f(B,I=f(I,T,M,B,w,5,a[24]),T,M,A,9,a[25]),I,T,p,14,a[26]),B,I,m,20,a[27]),M=f(M,B=f(B,I=f(I,T,M,B,k,5,a[28]),T,M,d,9,a[29]),I,T,g,14,a[30]),B,I,S,20,a[31]),M=h(M,B=h(B,I=h(I,T,M,B,y,4,a[32]),T,M,m,11,a[33]),I,T,E,16,a[34]),B,I,A,23,a[35]),M=h(M,B=h(B,I=h(I,T,M,B,u,4,a[36]),T,M,b,11,a[37]),I,T,g,16,a[38]),B,I,_,23,a[39]),M=h(M,B=h(B,I=h(I,T,M,B,k,4,a[40]),T,M,s,11,a[41]),I,T,p,16,a[42]),B,I,v,23,a[43]),M=h(M,B=h(B,I=h(I,T,M,B,w,4,a[44]),T,M,S,11,a[45]),I,T,x,16,a[46]),B,I,d,23,a[47]),M=l(M,B=l(B,I=l(I,T,M,B,s,6,a[48]),T,M,g,10,a[49]),I,T,A,15,a[50]),B,I,y,21,a[51]),M=l(M,B=l(B,I=l(I,T,M,B,S,6,a[52]),T,M,p,10,a[53]),I,T,_,15,a[54]),B,I,u,21,a[55]),M=l(M,B=l(B,I=l(I,T,M,B,m,6,a[56]),T,M,x,10,a[57]),I,T,v,15,a[58]),B,I,k,21,a[59]),M=l(M,B=l(B,I=l(I,T,M,B,b,6,a[60]),T,M,E,10,a[61]),I,T,d,15,a[62]),B,I,w,21,a[63]),o[0]=o[0]+I|0,o[1]=o[1]+T|0,o[2]=o[2]+M|0,o[3]=o[3]+B|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,u=a.words,c=0;c<4;c++){var f=u[c];u[c]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function c(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(u),r.HmacMD5=o._createHmacHelper(u)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],182:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var u=0;u>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],188:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],189:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],190:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],191:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173}],192:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,u;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,u=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),u=o.words,c=s.words,f=r.keySize,h=r.iterations;u.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;n[0]^=c,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=c,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],194:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],u=o[1],c=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8),h=c>>>16|4294901760&f,l=f<<16|65535&c;i[0]^=c,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=c,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,u=((s*s>>>17)+s*a>>>15)+a*a,c=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=u^c}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],195:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var u=n[i];n[i]=n[o],n[o]=u}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":172,"./core":173,"./enc-base64":174,"./evpkdf":176,"./md5":181}],196:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),u=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),c=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,I,T=this._hash.words,M=h.words,B=l.words,P=a.words,C=u.words,R=c.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)I=o+t[e+P[r]]|0,I+=r<16?p(s,d,w)+M[0]:r<32?b(s,d,w)+M[1]:r<48?y(s,d,w)+M[2]:r<64?v(s,d,w)+M[3]:g(s,d,w)+M[4],I=(I=m(I|=0,R[r]))+_|0,o=_,_=w,w=m(d,10),d=s,s=I,I=E+t[e+C[r]]|0,I+=r<16?g(S,k,A)+B[0]:r<32?v(S,k,A)+B[1]:r<48?y(S,k,A)+B[2]:r<64?b(S,k,A)+B[3]:p(S,k,A)+B[4],I=(I=m(I|=0,O[r]))+x|0,E=x,x=A,A=m(k,10),k=S,S=I;I=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=I},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function v(t,e,r){return t&r|e&~r}function g(t,e,r){return t^(e|~r)}function m(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],197:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],u=r[4],c=0;c<80;c++){if(c<16)o[c]=0|t[e+c];else{var f=o[c-3]^o[c-8]^o[c-14]^o[c-16];o[c]=f<<1|f>>>31}var h=(n<<5|n>>>27)+u+o[c];h+=c<20?1518500249+(i&s|~i&a):c<40?1859775393+(i^s^a):c<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,u=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],198:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":173,"./sha256":199}],199:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)c[d]=0|t[e+d];else{var p=c[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],v=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=b+c[d-7]+v+c[d-16]}var g=n&i^n&o^i&o,m=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+u[d]+c[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(m+g)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":173}],200:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,u=[],c=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){u[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)c[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var v=h[(l+4)%5],g=h[(l+1)%5],m=g.high,w=g.low;for(d=v.high^(m<<1|w>>>31),p=v.low^(w<<1|m>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=u[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[c[_]];A.high=d,A.low=p}var x=h[0],I=r[0];x.high=I.high,x.low=I.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],M=h[_],B=h[(l+1)%5+5*b],P=h[(l+2)%5+5*b];T.high=M.high^~B.high&P.high,T.low=M.low^~B.low&P.low}T=r[0];var C=f[a];T.high^=C.high,T.low^=C.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,u=a/8,c=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),c.push(d),c.push(l)}return new i.init(c,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],201:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":173,"./sha512":202,"./x64-core":204}],202:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],c=[];!function(){for(var t=0;t<80;t++)c[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,v=o.high,g=o.low,m=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,I=l.high,T=l.low,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_,N=E,U=S,H=k,K=A,z=x,q=I,F=T,W=0;W<80;W++){var V=c[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var X=c[W-15],Z=X.high,J=X.low,Q=(Z>>>1|J<<31)^(Z>>>8|J<<24)^Z>>>7,$=(J>>>1|Z<<31)^(J>>>8|Z<<24)^(J>>>7|Z<<25),tt=c[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=c[W-7],st=ot.high,at=ot.low,ut=c[W-16],ct=ut.high,ft=ut.low;G=(G=(G=Q+st+((Y=$+at)>>>0<$>>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ct+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=D&U^~D&K,dt=N&H^~N&z,pt=M&P^M&R^P&R,bt=B&C^B&O^C&O,yt=(M>>>28|B<<4)^(M<<30|B>>>2)^(M<<25|B>>>7),vt=(B>>>28|M<<4)^(B<<30|M>>>2)^(B<<25|M>>>7),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),mt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),wt=u[W],_t=wt.high,Et=wt.low,St=q+gt+((ht=F+mt)>>>0>>0?1:0),kt=vt+bt;q=K,F=z,K=U,z=H,U=D,H=N,D=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0
>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((N=j+ht|0)>>>0>>0?1:0)|0,L=R,j=O,R=P,O=C,P=M,C=B,M=St+(yt+pt+(kt>>>0>>0?1:0))+((B=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+B,n.high=d+M+(p>>>0>>0?1:0),y=i.low=y+C,i.high=b+P+(y>>>0>>0?1:0),g=o.low=g+O,o.high=v+R+(g>>>0>>0?1:0),w=s.low=w+j,s.high=m+L+(w>>>0>>0?1:0),E=a.low=E+N,a.high=_+D+(E>>>0>>0?1:0),k=f.low=k+H,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+z,h.high=A+K+(x>>>0>>0?1:0),T=l.low=T+F,l.high=I+q+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":173,"./x64-core":204}],203:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],c=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var c=i[o]=[],f=u[o];for(r=0;r<24;r++)c[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,c[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;c[0]=c[0]<<1|c[0]>>>31;for(r=1;r<7;r++)c[r]=c[r]>>>4*(r-1)+3;c[7]=c[7]<<5|c[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,u=0;u<8;u++)a|=c[u][((s^i[u])&f[u])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":206,_process:291}],206:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,u=t.keys.length-2;u>=0;u-=2){var c=t.keys[u],f=t.keys[u+1];o.expand(s,t.tmp,0),c^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(c,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":209,"./utils":212,inherits:279,"minimalistic-assert":286}],211:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":209,"./des":210,inherits:279,"minimalistic-assert":286}],212:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,u=0;u>>n[u]&1;for(u=a;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(u),e.cmp(u)){if(!e.cmp(c))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&v(p)&&v(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":90,"miller-rabin":285,randombytes:327}],216:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],217:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":221,assert:24,bigi:34}],218:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],219:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":217,"./names":220,"./point":221}],220:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),u=new BigInteger(e.h,16),c=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,c,f,a,u)}},{"./curve":217,"./curves.json":218,bigi:34}],221:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),u=a.multiply(s),c=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(c.shiftLeft(1)).multiply(t.z).subtract(u).multiply(s).mod(this.curve.p),l=c.multiply(i).multiply(o).subtract(r.multiply(u)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(u)).mod(this.curve.p),d=u.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),u=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),c=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,u,c)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),u=e.testBit(s);o=o.twice(),a!==u&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=t.pointFromX(u,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var c=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,c)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:24,bigi:34,"safe-buffer":345}],222:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":237,"./elliptic/curve":225,"./elliptic/curves":228,"./elliptic/ec":229,"./elliptic/eddsa":232,"./elliptic/utils":236,brorand:103}],223:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function u(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)u=(u<<1)+n[f];c.push(u)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;c--){for(var f=0;c>=0&&0===s[c];c--)f++;if(c>=0&&f++,u=u.dblp(f),c<0)break;var h=s[c];a(0!==h),u="affine"===t.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===t.type?u.toP():u},u.prototype._wnafMulAdd=function(t,e,r,n,i){var a,u,c,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var v=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(v[1]=e[b].add(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].add(e[y].neg())):(v[1]=e[b].toJ().mixedAdd(e[y]),v[2]=e[b].toJ().mixedAdd(e[y].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(d=Math.max(m[0].length,d),l[b]=new Array(d),l[y]=new Array(d),u=0;u=0;a--){for(var k=0;a>=0;){var A=!0;for(u=0;u=0&&k++,E=E.dblp(k),a<0)break;for(u=0;u0?c=h[u][x-1>>1]:x<0&&(c=h[u][-x-1>>1].neg()),E="affine"===c.type?E.mixedAdd(c):E.add(c))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},c.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(u,c,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(a)).redAdd(u);this.zOne?(t=s.redSub(a).redSub(u).redMul(c.redSub(this.curve.two)),e=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),t=s.redSub(a).redISub(u).redMul(o),e=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=a.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(u)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),u=r.redAdd(e),c=o.redMul(s),f=a.redMul(u),h=o.redMul(u),l=s.redMul(a);return this.curve.point(c,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(u).redMul(f);return this.curve.twisted?(e=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(e=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],225:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":223,"./edwards":224,"./mont":226,"./short":227}],226:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),u=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],227:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function u(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,s),e.exports=u,u.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,u,c,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),v=new i(1),g=0;0!==l.cmpn(0);){var m=d.div(l);c=d.sub(m.mul(l)),f=y.sub(m.mul(p));var w=v.sub(m.mul(b));if(!n&&c.cmp(h)<0)e=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++g)break;u=c,d=l,l=c,y=p,p=f,v=b,b=w}s=c.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},u.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(c).neg()}},u.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},u.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),u.prototype.jpoint=function(t,e,r){return new c(this,t,e,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),h=n.redMul(c),l=u.redSqr().redIAdd(f).redISub(h).redISub(h),d=u.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},c.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),h=a.redSqr().redIAdd(c).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},c.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":236,"./base":223,"bn.js":90,inherits:279}],228:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function u(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new u(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":225,"./precomputed/secp256k1":235,"./utils":236,"hash.js":265}],229:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),u=o.assert,c=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(u(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new c(this,t)},h.prototype.keyFromPrivate=function(t,e){return c.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return c.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),u=t.toArray("be",s),c=new i({hash:this.hash,entropy:a,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(c.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var g=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),g^=1),new f({r:y,s:v,recoveryParam:g})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),c=u.mul(t).umod(this.n),h=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(c,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(c,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){u((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,c=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=c.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":228,"../utils":236,"./key":230,"./signature":231,"bn.js":90,brorand:103,"hmac-drbg":277}],230:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":236,"bn.js":90}],231:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var c=a(t,r);if(!1===c)return!1;if(t.length!==c+r.place)return!1;var f=t.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(u),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,e.length),(n=n.concat(e)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":236,"bn.js":90}],232:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,u=t("./key"),c=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,c=e.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),s=0==(1&u)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(s),a=0==(1&c)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":90,"minimalistic-assert":286,"minimalistic-crypto-utils":287}],237:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],238:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var c=new n;c.update(u),c.update(t),e&&c.update(e),u=c.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,u.length),u.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,u.length-f);u.copy(a,l,f,f+d),i-=d}}return u.fill(0),{key:s,iv:a}}},{"md5.js":283,"safe-buffer":345}],239:[function(t,e,r){},{}],240:[function(t,e,r){arguments[4][239][0].apply(r,arguments)},{dup:239}],241:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(c=r.slice()).length,u=0;u0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],242:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,u,c=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,v="-",g=/^xn--/,m=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function I(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function B(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function P(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function C(t){var e,r,n,i,o,s,a,u,d,p,g,m=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(v))<0&&(r=0),n=0;n=128&&A("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((u=(g=t.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:f)>=f||u>S((c-_)/s))&&A("overflow"),_+=u*s,!(u<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(c/(p=f-d))&&A("overflow"),s*=p;k=P(_-o,e=m.length+1,0==o),S(_/e)>c-E&&A("overflow"),E+=S(_/e),_%=e,m.splice(_++,0,E)}return M(m)}function R(t){var e,r,n,i,o,s,a,u,d,p,g,m,w,_,E,x=[];for(m=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&gS((c-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;sc&&A("overflow"),g==e){for(u=r,d=f;!(u<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=u-p,_=f-p,x.push(k(B(p+E%_,0))),u=S(E/_);x.push(k(B(u,0))),o=P(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:M},decode:C,encode:R,toASCII:function(t){return I(t,function(t){return m.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return I(t,function(t){return g.test(t)?C(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(u in a)a.hasOwnProperty(u)&&(i[u]=a[u]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],243:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":244}],244:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var u=i(a.prototype),c=0;c0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),M(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function P(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(C,e,t))}function C(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function R(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?P(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&P(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&P(this)),null!==n&&this.emit("data",n),n},g.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},g.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:m;function c(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",v),t.removeListener("finish",g),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",c),n.removeListener("end",f),n.removeListener("end",m),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",c);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==R(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),m(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function v(){t.removeListener("finish",g),m()}function g(){l("onfinish"),t.removeListener("close",v),m()}function m(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",v),t.once("finish",g),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},g.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;v.WritableState=y;var c=Object.create(t("core-util-is"));c.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,c=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(c||0===c)?c:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?u(m,t,r,s,i):m(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function v(e){if(a=a||t("./_stream_duplex"),!(d.call(v,this)||this instanceof a))return new v(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function g(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function m(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,g(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,h=r.callback;if(g(t,e,!1,e.objectMode?1:c.length,c,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}c.inherits(v,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(v,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===v&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},v.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},v.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(v.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),v.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},v.prototype._writev=null,v.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(v.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),v.prototype.destroy=p.destroy,v.prototype._undestroy=p.undestroy,v.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":244,"./internal/streams/destroy":250,"./internal/streams/stream":251,_process:291,"core-util-is":136,inherits:279,"process-nextick-args":252,"safe-buffer":258,timers:372,"util-deprecate":381}],249:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":258,util:239}],250:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":252}],251:[function(t,e,r){e.exports=t("events").EventEmitter},{events:241}],252:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],254:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":255}],255:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":244,"./lib/_stream_passthrough.js":245,"./lib/_stream_readable.js":246,"./lib/_stream_transform.js":247,"./lib/_stream_writable.js":248}],256:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":255}],257:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":248}],258:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],259:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:241,inherits:279,"readable-stream/duplex.js":243,"readable-stream/passthrough.js":254,"readable-stream/readable.js":255,"readable-stream/transform.js":256,"readable-stream/writable.js":257}],260:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":258}],261:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],262:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{dup:26}],263:[function(t,e,r){arguments[4][27][0].apply(r,arguments)},{"./support/isBuffer":262,_process:291,dup:27,inherits:261}],264:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:279,"readable-stream":343,"safe-buffer":345}],265:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":266,"./hash/hmac":267,"./hash/ripemd":268,"./hash/sha":269,"./hash/utils":276}],266:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":276}],276:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:279,"minimalistic-assert":286}],277:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*b}},{}],279:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],280:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],281:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],282:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",c=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,v=2,g=4,m=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,I="...",T=800,M=16,B=1,P=2,C=1/0,R=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,D=j-1,N=j>>>1,U=[["ary",S],["bind",y],["bindKey",v],["curry",m],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],H="[object Arguments]",K="[object Array]",z="[object AsyncFunction]",q="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",X="[object Map]",Z="[object Number]",J="[object Null]",Q="[object Object]",$="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ut="[object DataView]",ct="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",vt="[object Uint32Array]",gt=/\b__p \+= '';/g,mt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,It=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mt=/^\w*$/,Bt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pt=/[\\^$.*+?()[\]{}|]/g,Ct=RegExp(Pt.source),Rt=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Dt=/,? & /,Nt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Ht=/\\(\\)?/g,Kt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,zt=/\w*$/,qt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Jt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Qt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",$t="[\\ud800-\\udfff]",te="["+Qt+"]",ee="["+Jt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+Qt+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ue="(?:\\ud83c[\\udde6-\\uddff]){2}",ce="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ue,ce].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ue,ce].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ue,ce,$t].join("|")+")",ve=RegExp("['’]","g"),ge=RegExp(ee,"g"),me=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Jt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ct]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[vt]=!0,Ae[H]=Ae[K]=Ae[at]=Ae[q]=Ae[ut]=Ae[F]=Ae[V]=Ae[G]=Ae[X]=Ae[Z]=Ae[Q]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[H]=xe[K]=xe[at]=xe[ut]=xe[q]=xe[F]=xe[ct]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[X]=xe[Z]=xe[Q]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[vt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Ie={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Me=parseInt,Be="object"==typeof t&&t&&t.Object===Object&&t,Pe="object"==typeof self&&self&&self.Object===Object&&self,Ce=Be||Pe||Function("return this")(),Re="object"==typeof r&&r&&!r.nodeType&&r,Oe=Re&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Re,je=Le&&Be.process,De=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),Ne=De&&De.isArrayBuffer,Ue=De&&De.isDate,He=De&&De.isMap,Ke=De&&De.isRegExp,ze=De&&De.isSet,qe=De&&De.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Je(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Ie[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Ir(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Ce:Or.defaults(Ce.Object(),e,Or.pick(Ce,Se))).Array,Jt=e.Date,Qt=e.Error,$t=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=$t.prototype,ae=ee.prototype,ue=e["__core-js_shared__"],ce=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ce.call(ee),be=Ce._,ye=re("^"+ce.call(fe).replace(Pt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,me=e.Symbol,_e=e.Uint8Array,Ie=Buffer?Buffer.allocUnsafe:n,Be=xr(ee.getPrototypeOf,ee),Pe=ee.create,Re=ae.propertyIsEnumerable,Oe=oe.splice,je=me?me.isConcatSpreadable:n,De=me?me.iterator:n,nr=me?me.toStringTag:n,hr=function(){try{var t=Ho(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Ce.clearTimeout&&e.clearTimeout,jr=Jt&&Jt.now!==Ce.Date.now&&Jt.now,Dr=e.setTimeout!==Ce.setTimeout&&e.setTimeout,Nr=te.ceil,Ur=te.floor,Hr=ee.getOwnPropertySymbols,Kr=Buffer?Buffer.isBuffer:n,zr=e.isFinite,qr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Jt.now,Yr=e.parseInt,Xr=te.random,Zr=oe.reverse,Jr=Ho(e,"DataView"),Qr=Ho(e,"Map"),$r=Ho(e,"Promise"),tn=Ho(e,"Set"),en=Ho(e,"WeakMap"),rn=Ho(ee,"create"),nn=en&&new en,on={},sn=ls(Jr),an=ls(Qr),un=ls($r),cn=ls(tn),fn=ls(en),hn=me?me.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ma(t)&&!ga(t)&&!(t instanceof gn)){if(t instanceof vn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new vn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Pe)return Pe(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function vn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function gn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function mn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,u=e&h,c=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=ga(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!u)return no(t,a)}else{var b=qo(t),y=b==G||b==Y;if(Ea(t))return Ji(t,u);if(b==Q||b==H||y&&!o){if(a=c||y?{}:Wo(t),!u)return c?function(t,e){return io(t,zo(t),e)}(t,function(t,e){return t&&io(e,su(e),t)}(a,t)):function(t,e){return io(t,Ko(t),e)}(t,Cn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return Qi(t);case q:case F:return new s(+t);case ut:return function(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ct:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case vt:return $i(t,r);case X:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,zt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,u)}}s||(s=new Sn);var v=s.get(t);if(v)return v;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Ba(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var g=p?n:(f?c?Ro:Co:c?su:ou)(t);return Ve(g||t,function(n,i){g&&(n=t[i=n]),Mn(a,i,jn(n,e,r,i,t,s))}),a}function Dn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Nn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,u=t.length,c=[],f=e.length;if(!u)return c;r&&(e=Qe(e,yr(r))),n?(s=Je,a=!1):e.length>=i&&(s=gr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Bn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new mn,map:new(Qr||wn),string:new mn}},_n.prototype.delete=function(t){var e=No(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return No(this,t).get(t)},_n.prototype.has=function(t){return No(this,t).has(t)},_n.prototype.set=function(t,e){var r=No(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,u),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!Qr||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):$e(i,a):n||(i[i.length]=a)}return i}var Vn=uo(),Gn=uo(!0);function Yn(t,e){return t&&Vn(t,e,ou)}function Xn(t,e){return t&&Gn(t,e,ou)}function Zn(t,e){return Xe(e,function(e){return Aa(t[e])})}function Jn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Je:Ze,o=t[0].length,s=t.length,a=s,u=Ot(s),c=1/0,f=[];a--;){var h=t[a];a&&e&&(h=Qe(h,yr(e))),c=Vr(h.length,c),u[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=u[0];t:for(;++l=a)return u;var c=r[n];return u*("desc"==c?-1:1)}}return t.index-e.index}(t,e,r)})}function mi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,u,1),Oe.call(t,u,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Xr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>R)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Pu),t+"")}function Ai(t){return An(pu(t))}function xi(t,e){var r=pu(t);return cs(r,Ln(e,0,r.length))}function Ii(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,u=t;null!=u&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=gr,c=new En}else c=e?[]:u;t:for(;++n=i?t:Pi(t,e,r)}var Zi=Lr||function(t){return Ce.clearTimeout(t)};function Ji(t,e){if(e)return t.slice();var r=t.length,n=Ie?Ie(r):new t.constructor(r);return t.copy(n),n}function Qi(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function $i(t,e){var r=e?Qi(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,u=null===e,c=e==e,f=ja(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||i&&a&&c||!r&&c||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Po(function(e){var r=e.length,i=r,o=vn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!u&&"wrapper"==Lo(a))var u=new vn([],!0)}for(i=u?i:r;++i1&&m.reverse(),h&&cu))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Dt):[]}(n),r)))}function us(t){var e=0,r=0;return function(){var i=Gr(),o=M-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function cs(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Rs(t,r="function"==typeof r?(t.pop(),r):n)});function Hs(t){var e=pn(t);return e.__chain__=!0,e}function Ks(t,e){return e(t)}var zs=Po(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof gn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Ks,args:[o],thisArg:n}),new vn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var qs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Rn(t,r,1)});var Fs=lo(vs),Ws=lo(gs);function Vs(t,e){return(ga(t)?Ve:Hn)(t,Do(e,3))}function Gs(t,e){return(ga(t)?Ge:Kn)(t,Do(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Rn(t,r,[e])});var Xs=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Hn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Rn(t,r,e)});function Js(t,e){return(ga(t)?Qe:di)(t,Do(e,3))}var Qs=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var $s=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),gi(t,Wn(e,1),[])}),ta=jr||function(){return Ce.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=za(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Ir(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|v;if(r.length){var i=Ir(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,u,c,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,u=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function v(){var t=ta();if(y(t))return g(t);c=os(v,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function g(t){return c=n,p&&i?b(t):(i=o=n,u)}function m(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(c===n)return function(t){return h=t,c=os(v,e),l?b(t):u}(f);if(d)return Zi(c),c=os(v,e),b(f)}return c===n&&(c=os(v,e)),u}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),m.cancel=function(){c!==n&&Zi(c),h=0,i=f=o=c=n},m.flush=function(){return c===n?u:g(ta())},m}var sa=ki(function(t,e){return Nn(t,1,e)}),aa=ki(function(t,e,r){return Nn(t,Fa(e)||0,r)});function ua(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ua.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&ga(e[0])?Qe(e[0],yr(Do())):Qe(Wn(e,1),yr(Do()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),va=oi(function(){return arguments}())?oi:function(t){return Ma(t)&&fe.call(t,"callee")&&!Re.call(t,"callee")},ga=Ot.isArray,ma=Ne?yr(Ne):function(t){return Ma(t)&&$n(t)==at};function wa(t){return null!=t&&Ia(t.length)&&!Aa(t)}function _a(t){return Ma(t)&&wa(t)}var Ea=Kr||Fu,Sa=Ue?yr(Ue):function(t){return Ma(t)&&$n(t)==F};function ka(t){if(!Ma(t))return!1;var e=$n(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ca(t)}function Aa(t){if(!Ta(t))return!1;var e=$n(t);return e==G||e==Y||e==z||e==$}function xa(t){return"number"==typeof t&&t==za(t)}function Ia(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=R}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ma(t){return null!=t&&"object"==typeof t}var Ba=He?yr(He):function(t){return Ma(t)&&qo(t)==X};function Pa(t){return"number"==typeof t||Ma(t)&&$n(t)==Z}function Ca(t){if(!Ma(t)||$n(t)!=Q)return!1;var e=Be(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ce.call(r)==pe}var Ra=Ke?yr(Ke):function(t){return Ma(t)&&$n(t)==tt};var Oa=ze?yr(ze):function(t){return Ma(t)&&qo(t)==et};function La(t){return"string"==typeof t||!ga(t)&&Ma(t)&&$n(t)==rt}function ja(t){return"symbol"==typeof t||Ma(t)&&$n(t)==nt}var Da=qe?yr(qe):function(t){return Ma(t)&&Ia(t.length)&&!!Ae[$n(t)]};var Na=_o(li),Ua=_o(function(t,e){return t<=e});function Ha(t){if(!t)return[];if(wa(t))return La(t)?Pr(t):no(t);if(De&&t[De])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[De]());var e=qo(t);return(e==X?Ar:e==et?Tr:pu)(t)}function Ka(t){return t?(t=Fa(t))===C||t===-C?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function za(t){var e=Ka(t),r=e%1;return e==e?r?e-r:e:0}function qa(t){return t?Ln(za(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Me(t.slice(2),r?2:8):qt.test(t)?L:+t}function Wa(t){return io(t,su(t))}function Va(t){return null==t?"":Di(t)}var Ga=so(function(t,e){if(Qo(e)||wa(e))io(e,ou(e),t);else for(var r in e)fe.call(e,r)&&Mn(t,r,e[r])}),Ya=so(function(t,e){io(e,su(e),t)}),Xa=so(function(t,e,r,n){io(e,su(e),t,n)}),Za=so(function(t,e,r,n){io(e,ou(e),t,n)}),Ja=Po(On);var Qa=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Ro(t),r),n&&(r=jn(r,h|l|d,Mo));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fu=Po(function(t,e){return null==t?{}:function(t,e){return mi(t,e,function(e,r){return eu(t,r)})}(t,e)});function hu(t,e){if(null==t)return{};var r=Qe(Ro(t),function(t){return[t]});return e=Do(e),mi(t,r,function(t,r){return e(t,r[0])})}var lu=Ao(ou),du=Ao(su);function pu(t){return null==t?[]:vr(t,ou(t))}var bu=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yu(e):e)});function yu(t){return ku(Va(t).toLowerCase())}function vu(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ge,"")}var gu=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),mu=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wu=co("toLowerCase");var _u=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Eu=fo(function(t,e,r){return t+(r?" ":"")+ku(e)});var Su=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),ku=co("toUpperCase");function Au(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Nt)||[]}(t):t.match(e)||[]}var xu=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new Qt(t)}}),Iu=Po(function(t,e){return Ve(e,function(e){e=hs(e),Rn(t,e,na(t[e],t))}),t});function Tu(t){return function(){return t}}var Mu=po(),Bu=po(!0);function Pu(t){return t}function Cu(t){return ci("function"==typeof t?t:jn(t,h))}var Ru=ki(function(t,e){return function(r){return ii(r,t,e)}}),Ou=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lu(t,e,r){var n=ou(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,ou(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,$e([this.value()],arguments))})}),t}function ju(){}var Du=go(Qe),Nu=go(Ye),Uu=go(rr);function Hu(t){return Xo(t)?fr(hs(t)):function(t){return function(e){return Jn(e,t)}}(t)}var Ku=wo(),zu=wo(!0);function qu(){return[]}function Fu(){return!1}var Wu=vo(function(t,e){return t+e},0),Vu=So("ceil"),Gu=vo(function(t,e){return t/e},1),Yu=So("floor");var Xu,Zu=vo(function(t,e){return t*e},1),Ju=So("round"),Qu=vo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=za(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Xa,pn.assignWith=Za,pn.at=Ja,pn.before=ra,pn.bind=na,pn.bindAll=Iu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return ga(t)?t:[t]},pn.chain=Hs,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(za(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Nr(i/e));oo?0:o+r),(i=i===n||i>o?o:za(i))<0&&(i+=o),i=r>i?0:qa(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ra(e))&&!(e=Di(e))&&kr(t)?Xi(Pr(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(za(e),0),ki(function(r){var n=r[e],i=Xi(r,0,e);return n&&$e(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Pi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Pi(t,0,(e=r||e===n?1:za(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Pi(t,(e=i-(e=r||e===n?1:za(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Ki(t,Do(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Ks,pn.toArray=Ha,pn.toPairs=lu,pn.toPairsIn=du,pn.toPath=function(t){return ga(t)?Qe(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=ga(t),i=n||Ea(t)||Da(t);if(e=Do(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Be(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Ms,pn.unionBy=Bs,pn.unionWith=Ps,pn.uniq=function(t){return t&&t.length?Ni(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Ni(t,Do(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Ni(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Cs,pn.unzipWith=Rs,pn.update=function(t,e,r){return null==t?t:Hi(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Hi(t,e,Vi(r),i)},pn.values=pu,pn.valuesIn=function(t){return null==t?[]:vr(t,su(t))},pn.without=Os,pn.words=Au,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ds,pn.zip=Ns,pn.zipObject=function(t,e){return Fi(t||[],e||[],Mn)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Ii)},pn.zipWith=Us,pn.entries=lu,pn.entriesIn=du,pn.extend=Ya,pn.extendWith=Xa,Lu(pn,pn),pn.add=Wu,pn.attempt=xu,pn.camelCase=bu,pn.capitalize=yu,pn.ceil=Vu,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Dn(t,e,ou(e))},pn.deburr=vu,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gu,pn.endsWith=function(t,e,r){t=Va(t),e=Di(e);var i=t.length,o=r=r===n?i:Ln(za(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Ct.test(t)?t.replace(Pt,"\\$&"):t},pn.every=function(t,e,r){var i=ga(t)?Ye:zn;return r&&Yo(t,e,r)&&(e=n),i(t,Do(e,3))},pn.find=Fs,pn.findIndex=vs,pn.findKey=function(t,e){return ir(t,Do(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=gs,pn.findLastKey=function(t,e){return ir(t,Do(e,3),Xn)},pn.floor=Yu,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,Do(e,3),su)},pn.forInRight=function(t,e){return null==t?t:Gn(t,Do(e,3),su)},pn.forOwn=function(t,e){return t&&Yn(t,Do(e,3))},pn.forOwnRight=function(t,e){return t&&Xn(t,Do(e,3))},pn.get=tu,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=eu,pn.head=ws,pn.identity=Pu,pn.includes=function(t,e,r,n){t=wa(t)?t:pu(t),r=r&&!n?za(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:za(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ka(e),r===n?(r=e,e=0):r=Ka(r),function(t,e,r){return t>=Vr(e,r)&&t=-R&&t<=R},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Da,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ma(t)&&qo(t)==ot},pn.isWeakSet=function(t){return Ma(t)&&$n(t)==st},pn.join=function(t,e){return null==t?"":qr.call(t,e)},pn.kebabCase=gu,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=za(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,ur,o,!0)},pn.lowerCase=mu,pn.lowerFirst=wu,pn.lt=Na,pn.lte=Ua,pn.max=function(t){return t&&t.length?qn(t,Pu,ti):n},pn.maxBy=function(t,e){return t&&t.length?qn(t,Do(e,2),ti):n},pn.mean=function(t){return cr(t,Pu)},pn.meanBy=function(t,e){return cr(t,Do(e,2))},pn.min=function(t){return t&&t.length?qn(t,Pu,li):n},pn.minBy=function(t,e){return t&&t.length?qn(t,Do(e,2),li):n},pn.stubArray=qu,pn.stubFalse=Fu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zu,pn.nth=function(t,e){return t&&t.length?vi(t,za(e)):n},pn.noConflict=function(){return Ce._===this&&(Ce._=be),this},pn.noop=ju,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return mo(Ur(i),r)+t+mo(Nr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=za(e))?Br(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Xr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=ga(t)?tr:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Hn)},pn.reduceRight=function(t,e,r){var n=ga(t)?er:lr,i=arguments.length<3;return n(t,Do(e,4),r,i,Kn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:za(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iR)return[];var r=j,n=Vr(t,j);e=Do(e),t-=j;for(var i=pr(n,e);++r=s)return t;var u=r-Br(i);if(u<1)return i;var c=a?Xi(a,0,u).join(""):t.slice(0,u);if(o===n)return c+i;if(a&&(u+=c.length-u),Ra(o)){if(t.slice(u).search(o)){var f,h=c;for(o.global||(o=re(o.source,Va(zt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;c=c.slice(0,l===n?u:l)}}else if(t.indexOf(Di(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Rr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Su,pn.upperFirst=ku,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lu(pn,(Xu={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Xu[e]=t)}),Xu),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){gn.prototype[t]=function(r){r=r===n?1:Wr(za(r),0);var i=this.__filtered__&&!e?new gn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},gn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==B||3==r;gn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:Do(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");gn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");gn.prototype[t]=function(){return this.__filtered__?new gn(this):this[r](1)}}),gn.prototype.compact=function(){return this.filter(Pu)},gn.prototype.find=function(t){return this.filter(t).head()},gn.prototype.findLast=function(t){return this.reverse().find(t)},gn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new gn(this):this.map(function(r){return ii(r,t,e)})}),gn.prototype.reject=function(t){return this.filter(ca(Do(t)))},gn.prototype.slice=function(t,e){t=za(t);var r=this;return r.__filtered__&&(t>0||e<0)?new gn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=za(e))<0?r.dropRight(-e):r.take(e-t)),r)},gn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},gn.prototype.toArray=function(){return this.take(j)},Yn(gn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,u=e instanceof gn,c=a[0],f=u||ga(e),h=function(t){var e=o.apply(pn,$e([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=u&&!d;if(!s&&f){e=b?e:new gn(this);var y=t.apply(e,a);return y.__actions__.push({func:Ks,args:[h],thisArg:n}),new vn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(ga(i)?i:[],t)}return this[r](function(r){return e.apply(ga(r)?r:[],t)})}}),Yn(gn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,v).name]=[{name:"wrapper",func:n}],gn.prototype.clone=function(){var t=new gn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},gn.prototype.reverse=function(){if(this.__filtered__){var t=new gn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},gn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=ga(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof gn){var e=t;return this.__actions__.length&&(e=new gn(this)),(e=e.reverse()).__actions__.push({func:Ks,args:[Ts],thisArg:n}),new vn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return zi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,De&&(pn.prototype[De]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Re._=Or):Ce._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],283:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function u(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":264,inherits:279,"safe-buffer":345}],284:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),u=0;!a.testn(u);u++);for(var c=t.shrn(u),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(c);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(u);if(0!==l.cmp(o)&&0!==l.cmp(c)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],288:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function u(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===c&&!1===isNaN(t))return e.long?u(r=t,s,"day")||u(r,o,"hour")||u(r,i,"minute")||u(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],289:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;un)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var u,c,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,c=new Buffer(a),u=o-((f=Math.ceil(o/a))-1)*a),p.copy(c,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?c(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),c=e.slice(s+1),f=o(a,i(c,s)),h=o(c,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,"safe-buffer":345}],316:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),u=t("bn.js"),c=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,c=o("sha1").update(Buffer.alloc(0)).digest(),f=c.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([c,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new u(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):c(l,d)}},{"./mgf":293,"./withPublic":317,"./xor":318,"bn.js":90,"browserify-rsa":308,"create-hash":138,"parse-asn1":314,randombytes:327,"safe-buffer":345}],317:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":90,"safe-buffer":345}],318:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":41}],320:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function u(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(u,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(u)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,u):function(){n(u)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){o=f,c.port1.onmessage=u,u()};var f=function(){c.port2.postMessage(0)};o=function(){setTimeout(u,0),f()}}else o=function(){setTimeout(u,0)};return s}(),a=Function.call;function u(t){return function(){return a.apply(t,arguments)}}var c,f=u(Array.prototype.slice),h=u(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return P(t)?t:C(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):K(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=B(t);return P(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(K(e))},i.reject=function(e){t||a(H(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function I(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=I,x.all=F,x.reject=H,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=I,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return H(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return H(t)}}return H(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=M,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=B,k.isPromise=P,k.isPromiseAlike=C,k.isPending=function(t){return P(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!P(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return P(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var R,O,L,j=[],D=[],N=!0;function U(){j.length=0,D.length=0,N||(N=!0)}function H(t){var e=T({when:function(e){return e&&function(t){if(N){var e=l(D,t);-1!==e&&(D.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){N&&(D.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function K(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function z(t,e,r){return k(t).spread(e,r)}function q(t,e,r){return k(t).dispatch(e,r)}function F(t){return M(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;P(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,M(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return M(t,function(t){return t=d(t,k),M(F(d(t,function(t){return M(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),N=!1},U(),k.reject=H,k.fulfill=K,k.master=function(t){return T({isDef:function(){}},function(e,r){return q(t,e,r)},function(){return k(t).inspect()})},k.spread=z,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return H(t)}return o.done?o.value:M(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===v(t)||t instanceof c}(t)?t.value:H(t)}return M(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new c(t)},k.promised=function(t){return function(){return z([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=q,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(R=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),R.apply(R,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:291,timers:372}],321:[function(t,e,r){r.QRCapacityTable=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]]},{}],322:[function(t,e,r){var n=t("bops"),i=t("./qrcode.js"),o=t("./qrcapacitytable.js").QRCapacityTable;i.QRCode;function s(){}r.QRCodeDraw=s,r.QRVersionCapacityTable=o,r.QRErrorCorrectLevel=i.QRErrorCorrectLevel,r.QRCode=i.QRCode,s.prototype={scale:4,defaultMargin:20,marginScaleFactor:5,Array:"undefined"==typeof Uint32Array?Uint32Array:Array,errorBehavior:{length:"trim"},color:{dark:"black",light:"white"},defaultErrorCorrectLevel:i.QRErrorCorrectLevel.H,QRErrorCorrectLevel:i.QRErrorCorrectLevel,draw:function(t,e,r,n){var o,s,a,u=Array.prototype.slice.call(arguments);if(n=u.pop(),t=u.shift(),e=u.shift(),r=u.shift()||{},"function"!=typeof n)throw new Error("callback required");if("object"!=typeof r&&(r.errorCorrectLevel=r),this.QRVersion(e,r.errorCorrectLevel||this.QRErrorCorrectLevel.H,r.version,function(t,r,n,i){e=r,o=n,s=t,a=i}),this.scale=r.scale||this.scale,this.margin=void 0===r.margin?this.defaultMargin:r.margin,o){try{var c=new i.QRCode(o,a),f=this.scale||4,h=t.getContext("2d"),l=0;c.addData(e),c.make();var d=this.marginWidth(),p=d;l=this.dataWidth(c)+2*d,this.resetCanvas(t,h,l);for(var b=0,y=c.getModuleCount();b2&&(n=arguments[2]),this.QRVersion(t,n,(o||{}).version,function(e,r,i,o){t=r,level=i,error=e,n=o}),level){try{var s,a=new i.QRCode(level,n),u=(this.scale,0),c=0;a.addData(t),a.make(),u=this.dataWidth(a,1),s=new this.Array(u*u);for(var f=0,h=a.getModuleCount();ft&&t>0&&(t=this.scale*this.marginScaleFactor),t},dataWidth:function(t,e){return t.getModuleCount()*(e||this.scale||4)},resetCanvas:function(t,e,r){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.style.height=t.height=r,t.style.width=t.width=r,this.color.light?(e.fillStyle=this.color.light,e.fillRect(0,0,t.width,t.height)):e.clearRect(0,0,t.width,t.height)}}},{"./qrcapacitytable.js":321,"./qrcode.js":323,bops:91}],323:[function(t,e,r){var n=t("bops");r.QRCode=o;var i="undefined"==typeof Uint32Array?Uint32Array:Array;function o(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=new i}function s(t){this.mode=a.MODE_8BIT_BYTE,this.data=t;this.parsedData=n.from(t)}o.prototype={addData:function(t){var e=new s(t);this.dataList.push(e),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new i(this.moduleCount);for(var r=0;r=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e){for(var r=-1;r<=7;r++)if(!(t+r<=-1||this.moduleCount<=t+r))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(this.modules[t+r][e+n]=0<=r&&r<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=n&&n<=4)},getBestMaskPattern:function(){for(var t=0,e=0,r=0;r<8;r++){this.makeImpl(!0,r);var n=v.getLostPoint(this);(0==r||t>n)&&(t=n,e=r)}return e},setupTimingPattern:function(){for(var t=8;t>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=n}for(r=0;r<18;r++){n=!t&&1==(e>>r&1);this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=n}},setupTypeInfo:function(t,e){for(var r=this.errorCorrectLevel<<3|e,n=v.getBCHTypeInfo(r),i=0;i<15;i++){var o=!t&&1==(n>>i&1);i<6?this.modules[i][8]=o:i<8?this.modules[i+1][8]=o:this.modules[this.moduleCount-15+i][8]=o}for(i=0;i<15;i++){o=!t&&1==(n>>i&1);i<8?this.modules[8][this.moduleCount-i-1]=o:i<9?this.modules[8][15-i-1+1]=o:this.modules[8][15-i-1]=o}this.modules[this.moduleCount-8][8]=!t},mapData:function(t,e){for(var r=-1,n=this.moduleCount-1,i=7,o=0,s=this.moduleCount-1;s>0;s-=2)for(6==s&&s--;;){for(var a=0;a<2;a++)if(null==this.modules[n][s-a]){var u=!1;o>>i&1)),v.getMask(e,n,s-a)&&(u=!u),this.modules[n][s-a]=u,-1==--i&&(o++,i=7)}if((n+=r)<0||this.moduleCount<=n){n-=r,r=-r;break}}}},o.PAD0=236,o.PAD1=17,o.createData=function(t,e,r){for(var n=_.getRSBlocks(t,e),i=new E,s=0;s8*u)throw new Error("code length overflow. ("+i.getLengthInBits()+">"+8*u+")");for(i.getLengthInBits()+4<=8*u&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*u||(i.put(o.PAD0,8),i.getLengthInBits()>=8*u));)i.put(o.PAD1,8);return o.createBytes(i,n)},o.createBytes=function(t,e){for(var r=0,n=0,o=0,s=new i(e.length),a=new i(e.length),u=0;u=0?d.get(p):0}}var b=0;for(h=0;h=0;)e^=v.G15<=0;)e^=v.G18<>>=1;return e},getPatternPosition:function(t){return v.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case c:return(e+r)%2==0;case f:return e%2==0;case h:return r%3==0;case l:return(e+r)%3==0;case d:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case p:return e*r%2+e*r%3==0;case b:return(e*r%2+e*r%3)%2==0;case y:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new w([1],0),r=0;r5&&(r+=3+o-5)}for(n=0;n=256;)t-=255;return g.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},m=0;m<8;m++)g.EXP_TABLE[m]=1<>>7-t%8&1)},put:function(t,e){for(var r=0;r>>e-r-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}}},{bops:91}],324:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=t.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],325:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;ac||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>c||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return u.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}u&&u.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:291,randombytes:327,"safe-buffer":345}],329:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var u=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(u," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],330:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=c;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(c,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new g);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):P(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,P(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function M(t){var e=t._readableState;u("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(u("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(B,t))}function B(t){var e=t._readableState;u("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function P(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(C,t,e))}function C(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){u("readable nexttick read 0"),t.read(0)}function L(t,e){u("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(u("flow",e.flowing);e.flowing&&null!==t.read(););}function D(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function N(t){var e=t._readableState;u("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(u("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function H(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return u("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?N(this):M(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&N(this),null;var n,i=e.needReadable;return u("need readable",i),(0===e.length||e.length-t0?D(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&N(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new m("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:y;function a(e,r){u("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,u("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){u("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;u("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){u("ondata");var r=t.write(e);u("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==H(i.pipes,t))&&!h&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){u("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){u("onfinish"),t.removeListener("close",p),y()}function y(){u("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(u("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(R,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(R,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(u("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(u("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,B(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":329,"./_stream_duplex":330,"./internal/streams/destroy":337,"./internal/streams/state":341,"./internal/streams/stream":342,_process:291,buffer:130,inherits:279,"util-deprecate":381}],335:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[c])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[u]?n(t[u]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[c]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,c,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[u]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[c]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":338,_process:291}],336:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(u),o||(l.forEach(u),h(f))})});return r.reduce(c)}},{"../../../errors":329,"./end-of-stream":338}],341:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":329}],342:[function(t,e,r){arguments[4][251][0].apply(r,arguments)},{dup:251,events:241}],343:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":330,"./lib/_stream_passthrough.js":331,"./lib/_stream_readable.js":332,"./lib/_stream_transform.js":333,"./lib/_stream_writable.js":334,"./lib/internal/streams/end-of-stream.js":338,"./lib/internal/streams/pipeline.js":340}],344:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,m=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=p(r,n,i,l,m,t[s[A]],f[0],u[A]),I=g(w,_,E,S,k,t[a[A]],h[0],c[A])):A<32?(x=b(r,n,i,l,m,t[s[A]],f[1],u[A]),I=v(w,_,E,S,k,t[a[A]],h[1],c[A])):A<48?(x=y(r,n,i,l,m,t[s[A]],f[2],u[A]),I=y(w,_,E,S,k,t[a[A]],h[2],c[A])):A<64?(x=v(r,n,i,l,m,t[s[A]],f[3],u[A]),I=b(w,_,E,S,k,t[a[A]],h[3],c[A])):(x=g(r,n,i,l,m,t[s[A]],f[4],u[A]),I=p(w,_,E,S,k,t[a[A]],h[4],c[A])),r=m,m=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=I}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+m+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:130,"hash-base":264,inherits:279}],345:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:130}],346:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:291,buffer:130}],347:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":351,"./lib/elliptic":350}],348:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":280}],349:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var u=t[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+t[i]}if(!(u>n-i)){var c=i;for(i+=u;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);u>0&&0===t[c];u-=1,c+=1);if(!(u>32)){var h=t.slice(c,c+u);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:40,"safe-buffer":345}],350:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),u=a.curve;function c(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(u.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(u.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):u.n.sub(e).umod(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(u.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=c(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==c(t)},r.publicKeyTweakAdd=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(u.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(u.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var c=new i(e);if(c.cmp(u.n)>=0||c.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=c(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},c=new i(o.r),f=new i(o.s);if(c.cmp(u.n)>=0||f.cmp(u.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=c(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(u.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":352,"bn.js":90,"create-hash":138,elliptic:222,"safe-buffer":345}],351:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":345}],354:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":355,"./sha1":356,"./sha224":357,"./sha256":358,"./sha384":359,"./sha512":360}],355:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+c(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],356:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=u(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],357:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":353,"./sha256":358,inherits:279,"safe-buffer":345}],358:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,v=0;v<16;++v)r[v]=t.readInt32BE(4*v);for(;v<64;++v)r[v]=0|(((e=r[v-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[v-7]+l(r[v-15])+r[v-16];for(var g=0;g<64;++g){var m=y+h(d)+u(d,p,b)+o[g]+r[g]|0,w=f(n)+c(n,i,s)|0;y=b,b=p,p=d,d=a+m|0,a=s,s=i,i=n,n=m+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],359:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":353,"./sha512":360,inherits:279,"safe-buffer":345}],360:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function u(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,v=0|this._fh,g=0|this._gh,m=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,I=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var M=e[T-30],B=e[T-30+1],P=l(M,B),C=d(B,M),R=p(M=e[T-4],B=e[T-4+1]),O=b(B,M),L=e[T-14],j=e[T-14+1],D=e[T-32],N=e[T-32+1],U=C+j|0,H=P+L+y(U,C)|0;H=(H=H+R+y(U=U+O|0,O)|0)+D+y(U=U+N|0,N)|0,e[T]=H,e[T+1]=U}for(var K=0;K<160;K+=2){H=e[K],U=e[K+1];var z=c(r,n,i),q=c(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[K],X=o[K+1],Z=u(a,v,g),J=u(k,A,x),Q=I+G|0,$=m+V+y(Q,I)|0;$=($=($=$+Z+y(Q=Q+J|0,J)|0)+Y+y(Q=Q+X|0,X)|0)+H+y(Q=Q+U|0,U)|0;var tt=W+q|0,et=F+z+y(tt,W)|0;m=g,I=x,g=v,x=A,v=a,A=k,a=s+$+y(k=S+Q|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=$+et+y(w=Q+tt|0,Q)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+v+y(this._fl,A)|0,this._gh=this._gh+g+y(this._gl,x)|0,this._hh=this._hh+m+y(this._hl,I)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":353,inherits:279,"safe-buffer":345}],361:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var u,c,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(u=t.j[r])[0];var b=u[1],y=u[2],v=u[3],g=u[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^v[255&e]^i[d],c=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^v[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^v[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^v[255&a]^i[d+3],d+=4,o=u,s=c,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=g[o>>>24]<<24^g[s>>16&255]<<16^g[a>>8&255]<<8^g[255&e]^i[d++],u=o,o=s,s=a,a=e,e=u;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],u=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],u=this.j[1],c=a[4],f=u[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!c[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,c[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,u[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),u[t]=u[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=c+r|0,c=u,u=a,s=r+((a=s)&u^c&(a^u))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+u|0,i[3]=i[3]+c|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],u=i[2],c=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],v=i[11],g=i[12],m=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=u,A=c,x=f,I=h,T=l,M=d,B=p,P=b,C=y,R=v,O=g,L=m,j=w,D=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var N=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((H=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|H>>>29)^r>>>6,H=(r<<13|H>>>19)^(H<<3|r>>>29)^(r<<26|H>>>6),K=n[2*(t-7)],z=n[2*(t-16)],q=n[2*(t-16)+1];e=e+K+((r=N+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=H)>>>0>>0?1:0),e+=z+((r+=q)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;K=B&C^~B&O;var F=P&R^~P&L,W=(H=E&k^E&x^k&x,S&A^S&I^A&I),V=(z=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),q=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];N=(N=(N=(N=j+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9))+((U=D+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9)))>>>0>>0?1:0))+(K+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=z+H+((r=q+W)>>>0>>0?1:0),j=O,D=L,O=C,L=R,C=B,R=P,B=T+N+((P=M+U|0)>>>0>>0?1:0)|0,T=x,M=I,x=k,I=A,k=E,A=S,E=N+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,c=i[3]=c+A|0,i[2]=u+k+(c>>>0>>0?1:0)|0,h=i[5]=h+I|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+M|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+P|0,i[8]=p+B+(b>>>0

>>0?1:0)|0,v=i[11]=v+R|0,i[10]=y+C+(v>>>0>>0?1:0)|0,m=i[13]=m+L|0,i[12]=g+O+(m>>>0>>0?1:0)|0,_=i[15]=_+D|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,u=a.bitLength(s);if(o=o||128,i=i||[],o<=u?(e=a.bitSlice(s,u-o),s=a.bitSlice(s,0,u-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,u=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=u(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,u,c,f=[],h=n.bitArray;for(c=1;32*f.length<(i||1);c++){for(o=s=t.encrypt(h.concat(e,[c])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new u},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){u.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),u.prototype.del=u.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=g,f.delete=g,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":366,"./is-object":368,"./request-base":369,"./response-base":370,"component-emitter":135}],368:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],369:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":368}],370:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":371}],371:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],372:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},u=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":291,timers:372}],373:[function(t,e,r){e.exports=function(t,e,r){e=void 0===e?0:e,r=void 0===r?t.length:r;var s,f,h=0,l=0;i.length=n.length=0;for(;h>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":280,"./errors":374,"./native":377}],376:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw u(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw u(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":374,"./extra":375,"./native":377}],377:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],378:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,u=19,c=21,f=28,h=c*f,l=u*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var v=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var g=function(t){this.str=t,this.cursor=0};g.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=t("querystring");function m(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?R+="x":R+=C[O];if(!R.match(d)){var j=B.slice(0,I),D=B.slice(I+1),N=C.match(p);N&&(j.push(N[1]),D.unshift(N[2])),D.length&&(m="/"+D.join(".")+m),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),M||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+U,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[E])for(I=0,P=f.length;I0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,I=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),I++):I&&(S.splice(T,1),I--);if(!_&&!E)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var M,B=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=B?"":S.length?S.shift():"",(M=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=M.shift(),r.host=r.hostname=M.shift()));return(_=_||r.host&&S.length)&&!B&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":380,punycode:242,querystring:326}],380:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],381:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],382:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":345}],383:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),u=0,c=a.length;u 300) { - // max inputs length - chunk = 300; + if (utxoArray.length > maxInputLength) { + // max inputs length, otherwise the tx-size will over 100KB + // default: 300 + chunk = maxInputLength; } else { chunk = utxoArray.length; } @@ -7438,7 +7439,7 @@ WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee } rawTransactionList.push(this.signTransaction(rawTransaction, temp)); } - console.log("rawTransactionList:",rawTransactionList); + console.log("raw transaction list:",rawTransactionList); return rawTransactionList; }; diff --git a/build/blocktrail-sdk.min.js b/build/blocktrail-sdk.min.js index b6675d1..77d145b 100644 --- a/build/blocktrail-sdk.min.js +++ b/build/blocktrail-sdk.min.js @@ -1 +1 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).blocktrailSDK=t()}}(function(){return function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){return i(e[s][1][t]||t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof u?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof u?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof u?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),u=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new c(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,u,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,u=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[u.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:u},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=m.AES.encrypt(t.secret,t.passphrase).toString(m.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=m.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(m.format.OpenSSL),t.recoverySecret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=m.AES.encrypt(t.secret,t.recoverySecret).toString(m.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:c.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var u=i.defer();u.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),u.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),u.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof e?c.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){c[t]=e[t]});var u={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(u.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(u.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",u,c,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:270,bip39:34,"bitcoinjs-lib":49,"bitcoinjs-message":78,buffer:110,"crypto-js":159,lodash:261,q:299,randombytes:303}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},c=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),c=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(t,e).toString(i.enc.Utf8)},u=function(t,e){return a(c(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(u(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=u,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:23,bip39:34,buffer:110,"crypto-js":159,q:299,util:242}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function c(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function u(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,c,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,bip39:34,buffer:110}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:23,buffer:110}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:110}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),c=t("create-hash"),u=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var u=o.parse(e,!0),f=p.qs(i.defaults({},r||{},u.query||{},this.params||{}));this.path="".concat(this.endpoint,u.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=u(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:270,"create-hash":118,debug:185,lodash:261,q:299,querystring:302,superagent:343,"superagent-http-signature/index-hmac-only":339,url:354}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:261,q:299}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:27,lodash:261,q:299}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:261,q:299,superagent:343}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":49,lodash:261,q:299,superagent:343}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){u+=a.getLengthForVarInt(t)+t}),u+=a.getLengthForVarInt(s.length)),[c,u]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var c=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var u=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(u)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var u=n.script.types,f=[u.MULTISIG,u.P2PKH,u.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,"bitcoinjs-lib":49,buffer:110}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:27,lodash:261,q:299}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:270}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),c=t("./blocktrail"),u=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,c,u,f,h,l,d,p,y,m,v,g,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!g,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(u,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=u,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=m,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function m(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(u.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new c.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=u.AES.encrypt(e.secret,t).toString(u.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),u=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&u===b.CHAIN_BTC_SEGWIT?(e=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=c);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new c.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new c.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var u=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!u&&!f)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,u){var f=this;"function"==typeof e?(u=e,e=null):"function"==typeof r?(u=r,r=!1):"function"==typeof n?(u=n,n=!0):"function"==typeof o?(u=o,o=null):"function"==typeof s?(u=s,s=null):"function"==typeof a&&(u=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(u),f.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(m,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var u=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(u.address,e,r).toString("hex"),delete a.address}catch(t){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,u,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof u?(h=u,u=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,u=u||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,u,f).spread(function(t,n,f){var d,y,m=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*c.DUST&&r!==f)return e(new c.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=c.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?m.splice(r.random(0,m.length),0,n):m.push(n)}t()},function(t){m.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new c.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var c=i.defer();return c.promise.nodeify(s),c.reject(t),c.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u=i.defer();return u.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){u.resolve(t)},function(t){t.requires_2fa?u.reject(new c.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?u.reject(new c.WalletInvalid2FAError):u.reject(t)}),u.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*c.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var u=s.script.decompile(a),f=u[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=u[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+c),u.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),u.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(c)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(c)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;p300?300:d.length,o=0,a=d.length;o=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!g(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),c=!t&&i&&!r;if((a&&o&&_(i,r)||c)&&m(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=m,l.ok=v,l.equal=function(t,e,r){t!=e&&m(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&m(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){g(t,e,!1)||m(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){g(t,e,!0)||m(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){g(t,e,!1)&&m(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){g(e,r,!0)&&m(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&m(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&m(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||m(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":268,"util/":26}],24:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],25:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],26:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var c=e.name?": "+e.name:"";return t.stylize("[Function"+c+"]","special")}if(g(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var u,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return g(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?g(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),M(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=b(r)?f(t,c.value,null):f(t,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function m(t){return"string"==typeof t}function v(t){return void 0===t}function g(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":25,_process:270,inherits:24}],27:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(t){return"[object Array]"===a.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}u(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var m=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(m),o.filterSeries=p(m),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var g=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(g),o.detectSeries=p(g),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,u(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),u(r,function(r){var n=c(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};u(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(u(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){c(t)||(t=[t]),u(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;u(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&u(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],28:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],d=0,p=u-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=u-i;b!==u&&0===h[b];)b++;for(var y=c.repeat(r);b>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function c(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var u=c(o),f=[],h=0;h=s.length||f.push(d)}if(1!==u)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var u=0;u<6;++u)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return u(t,8,5,!0)},fromWords:function(t){return u(t,5,8,!1)}}},{}],30:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function u(t){return a.charAt(t)}function f(t,e){var r=c[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,f=o[u-1];if(0!=f){var h=f*(1<1?o[u-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(u,v),v.subTo(o,o);o.t=0;){var g=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,g,r,m,0,u))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=u(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,m,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=u;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,m=t.t-1,v=!0,g=new BigInteger;for(i=l(t[m])-1;m>=0;){for(i>=c?b=t[m]>>i-c&u:(b=(t[m]&(1<0&&(b|=t[m-1]>>this.DB+i-c)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--m),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(y=o,o=g,g=y),n.mulTo(g,s[b],o)}for(;m>=0&&0==(t[m]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),u=o.slice(s),f=c.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===u,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^m[c>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[c>>16&255]^m[e>>8&255]^v[255&o]^i[p+1],h=t[c>>>24]^y[e>>16&255]^m[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^m[a>>8&255]^v[255&c]^i[p+3],p+=4,o=u,a=f,c=h;for(l=0;4>l;l++)b[r?3&-l:l]=g[o>>>24]<<24^g[a>>16&255]<<16^g[c>>8&255]<<8^g[255&e]^i[p++],u=o,o=a,a=c,c=e,e=u;return b}function c(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],c=this.o[1],u=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],c=this.o[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,u=0;for(e&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),u=i<<32-a):u^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,u,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=u+e|0,u=c,c=a,s=e+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=u.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),c=s.mode.ccm.s(t,c,r,e,o,a),u.concat(c.data,c.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,u=a.bitLength(e),f=a.clamp(e,u-o),h=a.bitSlice(e,u-o);u=(u-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&u>>>8*e;e++);return e<15-c&&(e=15-c),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],c=s.bitArray,u=c.j;if(n=[c.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=c.bitLength(e)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/u),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:c.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,u=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=u(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(c,n(c))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var c=e.slice(0),u=s.bitArray,f=u.bitLength(c);return a=a||128,i=i||[],a<=f?(e=u.bitSlice(c,f-a),c=u.bitSlice(c,0,f-a)):(e=c,c=[]),t=s.mode.gcm.s(o,t,c,i,r,a),u.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,c,u,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,u,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,u,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":321}],39:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],40:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":39}],41:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),c=t("./networks"),u=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){u(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||c.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":50,"./script":51,"./templates":53,"./types":77,bech32:29,bs58check:106,cashaddress:113,"safe-buffer":321,typeforce:351}],42:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),c=t("varuint-bitcoin"),u=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=u.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=c.decode(t,e),e+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":44,"./transaction":75,"./types":77,"buffer-reverse":108,"merkle-lib/fastRoot":263,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],43:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":298,"varuint-bitcoin":357}],44:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":118}],45:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),u=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(c).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(u.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=u.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),c=BigInteger.fromBuffer(t),l=u.n,d=u.G;return f(t,a,function(t){var i=d.multiply(t);return!u.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(c.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=u.n,s=u.G,a=e.r,c=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=c.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!u.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:u}},{"./ecsignature":47,"./types":77,bigi:32,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],46:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),c=t("./types"),u=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(c.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=u.decode(t),n=r.version;if(c.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":41,"./crypto":44,"./ecdsa":45,"./networks":50,"./types":77,bigi:32,ecurve:199,randombytes:303,typeforce:351,wif:359}],47:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":77,bigi:32,bip66:38,buffer:110,typeforce:351}],48:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),c=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),u=t("ecurve"),f=u.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=u.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),u=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,u);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":44,"./ecpair":46,"./networks":50,"./types":77,bigi:32,bs58check:106,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],49:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":41,"./block":42,"./bufferutils":43,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./hdnode":48,"./networks":50,"./script":51,"./transaction":75,"./transaction_builder":76,"bitcoin-ops":39}],50:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],51:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),c=t("bitcoin-ops"),u=t("bitcoin-ops/map"),f=c.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===c.OP_0||t>=c.OP_1&&t<=c.OP_16||t===c.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?c.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?c.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var u=t.slice(r,r+a.number);r+=a.number;var f=d(u);void 0!==f?e.push(f):e.push(u)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==c[t]?c[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return u[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===c.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var m=t("./templates");for(var v in m)e.exports[v]=m[v]},{"./script_number":52,"./templates":53,"./types":77,bip66:38,"bitcoin-ops":39,"bitcoin-ops/map":40,"pushdata-bitcoin":298,"safe-buffer":321,typeforce:351}],52:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":321}],53:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),c=t("./scripthash"),u=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:c.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(u.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(c.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return u.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:u,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":51,"./multisig":54,"./nulldata":57,"./pubkey":58,"./pubkeyhash":61,"./scripthash":64,"./witnesscommitment":67,"./witnesspubkeyhash":69,"./witnessscripthash":72}],54:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":55,"./output":56}],55:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function u(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,t.map(function(t){return t===o.OP_0?c:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(u(t,e))},encodeStack:u}},{"../../script":51,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],56:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function c(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},e.exports={check:c,decode:function(t,e){var r=n.decompile(t);return o(c,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":51,"../types":77,"bitcoin-ops":39,typeforce:351}],58:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":59,"./output":60,dup:54}],59:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":51,typeforce:351}],60:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":51,"bitcoin-ops":39,typeforce:351}],61:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":62,"./output":63,dup:54}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":51,typeforce:351}],63:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],64:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":65,"./output":66,dup:54}],65:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":51,"safe-buffer":321,typeforce:351}],66:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],67:[function(t,e,r){e.exports={output:t("./output")}},{"./output":68}],68:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},e.exports={check:c,decode:function(t){return o(c,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],69:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":70,"./output":71,dup:54}],70:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":51,typeforce:351}],71:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],72:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":73,"./output":74,dup:54}],73:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":65}],74:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],75:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),c=t("typeforce"),u=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:m};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function c(){return n(a())}function u(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(u.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function c(e){i=t.writeUInt32LE(e,i)}function u(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){u(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),u(this.ins.length),this.ins.forEach(function(t){o(t.hash),c(t.index),h(t.script),c(t.sequence)}),u(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;u((e=t.witness).length),e.forEach(h)}),c(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],76:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),c=t("bitcoin-ops"),u=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function m(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,c,u,f,l,d,p,b=!1,v=!1,g=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(g=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(u=e[e.length-1],f=s.classifyOutput(u),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(u)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(u)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(u)))throw new Error("unsupported witness script");a=u,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(c){if(!m(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return g&&(A.redeemScript=c,A.redeemScriptType=l),v&&(A.witnessScript=u,A.witnessScriptType=f),A}function g(t,e,r){u(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,c,l,d,p,b,y,m,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,m=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=g(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(m=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,m=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(c=t.prevOutType,l=t.prevOutScript,!(a=g(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,m=c,v=l}else a=g(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,m=c=h.P2PKH,v=l;if(void 0!==n||E){if(u(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}m===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=m,t.prevOutScript=l,t.prevOutType=c,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||c.OP_0}),n||(e=e.filter(function(t){return t!==c.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(u(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){u(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,u){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!c.verify(f,h.signature)&&(o[u]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=g(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!m(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=e.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!c.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351}],77:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:351}],78:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var u,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(c),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(u=d,f=i("sha256").update(u).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:81,buffer:110,"buffer-equals":107,"create-hash":118,secp256k1:323,"varuint-bitcoin":357}],79:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var u=0;t[u]===n&&u0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===e[c]&&c=0;--u)a+=t[n[u]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],80:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":79}],81:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:80,buffer:110,"create-hash":118}],82:[function(t,e,r){!function(e,r){"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 Buffer;"object"==typeof e?e.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{Buffer="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:t("buffer").Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:u[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,c="le"===e,u=new t(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(v,m),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new g;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],83:[function(t,e,r){var n;function i(t){this.rand=t}if(e.exports=function(t){return n||(n=new i(null)),n.generate(t)},e.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[m++],s=u[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[m++],a=u[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[m++],c=u[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[m++],d=o,p=s,b=a,y=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[m++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[m++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[m++],c=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[m++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[s]=u,n[u]=s;var f=t[s],h=t[f],l=t[h],d=257*t[u]^16843008*u;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(t){this._key=n(t),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/e|0]<<24):e>6&&o%e==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-e]^c}for(var u=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u},c.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},c.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=c},{"safe-buffer":321}],85:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),c=t("./incr32");function u(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var u=this._cipher.encryptBlock(a);this._ghash=new s(u),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,u=Buffer.alloc(8);u.writeUIntBE(a,0,8),n.update(u),t._finID=n.state;var f=Buffer.from(t._finID);return c(f),f}(this,r,u),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(u,i),u.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":84,"./authCipher":85,"./modes":97,"./streamCipher":100,"cipher-base":114,evp_bytestokey:218,inherits:258,"safe-buffer":321}],88:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),c=t("evp_bytestokey");function u(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(u,s),u.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new u(s.module,e,r)}u.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":321}],90:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],91:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":109}],92:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":109,"safe-buffer":321}],93:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,c=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return c}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return u(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(D(t,ArrayBuffer)||t&&D(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||D(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(D(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),c=this.slice(n,i),u=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return g(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function R(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(C,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function D(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":111,buffer:110,ieee754:257}],111:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],112:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),c=t.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=c.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=u(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+u.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:u.scriptType,prefix:e.prefix,hash:Buffer.from(c.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(c(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":112,buffer:110}],114:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:258,"safe-buffer":321,stream:238,string_decoder:239}],115:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:c(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),c=e;c=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-c.length]+c+r:c+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 u=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[u-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):m(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return g[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],139:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),c=s.toRed(r.mont(e.prime2)),u=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=c.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(u).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":138,buffer:110,randombytes:303}],140:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":141}],141:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],142:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],143:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),c=t("./algorithms.json");function u(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new u(t)}function l(t){return new f(t)}Object.keys(c).forEach(function(t){c[t].id=Buffer.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]}),o(u,i.Writable),u.prototype._write=function(t,e,r){this._hash.update(t),r()},u.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},u.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":141,"./sign":144,"./verify":145,"create-hash":118,inherits:258,"readable-stream":319,"safe-buffer":321}],144:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),c=t("./curves.json");function u(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,c,u){var f=o(r);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,c=r.data.g,u=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===c.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(u.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");e=Buffer.concat([u,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],m=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,u[r]=v;v=16843009*m^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[m^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],u=0;u>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,c,u,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var c=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&u]^r[d++],m=n[h>>>24]^i[l>>>16&255]^o[u>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[u>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];u=b,f=y,h=m,l=v}b=(a[u>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[d++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=m,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],152:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),u=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?g:m}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(c)},parse:function(t){var e=c.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=u.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=m.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,m.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":153,"./evpkdf":156}],153:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},u=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,u=t.min(4*c,i);if(c){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],155:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],156:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,c=s.words,u=0;u>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],161:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],c=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],m=t[e+6],v=t[e+7],g=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],M=o[0],T=o[1],I=o[2],P=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=u(T=u(T=u(T=u(T,I=u(I,P=u(P,M=u(M,T,I,P,s,7,a[0]),T,I,c,12,a[1]),M,T,d,17,a[2]),P,M,p,22,a[3]),I=u(I,P=u(P,M=u(M,T,I,P,b,7,a[4]),T,I,y,12,a[5]),M,T,m,17,a[6]),P,M,v,22,a[7]),I=u(I,P=u(P,M=u(M,T,I,P,g,7,a[8]),T,I,w,12,a[9]),M,T,_,17,a[10]),P,M,E,22,a[11]),I=u(I,P=u(P,M=u(M,T,I,P,S,7,a[12]),T,I,k,12,a[13]),M,T,A,17,a[14]),P,M,x,22,a[15]),I=f(I,P=f(P,M=f(M,T,I,P,c,5,a[16]),T,I,m,9,a[17]),M,T,E,14,a[18]),P,M,s,20,a[19]),I=f(I,P=f(P,M=f(M,T,I,P,y,5,a[20]),T,I,_,9,a[21]),M,T,x,14,a[22]),P,M,b,20,a[23]),I=f(I,P=f(P,M=f(M,T,I,P,w,5,a[24]),T,I,A,9,a[25]),M,T,p,14,a[26]),P,M,g,20,a[27]),I=f(I,P=f(P,M=f(M,T,I,P,k,5,a[28]),T,I,d,9,a[29]),M,T,v,14,a[30]),P,M,S,20,a[31]),I=h(I,P=h(P,M=h(M,T,I,P,y,4,a[32]),T,I,g,11,a[33]),M,T,E,16,a[34]),P,M,A,23,a[35]),I=h(I,P=h(P,M=h(M,T,I,P,c,4,a[36]),T,I,b,11,a[37]),M,T,v,16,a[38]),P,M,_,23,a[39]),I=h(I,P=h(P,M=h(M,T,I,P,k,4,a[40]),T,I,s,11,a[41]),M,T,p,16,a[42]),P,M,m,23,a[43]),I=h(I,P=h(P,M=h(M,T,I,P,w,4,a[44]),T,I,S,11,a[45]),M,T,x,16,a[46]),P,M,d,23,a[47]),I=l(I,P=l(P,M=l(M,T,I,P,s,6,a[48]),T,I,v,10,a[49]),M,T,A,15,a[50]),P,M,y,21,a[51]),I=l(I,P=l(P,M=l(M,T,I,P,S,6,a[52]),T,I,p,10,a[53]),M,T,_,15,a[54]),P,M,c,21,a[55]),I=l(I,P=l(P,M=l(M,T,I,P,g,6,a[56]),T,I,x,10,a[57]),M,T,m,15,a[58]),P,M,k,21,a[59]),I=l(I,P=l(P,M=l(M,T,I,P,b,6,a[60]),T,I,E,10,a[61]),M,T,d,15,a[62]),P,M,w,21,a[63]),o[0]=o[0]+M|0,o[1]=o[1]+T|0,o[2]=o[2]+I|0,o[3]=o[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function u(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],162:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],168:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],169:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],170:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],171:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],172:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,c;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),c=o.words,u=s.words,f=r.keySize,h=r.iterations;c.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;n[0]^=u,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=u,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],174:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;i[0]^=u,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=u,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],176:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,M,T=this._hash.words,I=h.words,P=l.words,B=a.words,R=c.words,C=u.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)M=o+t[e+B[r]]|0,M+=r<16?p(s,d,w)+I[0]:r<32?b(s,d,w)+I[1]:r<48?y(s,d,w)+I[2]:r<64?m(s,d,w)+I[3]:v(s,d,w)+I[4],M=(M=g(M|=0,C[r]))+_|0,o=_,_=w,w=g(d,10),d=s,s=M,M=E+t[e+R[r]]|0,M+=r<16?v(S,k,A)+P[0]:r<32?m(S,k,A)+P[1]:r<48?y(S,k,A)+P[2]:r<64?b(S,k,A)+P[3]:p(S,k,A)+P[4],M=(M=g(M|=0,O[r]))+x|0,E=x,x=A,A=g(k,10),k=S,S=M;M=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=M},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function m(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function g(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],177:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|t[e+u];else{var f=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=f<<1|f>>>31}var h=(n<<5|n>>>27)+c+o[u];h+=u<20?1518500249+(i&s|~i&a):u<40?1859775393+(i^s^a):u<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],178:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":153,"./sha256":179}],179:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),c[i]=r(e.pow(n,1/3)),i++),n++}();var u=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)u[d]=0|t[e+d];else{var p=u[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[d-2],m=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[d]=b+u[d-7]+m+u[d-16]}var v=n&i^n&o^i&o,g=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+c[d]+u[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(g+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],180:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],u=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){c[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)u[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var m=h[(l+4)%5],v=h[(l+1)%5],g=v.high,w=v.low;for(d=m.high^(g<<1|w>>>31),p=m.low^(w<<1|g>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[u[_]];A.high=d,A.low=p}var x=h[0],M=r[0];x.high=M.high,x.low=M.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],I=h[_],P=h[(l+1)%5+5*b],B=h[(l+2)%5+5*b];T.high=I.high^~P.high&B.high,T.low=I.low^~P.low&B.low}T=r[0];var R=f[a];T.high^=R.high,T.low^=R.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),u.push(d),u.push(l)}return new i.init(u,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],181:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":153,"./sha512":182,"./x64-core":184}],182:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var t=0;t<80;t++)u[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,m=o.high,v=o.low,g=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,M=l.high,T=l.low,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_,D=E,U=S,K=k,H=A,q=x,z=M,F=T,W=0;W<80;W++){var V=u[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var J=u[W-15],Z=J.high,X=J.low,$=(Z>>>1|X<<31)^(Z>>>8|X<<24)^Z>>>7,Q=(X>>>1|Z<<31)^(X>>>8|Z<<24)^(X>>>7|Z<<25),tt=u[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=u[W-7],st=ot.high,at=ot.low,ct=u[W-16],ut=ct.high,ft=ct.low;G=(G=(G=$+st+((Y=Q+at)>>>0>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ut+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=N&U^~N&H,dt=D&K^~D&q,pt=I&B^I&C^B&C,bt=P&R^P&O^R&O,yt=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),mt=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),vt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),wt=c[W],_t=wt.high,Et=wt.low,St=z+vt+((ht=F+gt)>>>0>>0?1:0),kt=mt+bt;z=H,F=q,H=U,q=K,U=N,K=D,N=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0

>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((D=j+ht|0)>>>0>>0?1:0)|0,L=C,j=O,C=B,O=R,B=I,R=P,I=St+(yt+pt+(kt>>>0>>0?1:0))+((P=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+P,n.high=d+I+(p>>>0

>>0?1:0),y=i.low=y+R,i.high=b+B+(y>>>0>>0?1:0),v=o.low=v+O,o.high=m+C+(v>>>0>>0?1:0),w=s.low=w+j,s.high=g+L+(w>>>0>>0?1:0),E=a.low=E+D,a.high=_+N+(E>>>0>>0?1:0),k=f.low=k+K,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+q,h.high=A+H+(x>>>0>>0?1:0),T=l.low=T+F,l.high=M+z+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],183:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var u=i[o]=[],f=c[o];for(r=0;r<24;r++)u[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^i[c])&f[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":186,_process:270}],186:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,c=t.keys.length-2;c>=0;c-=2){var u=t.keys[c],f=t.keys[c+1];o.expand(s,t.tmp,0),u^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(u,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":189,"./utils":192,inherits:258,"minimalistic-assert":265}],191:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":189,"./des":190,inherits:258,"minimalistic-assert":265}],192:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),e.cmp(c)){if(!e.cmp(u))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":82,"miller-rabin":264,randombytes:303}],196:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],197:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":201,assert:23,bigi:32}],198:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],199:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":197,"./names":200,"./point":201}],200:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),c=new BigInteger(e.h,16),u=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,u,f,a,c)}},{"./curve":197,"./curves.json":198,bigi:32}],201:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),u=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(u.shiftLeft(1)).multiply(t.z).subtract(c).multiply(s).mod(this.curve.p),l=u.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),u=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,u)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=e.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=t.pointFromX(c,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var u=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,u)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:23,bigi:32,"safe-buffer":321}],202:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":217,"./elliptic/curve":205,"./elliptic/curves":208,"./elliptic/ec":209,"./elliptic/eddsa":212,"./elliptic/utils":216,brorand:83}],203:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)c=(c<<1)+n[f];u.push(c)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){var a,c,u,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var m=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(m[1]=e[b].add(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].add(e[y].neg())):(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],g=s(r[b],r[y]);for(d=Math.max(g[0].length,d),l[b]=new Array(d),l[y]=new Array(d),c=0;c=0;a--){for(var k=0;a>=0;){var A=!0;for(c=0;c=0&&k++,E=E.dblp(k),a<0)break;for(c=0;c0?u=h[c][x-1>>1]:x<0&&(u=h[c][-x-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(c);this.zOne?(t=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),e=u.redMul(n.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),t=s.redSub(a).redISub(c).redMul(o),e=u.redMul(n.redSub(c)),r=u.redMul(o))}else n=a.redAdd(c),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(c)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(u,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(e=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(e=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],205:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":203,"./edwards":204,"./mont":206,"./short":207}],206:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),c=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],207:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function c(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(c,s),e.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),m=new i(1),v=0;0!==l.cmpn(0);){var g=d.div(l);u=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&u.cmp(h)<0)e=c.neg(),r=p,n=u.neg(),o=f;else if(n&&2==++v)break;c=u,d=l,l=u,y=p,p=f,m=b,b=w}s=u.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(u,s.BasePoint),c.prototype.jpoint=function(t,e,r){return new u(this,t,e,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),l=c.redSqr().redIAdd(f).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},u.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},u.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],208:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function c(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":205,"./precomputed/secp256k1":215,"./utils":216,"hash.js":244}],209:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),c=o.assert,u=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new u(this,t)},h.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),c=t.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new f({r:y,s:m,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(t).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,u=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=u.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":208,"../utils":216,"./key":210,"./signature":211,"bn.js":82,brorand:83,"hmac-drbg":256}],210:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":216,"bn.js":82}],211:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function c(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var c=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var u=a(t,r);if(!1===u)return!1;if(t.length!==u+r.place)return!1;var f=t.slice(r.place,u+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(c),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=c(e),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,e.length),(n=n.concat(e)).push(2),u(n,r.length);var o=n.concat(r),s=[48];return u(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":216,"bn.js":82}],212:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,c=t("./key"),u=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-c:c,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,c=t.andln(3)+i&3,u=e.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==c?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":82,"minimalistic-assert":265,"minimalistic-crypto-utils":266}],217:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],218:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var u=new n;u.update(c),u.update(t),e&&u.update(e),c=u.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,c.length),c.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,c.length-f);c.copy(a,l,f,f+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":262,"safe-buffer":321}],219:[function(t,e,r){},{}],220:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(u=r.slice()).length,c=0;c0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],221:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,u=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,m="-",v=/^xn--/,g=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function M(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function P(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function B(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function R(t){var e,r,n,i,o,s,a,c,d,p,v,g=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(m))<0&&(r=0),n=0;n=128&&A("not-basic"),g.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||c>S((u-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(u/(p=f-d))&&A("overflow"),s*=p;k=B(_-o,e=g.length+1,0==o),S(_/e)>u-E&&A("overflow"),E+=S(_/e),_%=e,g.splice(_++,0,E)}return I(g)}function C(t){var e,r,n,i,o,s,a,c,d,p,v,g,w,_,E,x=[];for(g=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((u-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;su&&A("overflow"),v==e){for(c=r,d=f;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=c-p,_=f-p,x.push(k(P(p+E%_,0))),c=S(E/_);x.push(k(P(c,0))),o=B(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:I},decode:R,encode:C,toASCII:function(t){return M(t,function(t){return g.test(t)?"xn--"+C(t):t})},toUnicode:function(t){return M(t,function(t){return v.test(t)?R(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],222:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":223}],223:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),u=0;u0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),I(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function B(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function C(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?B(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&B(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?P(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&B(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var c=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:g;function u(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",m),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",u),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(c):n.once("end",c),t.on("unpipe",u);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,I(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==C(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),g(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",v),g()}function v(){l("onfinish"),t.removeListener("close",m),g()}function g(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",m),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;m.WritableState=y;var u=Object.create(t("core-util-is"));u.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?c(g,t,r,s,i):g(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(e){if(a=a||t("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function g(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}u.inherits(m,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var c=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":223,"./internal/streams/destroy":229,"./internal/streams/stream":230,_process:270,"core-util-is":116,inherits:258,"process-nextick-args":231,"safe-buffer":237,timers:348,"util-deprecate":356}],228:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":237,util:219}],229:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":231}],230:[function(t,e,r){e.exports=t("events").EventEmitter},{events:220}],231:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],233:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":234}],234:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":223,"./lib/_stream_passthrough.js":224,"./lib/_stream_readable.js":225,"./lib/_stream_transform.js":226,"./lib/_stream_writable.js":227}],235:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":234}],236:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":227}],237:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],238:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",c),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",u),t.on("error",u),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:220,inherits:258,"readable-stream/duplex.js":222,"readable-stream/passthrough.js":233,"readable-stream/readable.js":234,"readable-stream/transform.js":235,"readable-stream/writable.js":236}],239:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=u,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],240:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{dup:24}],241:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],242:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{"./support/isBuffer":241,_process:270,dup:26,inherits:240}],243:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:258,"readable-stream":319,"safe-buffer":321}],244:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":255}],255:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var c=0,u=e;return c+=(u=u+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,c,u){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,c,u){return e+n+o+a+u>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:258,"minimalistic-assert":265}],256:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*b}},{}],258:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],259:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],260:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],261:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",u=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,m=2,v=4,g=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,M="...",T=800,I=16,P=1,B=2,R=1/0,C=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,N=j-1,D=j>>>1,U=[["ary",S],["bind",y],["bindKey",m],["curry",g],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],K="[object Arguments]",H="[object Array]",q="[object AsyncFunction]",z="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",J="[object Map]",Z="[object Number]",X="[object Null]",$="[object Object]",Q="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ct="[object DataView]",ut="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",mt="[object Uint32Array]",vt=/\b__p \+= '';/g,gt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,Mt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,It=/^\w*$/,Pt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Bt=/[\\^$.*+?()[\]{}|]/g,Rt=RegExp(Bt.source),Ct=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Nt=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Kt=/\\(\\)?/g,Ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,qt=/\w*$/,zt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Jt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Xt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",$t="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qt="[\\ud800-\\udfff]",te="["+$t+"]",ee="["+Xt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+$t+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ce,ue].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ce,ue].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ce,ue,Qt].join("|")+")",me=RegExp("['’]","g"),ve=RegExp(ee,"g"),ge=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Xt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ut]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[mt]=!0,Ae[K]=Ae[H]=Ae[at]=Ae[z]=Ae[ct]=Ae[F]=Ae[V]=Ae[G]=Ae[J]=Ae[Z]=Ae[$]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[K]=xe[H]=xe[at]=xe[ct]=xe[z]=xe[F]=xe[ut]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[J]=xe[Z]=xe[$]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[mt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Me={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Ie=parseInt,Pe="object"==typeof t&&t&&t.Object===Object&&t,Be="object"==typeof self&&self&&self.Object===Object&&self,Re=Pe||Be||Function("return this")(),Ce="object"==typeof r&&r&&!r.nodeType&&r,Oe=Ce&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Ce,je=Le&&Pe.process,Ne=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),De=Ne&&Ne.isArrayBuffer,Ue=Ne&&Ne.isDate,Ke=Ne&&Ne.isMap,He=Ne&&Ne.isRegExp,qe=Ne&&Ne.isSet,ze=Ne&&Ne.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Xe(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Me[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Mr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Re:Or.defaults(Re.Object(),e,Or.pick(Re,Se))).Array,Xt=e.Date,$t=e.Error,Qt=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=Qt.prototype,ae=ee.prototype,ce=e["__core-js_shared__"],ue=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ue.call(ee),be=Re._,ye=re("^"+ue.call(fe).replace(Bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,ge=e.Symbol,_e=e.Uint8Array,Me=Buffer?Buffer.allocUnsafe:n,Pe=xr(ee.getPrototypeOf,ee),Be=ee.create,Ce=ae.propertyIsEnumerable,Oe=oe.splice,je=ge?ge.isConcatSpreadable:n,Ne=ge?ge.iterator:n,nr=ge?ge.toStringTag:n,hr=function(){try{var t=Ko(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Re.clearTimeout&&e.clearTimeout,jr=Xt&&Xt.now!==Re.Date.now&&Xt.now,Nr=e.setTimeout!==Re.setTimeout&&e.setTimeout,Dr=te.ceil,Ur=te.floor,Kr=ee.getOwnPropertySymbols,Hr=Buffer?Buffer.isBuffer:n,qr=e.isFinite,zr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Xt.now,Yr=e.parseInt,Jr=te.random,Zr=oe.reverse,Xr=Ko(e,"DataView"),$r=Ko(e,"Map"),Qr=Ko(e,"Promise"),tn=Ko(e,"Set"),en=Ko(e,"WeakMap"),rn=Ko(ee,"create"),nn=en&&new en,on={},sn=ls(Xr),an=ls($r),cn=ls(Qr),un=ls(tn),fn=ls(en),hn=ge?ge.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ia(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof mn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new mn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Be)return Be(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function mn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function gn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,c=e&h,u=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return no(t,a)}else{var b=zo(t),y=b==G||b==Y;if(Ea(t))return Xi(t,c);if(b==$||b==K||y&&!o){if(a=u||y?{}:Wo(t),!c)return u?function(t,e){return io(t,qo(t),e)}(t,function(t,e){return t&&io(e,sc(e),t)}(a,t)):function(t,e){return io(t,Ho(t),e)}(t,Rn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return $i(t);case z:case F:return new s(+t);case ct:return function(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ut:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case mt:return Qi(t,r);case J:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,qt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,c)}}s||(s=new Sn);var m=s.get(t);if(m)return m;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Pa(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?u?Co:Ro:u?sc:oc)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),In(a,i,jn(n,e,r,i,t,s))}),a}function Nn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Dn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,c=t.length,u=[],f=e.length;if(!c)return u;r&&(e=$e(e,yr(r))),n?(s=Xe,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Pn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new gn,map:new($r||wn),string:new gn}},_n.prototype.delete=function(t){var e=Do(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return Do(this,t).get(t)},_n.prototype.has=function(t){return Do(this,t).has(t)},_n.prototype.set=function(t,e){var r=Do(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,c),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!$r||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):Qe(i,a):n||(i[i.length]=a)}return i}var Vn=co(),Gn=co(!0);function Yn(t,e){return t&&Vn(t,e,oc)}function Jn(t,e){return t&&Gn(t,e,oc)}function Zn(t,e){return Je(e,function(e){return Aa(t[e])})}function Xn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Xe:Ze,o=t[0].length,s=t.length,a=s,c=Ot(s),u=1/0,f=[];a--;){var h=t[a];a&&e&&(h=$e(h,yr(e))),u=Vr(h.length,u),c[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=c[0];t:for(;++l=a)return c;var u=r[n];return c*("desc"==u?-1:1)}}return t.index-e.index}(t,e,r)})}function gi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,c,1),Oe.call(t,c,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Jr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>C)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Bc),t+"")}function Ai(t){return An(pc(t))}function xi(t,e){var r=pc(t);return us(r,Ln(e,0,r.length))}function Mi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,c=t;null!=c&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,u=new En}else u=e?[]:c;t:for(;++n=i?t:Bi(t,e,r)}var Zi=Lr||function(t){return Re.clearTimeout(t)};function Xi(t,e){if(e)return t.slice();var r=t.length,n=Me?Me(r):new t.constructor(r);return t.copy(n),n}function $i(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function Qi(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,c=null===e,u=e==e,f=ja(e);if(!c&&!f&&!s&&t>e||s&&a&&u&&!c&&!f||i&&a&&u||!r&&u||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Bo(function(e){var r=e.length,i=r,o=mn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!c&&"wrapper"==Lo(a))var c=new mn([],!0)}for(i=c?i:r;++i1&&g.reverse(),h&&uc))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Nt):[]}(n),r)))}function cs(t){var e=0,r=0;return function(){var i=Gr(),o=I-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function us(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Cs(t,r="function"==typeof r?(t.pop(),r):n)});function Ks(t){var e=pn(t);return e.__chain__=!0,e}function Hs(t,e){return e(t)}var qs=Bo(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Hs,args:[o],thisArg:n}),new mn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var zs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Cn(t,r,1)});var Fs=lo(ms),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Kn)(t,No(e,3))}function Gs(t,e){return(va(t)?Ge:Hn)(t,No(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Cn(t,r,[e])});var Js=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Kn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Cn(t,r,e)});function Xs(t,e){return(va(t)?$e:di)(t,No(e,3))}var $s=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var Qs=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Re.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Mr(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|m;if(r.length){var i=Mr(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,c,u,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,c=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function m(){var t=ta();if(y(t))return v(t);u=os(m,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return u=n,p&&i?b(t):(i=o=n,c)}function g(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(u===n)return function(t){return h=t,u=os(m,e),l?b(t):c}(f);if(d)return Zi(u),u=os(m,e),b(f)}return u===n&&(u=os(m,e)),c}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),g.cancel=function(){u!==n&&Zi(u),h=0,i=f=o=u=n},g.flush=function(){return u===n?c:v(ta())},g}var sa=ki(function(t,e){return Dn(t,1,e)}),aa=ki(function(t,e,r){return Dn(t,Fa(e)||0,r)});function ca(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ca.Cache||_n),r}function ua(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ca.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?$e(e[0],yr(No())):$e(Wn(e,1),yr(No()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ma=oi(function(){return arguments}())?oi:function(t){return Ia(t)&&fe.call(t,"callee")&&!Ce.call(t,"callee")},va=Ot.isArray,ga=De?yr(De):function(t){return Ia(t)&&Qn(t)==at};function wa(t){return null!=t&&Ma(t.length)&&!Aa(t)}function _a(t){return Ia(t)&&wa(t)}var Ea=Hr||Fc,Sa=Ue?yr(Ue):function(t){return Ia(t)&&Qn(t)==F};function ka(t){if(!Ia(t))return!1;var e=Qn(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ra(t)}function Aa(t){if(!Ta(t))return!1;var e=Qn(t);return e==G||e==Y||e==q||e==Q}function xa(t){return"number"==typeof t&&t==qa(t)}function Ma(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=C}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ia(t){return null!=t&&"object"==typeof t}var Pa=Ke?yr(Ke):function(t){return Ia(t)&&zo(t)==J};function Ba(t){return"number"==typeof t||Ia(t)&&Qn(t)==Z}function Ra(t){if(!Ia(t)||Qn(t)!=$)return!1;var e=Pe(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ue.call(r)==pe}var Ca=He?yr(He):function(t){return Ia(t)&&Qn(t)==tt};var Oa=qe?yr(qe):function(t){return Ia(t)&&zo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ia(t)&&Qn(t)==rt}function ja(t){return"symbol"==typeof t||Ia(t)&&Qn(t)==nt}var Na=ze?yr(ze):function(t){return Ia(t)&&Ma(t.length)&&!!Ae[Qn(t)]};var Da=_o(li),Ua=_o(function(t,e){return t<=e});function Ka(t){if(!t)return[];if(wa(t))return La(t)?Br(t):no(t);if(Ne&&t[Ne])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Ne]());var e=zo(t);return(e==J?Ar:e==et?Tr:pc)(t)}function Ha(t){return t?(t=Fa(t))===R||t===-R?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function qa(t){var e=Ha(t),r=e%1;return e==e?r?e-r:e:0}function za(t){return t?Ln(qa(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Ie(t.slice(2),r?2:8):zt.test(t)?L:+t}function Wa(t){return io(t,sc(t))}function Va(t){return null==t?"":Ni(t)}var Ga=so(function(t,e){if($o(e)||wa(e))io(e,oc(e),t);else for(var r in e)fe.call(e,r)&&In(t,r,e[r])}),Ya=so(function(t,e){io(e,sc(e),t)}),Ja=so(function(t,e,r,n){io(e,sc(e),t,n)}),Za=so(function(t,e,r,n){io(e,oc(e),t,n)}),Xa=Bo(On);var $a=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Co(t),r),n&&(r=jn(r,h|l|d,Io));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fc=Bo(function(t,e){return null==t?{}:function(t,e){return gi(t,e,function(e,r){return ec(t,r)})}(t,e)});function hc(t,e){if(null==t)return{};var r=$e(Co(t),function(t){return[t]});return e=No(e),gi(t,r,function(t,r){return e(t,r[0])})}var lc=Ao(oc),dc=Ao(sc);function pc(t){return null==t?[]:mr(t,oc(t))}var bc=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yc(e):e)});function yc(t){return kc(Va(t).toLowerCase())}function mc(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vc=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),gc=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wc=uo("toLowerCase");var _c=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Ec=fo(function(t,e,r){return t+(r?" ":"")+kc(e)});var Sc=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),kc=uo("toUpperCase");function Ac(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(e)||[]}var xc=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new $t(t)}}),Mc=Bo(function(t,e){return Ve(e,function(e){e=hs(e),Cn(t,e,na(t[e],t))}),t});function Tc(t){return function(){return t}}var Ic=po(),Pc=po(!0);function Bc(t){return t}function Rc(t){return ui("function"==typeof t?t:jn(t,h))}var Cc=ki(function(t,e){return function(r){return ii(r,t,e)}}),Oc=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lc(t,e,r){var n=oc(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,oc(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,Qe([this.value()],arguments))})}),t}function jc(){}var Nc=vo($e),Dc=vo(Ye),Uc=vo(rr);function Kc(t){return Jo(t)?fr(hs(t)):function(t){return function(e){return Xn(e,t)}}(t)}var Hc=wo(),qc=wo(!0);function zc(){return[]}function Fc(){return!1}var Wc=mo(function(t,e){return t+e},0),Vc=So("ceil"),Gc=mo(function(t,e){return t/e},1),Yc=So("floor");var Jc,Zc=mo(function(t,e){return t*e},1),Xc=So("round"),$c=mo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Ja,pn.assignWith=Za,pn.at=Xa,pn.before=ra,pn.bind=na,pn.bindAll=Mc,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Ks,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(qa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Dr(i/e));oo?0:o+r),(i=i===n||i>o?o:qa(i))<0&&(i+=o),i=r>i?0:za(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ca(e))&&!(e=Ni(e))&&kr(t)?Ji(Br(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(qa(e),0),ki(function(r){var n=r[e],i=Ji(r,0,e);return n&&Qe(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Bi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Bi(t,0,(e=r||e===n?1:qa(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Bi(t,(e=i-(e=r||e===n?1:qa(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Hi(t,No(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Hi(t,No(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Hs,pn.toArray=Ka,pn.toPairs=lc,pn.toPairsIn=dc,pn.toPath=function(t){return va(t)?$e(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Na(t);if(e=No(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Pe(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Is,pn.unionBy=Ps,pn.unionWith=Bs,pn.uniq=function(t){return t&&t.length?Di(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Di(t,No(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Di(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Rs,pn.unzipWith=Cs,pn.update=function(t,e,r){return null==t?t:Ki(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Ki(t,e,Vi(r),i)},pn.values=pc,pn.valuesIn=function(t){return null==t?[]:mr(t,sc(t))},pn.without=Os,pn.words=Ac,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ns,pn.zip=Ds,pn.zipObject=function(t,e){return Fi(t||[],e||[],In)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Mi)},pn.zipWith=Us,pn.entries=lc,pn.entriesIn=dc,pn.extend=Ya,pn.extendWith=Ja,Lc(pn,pn),pn.add=Wc,pn.attempt=xc,pn.camelCase=bc,pn.capitalize=yc,pn.ceil=Vc,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Nn(t,e,oc(e))},pn.deburr=mc,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gc,pn.endsWith=function(t,e,r){t=Va(t),e=Ni(e);var i=t.length,o=r=r===n?i:Ln(qa(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Rt.test(t)?t.replace(Bt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:qn;return r&&Yo(t,e,r)&&(e=n),i(t,No(e,3))},pn.find=Fs,pn.findIndex=ms,pn.findKey=function(t,e){return ir(t,No(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,No(e,3),Jn)},pn.floor=Yc,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,No(e,3),sc)},pn.forInRight=function(t,e){return null==t?t:Gn(t,No(e,3),sc)},pn.forOwn=function(t,e){return t&&Yn(t,No(e,3))},pn.forOwnRight=function(t,e){return t&&Jn(t,No(e,3))},pn.get=tc,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=ec,pn.head=ws,pn.identity=Bc,pn.includes=function(t,e,r,n){t=wa(t)?t:pc(t),r=r&&!n?qa(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:qa(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ha(e),r===n?(r=e,e=0):r=Ha(r),function(t,e,r){return t>=Vr(e,r)&&t=-C&&t<=C},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Na,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ia(t)&&zo(t)==ot},pn.isWeakSet=function(t){return Ia(t)&&Qn(t)==st},pn.join=function(t,e){return null==t?"":zr.call(t,e)},pn.kebabCase=vc,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=qa(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,cr,o,!0)},pn.lowerCase=gc,pn.lowerFirst=wc,pn.lt=Da,pn.lte=Ua,pn.max=function(t){return t&&t.length?zn(t,Bc,ti):n},pn.maxBy=function(t,e){return t&&t.length?zn(t,No(e,2),ti):n},pn.mean=function(t){return ur(t,Bc)},pn.meanBy=function(t,e){return ur(t,No(e,2))},pn.min=function(t){return t&&t.length?zn(t,Bc,li):n},pn.minBy=function(t,e){return t&&t.length?zn(t,No(e,2),li):n},pn.stubArray=zc,pn.stubFalse=Fc,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zc,pn.nth=function(t,e){return t&&t.length?mi(t,qa(e)):n},pn.noConflict=function(){return Re._===this&&(Re._=be),this},pn.noop=jc,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return go(Ur(i),r)+t+go(Dr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Jr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Kn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Hn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:qa(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iC)return[];var r=j,n=Vr(t,j);e=No(e),t-=j;for(var i=pr(n,e);++r=s)return t;var c=r-Pr(i);if(c<1)return i;var u=a?Ji(a,0,c).join(""):t.slice(0,c);if(o===n)return u+i;if(a&&(c+=u.length-c),Ca(o)){if(t.slice(c).search(o)){var f,h=u;for(o.global||(o=re(o.source,Va(qt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;u=u.slice(0,l===n?c:l)}}else if(t.indexOf(Ni(o),c)!=c){var d=u.lastIndexOf(o);d>-1&&(u=u.slice(0,d))}return u+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Cr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Sc,pn.upperFirst=kc,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lc(pn,(Jc={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Jc[e]=t)}),Jc),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(qa(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:No(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Bc)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ua(No(t)))},vn.prototype.slice=function(t,e){t=qa(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=qa(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,c=e instanceof vn,u=a[0],f=c||va(e),h=function(t){var e=o.apply(pn,Qe([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof u&&1!=u.length&&(c=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=c&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Hs,args:[h],thisArg:n}),new mn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,m).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Hs,args:[Ts],thisArg:n}),new mn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return qi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Ne&&(pn.prototype[Ne]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Ce._=Or):Re._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],262:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function c(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function u(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=u(i,s=u(s,r=u(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=u(i,s=u(s,r=u(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=u(i,s=u(s,r=u(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=u(i,s=u(s,r=u(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":243,inherits:258,"safe-buffer":321}],263:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),c=0;!a.testn(c);c++);for(var u=t.shrn(c),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(u);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(u)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],267:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===u&&!1===isNaN(t))return e.long?c(r=t,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],268:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),c=1;cn)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,u,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,u=new Buffer(a),c=o-((f=Math.ceil(o/a))-1)*a),p.copy(u,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?u(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),u=e.slice(s+1),f=o(a,i(u,s)),h=o(u,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,"safe-buffer":321}],295:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),c=t("bn.js"),u=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,u=o("sha1").update(Buffer.alloc(0)).digest(),f=u.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([u,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new c(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):u(l,d)}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,randombytes:303,"safe-buffer":321}],296:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":82,"safe-buffer":321}],297:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":39}],299:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function c(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){o=f,u.port1.onmessage=c,c()};var f=function(){u.port2.postMessage(0)};o=function(){setTimeout(c,0),f()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(t){return function(){return a.apply(t,arguments)}}var u,f=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return B(t)?t:R(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):H(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=P(t);return B(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(H(e))},i.reject=function(e){t||a(K(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function M(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=M,x.all=F,x.reject=K,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=M,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return K(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return K(t)}}return K(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=I,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=P,k.isPromise=B,k.isPromiseAlike=R,k.isPending=function(t){return B(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!B(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return B(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var C,O,L,j=[],N=[],D=!0;function U(){j.length=0,N.length=0,D||(D=!0)}function K(t){var e=T({when:function(e){return e&&function(t){if(D){var e=l(N,t);-1!==e&&(N.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){D&&(N.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function H(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function q(t,e,r){return k(t).spread(e,r)}function z(t,e,r){return k(t).dispatch(e,r)}function F(t){return I(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;B(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,I(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return I(t,function(t){return t=d(t,k),I(F(d(t,function(t){return I(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),D=!1},U(),k.reject=K,k.fulfill=H,k.master=function(t){return T({isDef:function(){}},function(e,r){return z(t,e,r)},function(){return k(t).inspect()})},k.spread=q,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return K(t)}return o.done?o.value:I(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===m(t)||t instanceof u}(t)?t.value:K(t)}return I(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new u(t)},k.promised=function(t){return function(){return q([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=z,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(C=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),C.apply(C,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],300:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=t.length;c>0&&u>c&&(u=c);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],301:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;au||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>u||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}c&&c.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:270,randombytes:303,"safe-buffer":321}],305:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(c," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],306:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=u;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(u,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):B(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,B(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(P,t))}function P(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function B(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function L(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function K(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):I(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new g("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function a(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==K(i.pipes,t))&&!h&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){c("onfinish"),t.removeListener("close",p),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?I(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(C,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(C,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,P(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":305,"./_stream_duplex":306,"./internal/streams/destroy":313,"./internal/streams/state":317,"./internal/streams/stream":318,_process:270,buffer:110,inherits:258,"util-deprecate":356}],311:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[c]?n(t[c]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[u]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[c]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[u]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":314,_process:270}],312:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))})});return r.reduce(u)}},{"../../../errors":305,"./end-of-stream":314}],317:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":305}],318:[function(t,e,r){arguments[4][230][0].apply(r,arguments)},{dup:230,events:220}],319:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":306,"./lib/_stream_passthrough.js":307,"./lib/_stream_readable.js":308,"./lib/_stream_transform.js":309,"./lib/_stream_writable.js":310,"./lib/internal/streams/end-of-stream.js":314,"./lib/internal/streams/pipeline.js":316}],320:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,g=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,M;A<16?(x=p(r,n,i,l,g,t[s[A]],f[0],c[A]),M=v(w,_,E,S,k,t[a[A]],h[0],u[A])):A<32?(x=b(r,n,i,l,g,t[s[A]],f[1],c[A]),M=m(w,_,E,S,k,t[a[A]],h[1],u[A])):A<48?(x=y(r,n,i,l,g,t[s[A]],f[2],c[A]),M=y(w,_,E,S,k,t[a[A]],h[2],u[A])):A<64?(x=m(r,n,i,l,g,t[s[A]],f[3],c[A]),M=b(w,_,E,S,k,t[a[A]],h[3],u[A])):(x=v(r,n,i,l,g,t[s[A]],f[4],c[A]),M=p(w,_,E,S,k,t[a[A]],h[4],u[A])),r=g,g=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=M}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+g+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:110,"hash-base":243,inherits:258}],321:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],322:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:270,buffer:110}],323:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":327,"./lib/elliptic":326}],324:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":259}],325:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var c=t[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+t[i]}if(!(c>n-i)){var u=i;for(i+=c;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);c>0&&0===t[u];c-=1,u+=1);if(!(c>32)){var h=t.slice(u,u+c);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:38,"safe-buffer":321}],326:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),c=a.curve;function u(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(c.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):c.n.sub(e).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=u(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==u(t)},r.publicKeyTweakAdd=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=c.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(c.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var u=new i(e);if(u.cmp(c.n)>=0||u.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=u(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},u=new i(o.r),f=new i(o.s);if(u.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(u.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":328,"bn.js":82,"create-hash":118,elliptic:202,"safe-buffer":321}],327:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":321}],330:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function u(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+u(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],332:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=u(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],333:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":329,"./sha256":334,inherits:258,"safe-buffer":321}],334:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=t.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((e=r[m-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[m-7]+l(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+h(d)+c(d,p,b)+o[v]+r[v]|0,w=f(n)+u(n,i,s)|0;y=b,b=p,p=d,d=a+g|0,a=s,s=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],335:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":329,"./sha512":336,inherits:258,"safe-buffer":321}],336:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,m=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,M=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var I=e[T-30],P=e[T-30+1],B=l(I,P),R=d(P,I),C=p(I=e[T-4],P=e[T-4+1]),O=b(P,I),L=e[T-14],j=e[T-14+1],N=e[T-32],D=e[T-32+1],U=R+j|0,K=B+L+y(U,R)|0;K=(K=K+C+y(U=U+O|0,O)|0)+N+y(U=U+D|0,D)|0,e[T]=K,e[T+1]=U}for(var H=0;H<160;H+=2){K=e[H],U=e[H+1];var q=u(r,n,i),z=u(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[H],J=o[H+1],Z=c(a,m,v),X=c(k,A,x),$=M+G|0,Q=g+V+y($,M)|0;Q=(Q=(Q=Q+Z+y($=$+X|0,X)|0)+Y+y($=$+J|0,J)|0)+K+y($=$+U|0,U)|0;var tt=W+z|0,et=F+q+y(tt,W)|0;g=v,M=x,v=m,x=A,m=a,A=k,a=s+Q+y(k=S+$|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=Q+et+y(w=$+tt|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+M|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+m+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,x)|0,this._hh=this._hh+g+y(this._hl,M)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],337:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var c,u,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(c=t.j[r])[0];var b=c[1],y=c[2],m=c[3],v=c[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^m[255&e]^i[d],u=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^m[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^m[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^m[255&a]^i[d+3],d+=4,o=c,s=u,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],c=o,o=s,s=a,a=e,e=c;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],c=this.j[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=u+r|0,u=c,c=a,s=r+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(e=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,c,u,f=[],h=n.bitArray;for(u=1;32*f.length<(i||1);u++){for(o=s=t.encrypt(h.concat(e,[u])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){c.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":342,"./is-object":344,"./request-base":345,"./response-base":346,"component-emitter":115}],344:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],345:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":344}],346:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":347}],347:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],348:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new u(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new u(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":270,timers:348}],349:[function(t,e,r){var n=t("./native");function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function c(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),c('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,e.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},{"./native":352}],350:[function(t,e,r){(function(Buffer){(function(){var r=t("./native"),n=t("./errors");function i(t){return Buffer.isBuffer(t)}function o(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function s(t,e){var r=t.toJSON();function i(i){if(!t(i))return!1;if(i.length===e)return!0;throw n.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var a=s.bind(null,r.Array),c=s.bind(null,i),u=s.bind(null,o),f=s.bind(null,r.String);var h=Math.pow(2,53)-1;var l={ArrayN:a,Buffer:i,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:o,HexN:u,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":259,"./errors":349,"./native":352}],351:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":349,"./extra":350,"./native":352}],352:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],353:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,u=21,f=28,h=u*f,l=c*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var m=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function g(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?C+="x":C+=R[O];if(!C.match(d)){var j=P.slice(0,M),N=P.slice(M+1),D=R.match(p);D&&(j.push(D[1]),N.unshift(D[2])),N.length&&(g="/"+N.join(".")+g),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+U,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[E])for(M=0,B=f.length;M0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,M=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),M++):M&&(S.splice(T,1),M--);if(!_&&!E)for(;M--;M)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var I,P=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=P?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift()));return(_=_||r.host&&S.length)&&!P&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":355,punycode:221,querystring:302}],355:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],356:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":321}],358:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),c=0,u=a.length;c0})})})}),s.then(function(t){o.resolve({has_transactions:t})},function(t){o.reject(t)}),w(o.promise,r)},_.prototype.addressUnconfirmedTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressTransactions(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){if(null===t.data)return t;var e=n.converter.convertAddressTxs(t);return e.data=e.data.filter(function(t){return!t.confirmations}),e}),r)},_.prototype.addressUnspentOutputs=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(e){return null===e.data?e:n.converter.convertAddressUnspentOutputs(e,t)}),r)},_.prototype.batchAddressUnspentOutputs=function(t,e,r){var n=this;return n.converter instanceof u?w(n.dataClient.get(n.converter.getUrlForBatchAddressUnspent(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBatchAddressUnspentOutputs(t)}),r):("function"==typeof e&&(r=e,e=null),w(n.dataClient.post("/address/unspent-outputs",e,{addresses:t}),r))},_.prototype.verifyAddress=function(t,e,r){return this.verifyMessage(t,t,e,r)},_.prototype.allBlocks=function(t,e){var r=this;return"function"==typeof t&&(e=t,t=null),w(r.dataClient.get(r.converter.getUrlForAllBlocks(),r.converter.paginationParams(t)).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlocks(t)}),e)},_.prototype.block=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForBlock(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertBlock(t.data)}),e)},_.prototype.blockLatest=function(t){var e=this;return w(e.dataClient.get(e.converter.getUrlForBlock("latest"),null).then(function(t){return e.converter.handleErrors(e,t)}).then(function(t){return null===t.data?t:e.converter.convertBlock(t.data)}),t)},_.prototype.blockTransactions=function(t,e,r){var n=this;return"function"==typeof e&&(r=e,e=null),w(n.dataClient.get(n.converter.getUrlForBlockTransaction(t),n.converter.paginationParams(e)).then(function(t){return n.converter.handleErrors(n,t)}).then(function(t){return null===t.data?t:n.converter.convertBlockTxs(t)}),r)},_.prototype.transaction=function(t,e){var r=this;return w(r.dataClient.get(r.converter.getUrlForTransaction(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(e){return null===e.data?e:r.converter instanceof u?r.dataClient.get(r.converter.getUrlForRawTransaction(t),null).then(function(t){return[e,t.data]}).then(function(t){if(null!==t){var e=t[0],n=t[1];return r.converter.convertTx(e,n)}return t}):r.converter.convertTx(e)}),e)},_.prototype.transactions=function(t,e){var r=this;return r.converter instanceof u?w(r.dataClient.get(r.converter.getUrlForTransactions(t),null).then(function(t){return r.converter.handleErrors(r,t)}).then(function(t){return null===t.data?t:r.converter.convertTxs(t)}),e):w(r.dataClient.post("/transactions",null,t,null,!1),e)},_.prototype.allWebhooks=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/webhooks",t,e)},_.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.post("/webhook",null,{url:t,identifier:e},r)},_.prototype.getLegacyBitcoinCashAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromBase58Check(t,this.network),t}catch(t){}if((e=o.address.fromCashAddress(t,this.network)).version===o.script.types.P2PKH)r=this.network.pubKeyHash;else{if(e.version!==o.script.types.P2SH)throw new Error("Unsupported address type");r=this.network.scriptHash}return o.address.toBase58Check(e.hash,r)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getCashAddressFromLegacyAddress=function(t){if(this.network===o.networks.bitcoincash||this.network===o.networks.bitcoincashtestnet||this.network===o.networks.bitcoincashregtest){var e,r;try{return o.address.fromCashAddress(t,this.network),t}catch(t){}if((e=o.address.fromBase58Check(t,this.network)).version===this.network.pubKeyHash)r=o.script.types.P2PKH;else{if(e.version!==this.network.scriptHash)throw new Error("Unsupported address type");r=o.script.types.P2SH}return o.address.toCashAddress(e.hash,r,this.network.cashAddrPrefix)}throw new Error("Cash addresses only work on bitcoin cash")},_.prototype.getWebhook=function(t,e){return this.blocktrailClient.get("/webhook/"+t,null,e)},_.prototype.updateWebhook=function(t,e,r){return this.blocktrailClient.put("/webhook/"+t,null,e,r)},_.prototype.deleteWebhook=function(t,e){return this.blocktrailClient.delete("/webhook/"+t,null,null,e)},_.prototype.getWebhookEvents=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/webhook/"+t+"/events",e,r)},_.prototype.subscribeTransaction=function(t,e,r,n){var i={event_type:"transaction",transaction:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.subscribeAddressTransactions=function(t,e,r,n){var i={event_type:"address-transactions",address:e,confirmations:r};return this.blocktrailClient.post("/webhook/"+t+"/events",null,i,n)},_.prototype.batchSubscribeAddressTransactions=function(t,e,r){return e.forEach(function(t){t.event_type="address-transactions"}),this.blocktrailClient.post("/webhook/"+t+"/events/batch",null,e,r)},_.prototype.subscribeNewBlocks=function(t,e){return this.blocktrailClient.post("/webhook/"+t+"/events",null,{event_type:"block"},e)},_.prototype.unsubscribeAddressTransactions=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/address-transactions/"+e,null,null,r)},_.prototype.unsubscribeTransaction=function(t,e,r){return this.blocktrailClient.delete("/webhook/"+t+"/transaction/"+e,null,null,r)},_.prototype.unsubscribeNewBlocks=function(t,e){return this.blocktrailClient.delete("/webhook/"+t+"/block",null,null,e)},_.prototype.getWalletLatestBlock=function(t){return this.blocktrailClient.get("/block/latest",null,t)},_.prototype.initWallet=function(t,e){var r=this;if("object"!=typeof t&&(t={identifier:arguments[0],passphrase:arguments[1]},e=arguments[2]),t.check_backup_key&&"string"!=typeof t.check_backup_key)throw new Error("Invalid input, must provide the backup key as a string (the xpub)");var s=i.defer();s.promise.spreadNodeify(e);var a=t.identifier;return a?(s.resolve(r.blocktrailClient.get("/wallet/"+a,null,!0).then(function(e){var i=t.keyIndex||e.key_index;if(t.walletVersion=e.wallet_version,t.check_backup_key&&t.check_backup_key!==e.backup_public_key[0])throw new Error("Backup key returned from server didn't match our own copy");var s=o.HDNode.fromBase58(e.backup_public_key[0],r.network),u=n.mapValues(e.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),f=n.mapValues(e.primary_public_keys,function(t){return o.HDNode.fromBase58(t[0],r.network)}),h=new c(r,a,t.walletVersion,e.primary_mnemonic,e.encrypted_primary_seed,e.encrypted_secret,f,s,u,i,e.segwit||0,r.testnet,r.regtest,e.checksum,e.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.recoverySecret=e.recovery_secret,t.readOnly?h:h.unlock(t).then(function(){return h})})),s.promise):(s.reject(new b.WalletInitError("Identifier is required")),s.promise)},_.CREATE_WALLET_PROGRESS_START=0,_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET=4,_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY=5,_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY=6,_.CREATE_WALLET_PROGRESS_PRIMARY=10,_.CREATE_WALLET_PROGRESS_BACKUP=20,_.CREATE_WALLET_PROGRESS_SUBMIT=30,_.CREATE_WALLET_PROGRESS_INIT=40,_.CREATE_WALLET_PROGRESS_DONE=100,_.prototype.createNewWallet=function(t,e){var r=this;if("object"!=typeof t){var n=arguments[0],o=arguments[1],s=arguments[2];e=arguments[3],"function"==typeof s&&(e=s,s=null),t={identifier:n,passphrase:o,keyIndex:s}}t.walletVersion=t.walletVersion||c.WALLET_VERSION_V3;var a=i.defer();return a.promise.spreadNodeify(e),i.nextTick(function(){if(a.notify(_.CREATE_WALLET_PROGRESS_START),t.keyIndex=t.keyIndex||0,t.passphrase=t.passphrase||t.password,delete t.password,!t.identifier)return a.reject(new b.WalletCreateError("Identifier is required")),a.promise;t.walletVersion===c.WALLET_VERSION_V1?r._createNewWalletV1(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V2?r._createNewWalletV2(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):t.walletVersion===c.WALLET_VERSION_V3?r._createNewWalletV3(t).progress(function(t){a.notify(t)}).then(function(t){a.resolve(t)},function(t){a.reject(t)}):a.reject(new b.WalletCreateError("Invalid wallet version!"))}),a.promise},_.prototype._createNewWalletV1=function(t){var e=this,r=i.defer();return i.nextTick(function(){if(!t.primaryMnemonic&&!t.primarySeed){if(!t.passphrase&&!t.password)return r.reject(new b.WalletCreateError("Can't generate Primary Mnemonic without a passphrase")),r.promise;t.primaryMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS),!1!==t.storePrimaryMnemonic&&(t.storePrimaryMnemonic=!0)}t.backupMnemonic||t.backupPublicKey||(t.backupMnemonic=a.generateMnemonic(c.WALLET_ENTROPY_BITS)),r.notify(_.CREATE_WALLET_PROGRESS_PRIMARY),e.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return r.notify(_.CREATE_WALLET_PROGRESS_BACKUP),e.resolveBackupPublicKeyFromOptions(t).then(function(t){r.notify(_.CREATE_WALLET_PROGRESS_SUBMIT);var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),a=t.keyIndex,u=t.primaryPrivateKey.deriveHardened(a).neutered();return e.storeNewWalletV1(t.identifier,[u.toBase58(),"M/"+a+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storePrimaryMnemonic&&t.primaryMnemonic,s,a,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V1,t.primaryMnemonic,null,null,{keyIndex:u},t.backupPublicKey,f,a,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V1,passphrase:t.passphrase,primarySeed:t.primarySeed,primaryMnemonic:null}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,primaryMnemonic:t.primaryMnemonic,backupMnemonic:t.backupMnemonic,blocktrailPublicKeys:f}]})})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)})}),r.promise},_.prototype._createNewWalletV2=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return function(t,e){return i.when(t).then(function(t){if(t.storeDataOnServer){if(!t.secret){if(!t.passphrase)throw new b.WalletCreateError("Can't encrypt data without a passphrase");e(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),t.secret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),t.encryptedSecret=m.AES.encrypt(t.secret,t.passphrase).toString(m.format.OpenSSL)}e(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),t.encryptedPrimarySeed=m.AES.encrypt(t.primarySeed.toString("base64"),t.secret).toString(m.format.OpenSSL),t.recoverySecret=y(c.WALLET_ENTROPY_BITS/8).toString("hex"),e(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),t.recoveryEncryptedSecret=m.AES.encrypt(t.secret,t.recoverySecret).toString(m.format.OpenSSL)}return t})}(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV2(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V2,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V2,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?a.entropyToMnemonic(b.convert(t.encryptedPrimarySeed,"base64","hex")):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed.toString("hex")):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?a.entropyToMnemonic(b.convert(t.recoveryEncryptedSecret,"base64","hex")):null,encryptedSecret:t.encryptedSecret?a.entropyToMnemonic(b.convert(t.encryptedSecret,"base64","hex")):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype._createNewWalletV3=function(t){var e=this,r=i.defer();return t=n.merge({},t),E(t).then(function(t){if(t.passphrase=t.passphrase||t.password,delete t.password,t.primaryPrivateKey)throw new b.WalletInitError("Can't specify; Primary PrivateKey");return t.primarySeed=t.primarySeed||y(c.WALLET_ENTROPY_BITS/8),t}).then(function(t){return e.produceEncryptedDataV3(t,r.notify.bind(r))}).then(function(t){return S(t,e.network,r.notify.bind(r))}).then(function(t){var i=o.crypto.hash160(t.primaryPrivateKey.getPublicKeyBuffer()),s=o.address.toBase58Check(i,e.network.pubKeyHash),u=t.keyIndex;return e.storeNewWalletV3(t.identifier,[t.primaryPublicKey.toBase58(),"M/"+u+"'"],[t.backupPublicKey.toBase58(),"M"],!!t.storeDataOnServer&&t.encryptedPrimarySeed,!!t.storeDataOnServer&&t.encryptedSecret,!!t.storeDataOnServer&&t.recoverySecret,s,u,t.support_secret||null,t.segwit||null).then(function(i){r.notify(_.CREATE_WALLET_PROGRESS_INIT);var f=n.mapValues(i.blocktrail_public_keys,function(t){return o.HDNode.fromBase58(t[0],e.network)}),h=new c(e,t.identifier,c.WALLET_VERSION_V3,null,t.storeDataOnServer?t.encryptedPrimarySeed:null,t.storeDataOnServer?t.encryptedSecret:null,{keyIndex:t.primaryPublicKey},t.backupPublicKey,f,u,i.segwit||0,e.testnet,e.regtest,s,i.upgrade_key_index,t.useCashAddress,t.bypassNewAddressCheck);return h.unlock({walletVersion:c.WALLET_VERSION_V3,passphrase:t.passphrase,primarySeed:t.primarySeed,secret:t.secret}).then(function(){return r.notify(_.CREATE_WALLET_PROGRESS_DONE),[h,{walletVersion:h.walletVersion,encryptedPrimarySeed:t.encryptedPrimarySeed?p.encode(t.encryptedPrimarySeed):null,backupSeed:t.backupSeed?a.entropyToMnemonic(t.backupSeed):null,recoveryEncryptedSecret:t.recoveryEncryptedSecret?p.encode(t.recoveryEncryptedSecret):null,encryptedSecret:t.encryptedSecret?p.encode(t.encryptedSecret):null,blocktrailPublicKeys:f}]})})}).then(function(t){r.resolve(t)},function(t){r.reject(t)}),r.promise},_.prototype.storeNewWalletV1=function(t,e,r,n,i,o,s){var a={identifier:t,wallet_version:c.WALLET_VERSION_V1,primary_public_key:e,backup_public_key:r,primary_mnemonic:n,checksum:i,key_index:o,segwit:s};return A(a,this.network),this.blocktrailClient.post("/wallet",null,a)},_.prototype.storeNewWalletV2=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V2,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n,encrypted_secret:i,recovery_secret:o,checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.storeNewWalletV3=function(t,e,r,n,i,o,s,a,u,f){var h={identifier:t,wallet_version:c.WALLET_VERSION_V3,primary_public_key:e,backup_public_key:r,encrypted_primary_seed:n.toString("base64"),encrypted_secret:i.toString("base64"),recovery_secret:o.toString("hex"),checksum:s,key_index:a,support_secret:u||null,segwit:f};return A(h,this.network),this.blocktrailClient.post("/wallet",null,h)},_.prototype.updateWallet=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t,null,e,r)},_.prototype.upgradeKeyIndex=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/upgrade",null,{key_index:e,primary_public_key:r},n)},_.prototype.getWalletBalance=function(t,e){return this.blocktrailClient.get("/wallet/"+t+"/balance",null,!0,e)},_.prototype.doWalletDiscovery=function(t,e,r){return this.blocktrailClient.get("/wallet/"+t+"/discovery",{gap:e},!0,r)},_.prototype.getNewDerivation=function(t,e,r){return this.blocktrailClient.post("/wallet/"+t+"/path",null,{path:e},r)},_.prototype.deleteWallet=function(t,e,r,n,i){return"function"==typeof n&&(i=n,n=!1),this.blocktrailClient.delete("/wallet/"+t,{force:n},{checksum:e,signature:r},i)},_.prototype.coinSelection=function(t,e,r,n,o,s,a){"function"==typeof o?(a=o,o=null,s={}):"function"==typeof s&&(a=s,s={}),o=o||c.FEE_STRATEGY_OPTIMAL,s=s||{};var u=i.defer();u.promise.spreadNodeify(a);var f={lock:r,zeroconf:n?1:0,zeroconfself:void 0===s.allowZeroConfSelf||s.allowZeroConfSelf?1:0,fee_strategy:o};return s.forcefee&&(f.forcefee=s.forcefee),u.resolve(this.blocktrailClient.post("/wallet/"+t+"/coin-selection",f,e).then(function(t){return[t.utxos,t.fee,t.change,t]},function(t){if(t.message.match(/too low to pay the fee/))throw b.WalletFeeError(t);throw t})),u.promise},_.prototype.feePerKB=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.blocktrailClient.get("/fee-per-kb")),e.promise},_.prototype.sendTransaction=function(t,e,r,n,i,o,s,a){"function"==typeof i?(a=i,i=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var c={paths:r,two_factor_token:i};"string"==typeof e?c.raw_transaction=e:"object"==typeof e&&Object.keys(e).map(function(t){c[t]=e[t]});var u={check_fee:n?1:0,prioboost:o?1:0};return s.bip70PaymentUrl&&(u.bip70PaymentUrl=s.bip70PaymentUrl,s.bip70MerchantData&&s.bip70MerchantData instanceof Uint8Array&&(u.bip70MerchantData=Buffer.from(Array.prototype.map.call(s.bip70MerchantData,function(t){return String.fromCharCode(t)}).join("")).toString("base64"))),this.blocktrailClient.post("/wallet/"+t+"/send",u,c,a)},_.prototype.setupWalletWebhook=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/webhook",null,{url:r,identifier:e},n)},_.prototype.deleteWalletWebhook=function(t,e,r){return this.blocktrailClient.delete("/wallet/"+t+"/webhook/"+e,null,null,r)},_.prototype.walletTransactions=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/transactions",e,!0,r)},_.prototype.walletAddresses=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/addresses",e,!0,r)},_.prototype.labelWalletAddress=function(t,e,r,n){return this.blocktrailClient.post("/wallet/"+t+"/address/"+e+"/label",null,{label:r},n)},_.prototype.walletMaxSpendable=function(t,e,r,n,i){"function"==typeof r?(i=r,r=null):"function"==typeof n&&(i=n,n={}),r=r||c.FEE_STRATEGY_OPTIMAL;var o={outputs:(n=n||{}).outputs?n.outputs:1,zeroconf:e?1:0,zeroconfself:void 0===n.allowZeroConfSelf||n.allowZeroConfSelf?1:0,fee_strategy:r};return n.forcefee&&(o.forcefee=n.forcefee),this.blocktrailClient.get("/wallet/"+t+"/max-spendable",o,!0,i)},_.prototype.walletUTXOs=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.blocktrailClient.get("/wallet/"+t+"/utxos",e,!0,r)},_.prototype.allWallets=function(t,e){return"function"==typeof t&&(e=t,t=null),this.blocktrailClient.get("/wallets",t,!0,e)},_.prototype.verifyMessage=function(t,e,r,n){var o=i.defer();o.promise.nodeify(n);try{var a=s.verify(e,this.network.messagePrefix,t,new Buffer(r,"base64"));o.resolve(a)}catch(t){o.reject(t)}return o.promise},_.prototype.faucetWithdrawl=function(t,e,r){return this.blocktrailClient.post("/faucet/withdrawl",null,{address:t,amount:e},r)},_.prototype.sendRawTransaction=function(t,e){return this.blocktrailClient.post("/send-raw-tx",null,t,e)},_.prototype.price=function(t){return this.blocktrailClient.get("/price",null,!1,t)},e.exports=_}).call(this)}).call(this,t("_process"),t("buffer").Buffer)},{"./blocktrail":3,"./blocktrail.convert":2,"./btccom.convert":4,"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,"./rest_client":11,"./use-webworker":17,"./wallet":18,"./webworker":20,"./webworkifier":21,_process:270,bip39:34,"bitcoinjs-lib":49,"bitcoinjs-message":78,buffer:110,"crypto-js":159,lodash:261,q:299,randombytes:303}],2:[function(t,e,r){var n=function(){};n.prototype.paginationParams=function(t){return t},n.prototype.getUrlForBlock=function(t){return"/block/"+t},n.prototype.getUrlForTransaction=function(t){return"/transaction/"+t},n.prototype.getUrlForBlockTransaction=function(t){return"/block/"+t+"/transactions"},n.prototype.getUrlForAddress=function(t){return"/address/"+t},n.prototype.getUrlForAddressTransactions=function(t){return"/address/"+t+"/transactions"},n.prototype.getUrlForAddressUnspent=function(t){return"/address/"+t+"/unspent-outputs"},n.prototype.convertBlock=function(t){return t},n.prototype.convertBlockTxs=function(t){return t},n.prototype.convertTx=function(t){return t},n.prototype.convertAddressTxs=function(t){return t},n.prototype.convertAddress=function(t){return t},n.prototype.convertAddressUnspentOutputs=function(t){return t},n.prototype.convertBatchAddressUnspentOutputs=function(t){return t},n.prototype.getUrlForAllBlocks=function(){return"/all-blocks"},n.prototype.handleErrors=function(t,e){return e},e.exports=n},{}],3:[function(t,e,r){(function(Buffer){(function(){var r=t("util"),n=t("assert"),i=t("crypto-js"),o=t("bip39"),s={COIN:1e8,PRECISION:8,DUST:2730,BASE_FEE:1e4,LOCK_TIME_TIMESTAMP_THRESHOLD:5e6},a=function(t,e,r){return new Buffer(t,e).toString(r)},c=function(t,e){return function(t,e){var r=o.mnemonicToEntropy(t),n=a(r,"hex","base64"),c=i.AES.decrypt(n,e).toString(i.enc.Utf8);if(!c.length)throw new s.WalletDecryptError;return c}(t,e).toString(i.enc.Utf8)},u=function(t,e){return a(c(t,e),"base64","hex")},f=function(t,e){var r=i.AES.encrypt(t,e).toString(i.format.OpenSSL),n=a(r,"base64","hex");return o.entropyToMnemonic(n)};s.convert=a,s.aesDecryptMnemonicToSeed=c,s.aesDecryptMnemonicToSeedBuffer=function(t,e){return new Buffer(u(t,e),"hex")},s.aesDecryptMnemonicToSeedHex=u,s.aesEncryptSeedToMnemonic=f,s.aesEncryptSeedHexToMnemonic=function(t,e){return f(a(t,"hex","base64"),e)},s.aesEncryptSeedBufferToMnemonic=function(t,e){return f(t.toString("base64"),e)},s.V3Crypt={KeyDerivation:t("./keyderivation"),Encryption:t("./encryption"),EncryptionMnemonic:t("./encryption_mnemonic")},s.toSatoshi=function(t){return parseInt((t*s.COIN).toFixed(0),10)},s.toBTC=function(t){return(t/s.COIN).toFixed(s.PRECISION)},s.patchQ=function(t){t.spreadNodeify&&t.spreadDone||(t.spreadDone=function(e,r,n){return t(e).spreadDone(r,n)},t.makePromise.prototype.spreadDone=function(t,e){return this.all().done(function(e){return t.apply(void 0,e)},e)},t.spreadNodeify=function(e,r){return t(e).spreadNodeify(r)},t.makePromise.prototype.spreadNodeify=function(e){if(!e)return this;this.then(function(r){t.nextTick(function(){e.apply(void 0,[null].concat(r))})},function(r){t.nextTick(function(){e(r)})})})},Error.extend=function(t,e){n(t,"subTypeName is required");var i=function(r){if(!(this instanceof i))return new i(r);this.name=t,this.code=e,this.message=r&&(r.message||r)||"",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return r.inherits(i,this),i.prototype.toString=function(){return this.name+": "+r.inspect(this.message)},i.extend=this.extend,i},"function"!=typeof Uint8Array.prototype.reverse&&(Buffer.prototype.reverse=function(){for(var t,e=0,r=this.length-1;e<=r;++e,--r)t=this[e],this[e]=this[r],this[r]=t;return this}),s.WalletInitError=Error.extend("WalletInitError",400),s.WalletCreateError=Error.extend("WalletCreateError",400),s.WalletUpgradeError=Error.extend("WalletUpgradeError",400),s.WalletChecksumError=Error.extend("WalletChecksumError",400),s.WalletDeleteError=Error.extend("WalletDeleteError",400),s.WalletDecryptError=Error.extend("WalletDecryptError",400),s.WalletAddressError=Error.extend("WalletAddressError",500),s.WalletSendError=Error.extend("WalletSendError",400),s.WalletLockedError=Error.extend("WalletLockedError",500),s.WalletFeeError=Error.extend("WalletFeeError",500),s.WalletInvalid2FAError=Error.extend("WalletInvalid2FAError",401),s.WalletMissing2FAError=Error.extend("WalletMissing2FAError",401),s.WalletMissingEmail2FAError=Error.extend("WalletMissingEmail2FAError",401),s.TransactionSignError=Error.extend("TransactionSignError",500),s.TransactionInputError=Error.extend("TransactionInputError",400),s.TransactionOutputError=Error.extend("TransactionOutputError",400),s.KeyPathError=Error.extend("KeyPathError",400),s.InvalidAddressError=Error.extend("InvalidAddressError",400),s.Error=Error.extend("Error",500),s.FEE_STRATEGY_FORCE_FEE="force_fee",s.FEE_STRATEGY_BASE_FEE="base_fee",s.FEE_STRATEGY_HIGH_PRIORITY="high_priority",s.FEE_STRATEGY_OPTIMAL="optimal",s.FEE_STRATEGY_LOW_PRIORITY="low_priority",s.FEE_STRATEGY_MIN_RELAY_FEE="min_relay_fee",s.patchQ(t("q")),e.exports=s}).call(this)}).call(this,t("buffer").Buffer)},{"./encryption":5,"./encryption_mnemonic":6,"./keyderivation":7,assert:23,bip39:34,buffer:110,"crypto-js":159,q:299,util:242}],4:[function(t,e,r){var n=t("./wallet"),i=t("./blocktrail"),o=t("bitcoinjs-lib"),s=function(t,e){this.network=t,this.useNewCashAddr=e};function a(t,e,r){var n;try{n=o.address.toOutputScript(t,e,r)}catch(t){n=null}return n}function c(t){var e;try{e=o.script.toASM(t)}catch(t){e=null}return e}function u(asm){return asm?asm.replace(/^0 /,"OP_0 "):asm}function f(t){var e;try{e=o.script.classifyOutput(t)}catch(t){e=null}return e}function h(t){switch(t){case"P2PKH_PUBKEY":return"pubkey";case"P2PKH":return"pubkeyhash";case"P2SH":return"scripthash";case"P2WSH_V0":return"witnessscripthash";case"P2WPKH_V0":return"witnesspubkeyhash";case"NULL_DATA":return"op_return";case"coinbase":return"coinbase";default:throw new Error("Not implemented yet, script type: "+t)}}function l(t){return new Date(1e3*t).toISOString().replace(/\.000Z$/,"+0000")}function d(t){return t&&1===t.length?t[0]:t}function p(t){var e,r={};for(var n in r.size=t.vsize,r.hash=t.hash,r.block_height=t.block_height,r.time=r.block_time=l(t.block_time),r.block_hash=t.block_hash,r.confirmations=t.confirmations,r.is_coinbase=t.is_coinbase,e=r.is_coinbase?t.outputs[0].value-t.fee:t.inputs_value,r.total_input_value=e,r.total_output_value=t.outputs.reduce(function(t,e){return t+e.value},0),r.total_fee=t.fee,r.inputs=[],r.outputs=[],r.opt_in_rbf=!1,t.inputs){var s,a,c,f,p=t.inputs[n];p.sequence=1<<28)throw new RangeError("repeat count must not overflow maximum string size");for(var r="";1==(1&t)&&(r+=e),0!==(t>>>=1);)e+=e;return r});var i={chunkSize:4,paddingDummy:129},o=function(t){if(t[0]>128)throw new Error("Mnemonic sanity check - first byte can never be above 0x80");return i.paddingDummy.toString(16).repeat(i.chunkSize-t.length%i.chunkSize)};i.encode=function(t){r(t instanceof Buffer,"Data must be provided as a Buffer");var e=o(t),i=n.entropyToMnemonic(e+t.toString("hex"));try{n.mnemonicToEntropy(i)}catch(t){throw new Error("BIP39 library produced an invalid mnemonic")}return i},i.decode=function(t){r("string"==typeof t,"Mnemonic must be provided as a string");for(var e=new Buffer(n.mnemonicToEntropy(t),"hex"),i=0;e[i]===this.paddingDummy;)i++;var s=e.slice(i,e.length);if(o(s)!==e.slice(0,i).toString("hex"))throw new Error("There is only one way to pad a string");return s},e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,bip39:34,buffer:110}],7:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("./pbkdf2_sha512"),i={defaultIterations:35e3,subkeyIterations:1,keySizeBits:256,compute:function(t,e,i){if(i=i||this.defaultIterations,r(t instanceof Buffer,"Password must be provided as a Buffer"),r(e instanceof Buffer,"Salt must be provided as a Buffer"),r(e.length>0,"Salt must not be empty"),r("number"==typeof i,"Iterations must be a number"),r(i>0,"Iteration count should be at least 1"),e.length>128)throw new Error("Sanity check: Invalid salt, length can never be greater than 128");return n.digest(t,e,i,this.keySizeBits/8)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{"./pbkdf2_sha512":8,assert:23,buffer:110}],8:[function(t,e,r){(function(Buffer){(function(){e.exports={digest:function(t,e,r,n){var i="undefined"!=typeof window?window.asmCrypto:self.asmCrypto;return new Buffer(new i.PBKDF2_HMAC_SHA512.bytes(t,e,r,n).buffer)}}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:110}],9:[function(t,e,r){e.exports={VERSION:"3.7.22"}},{}],10:[function(t,e,r){(function(r){(function(){var n=t("./blocktrail"),i=t("lodash"),o=t("url"),s=t("querystring"),a=t("q"),c=t("create-hash"),u=t("superagent"),f=t("superagent-http-signature/index-hmac-only"),h=t("debug")("blocktrail-sdk:request"),l=!r.browser,d=function(){};function p(t){this.https=t.https,this.host=t.host,this.endpoint=t.endpoint,this.auth=t.auth,this.port=t.port,this.apiKey=t.apiKey,this.apiSecret=t.apiSecret,this.contentMd5=void 0===t.contentMd5||t.contentMd5,this.params=i.defaults({},t.params),this.headers=i.defaults({},t.headers)}p.qs=function(t){var e=[],r=Object.keys(t);return r.sort(),r.forEach(function(r){var n={};n[r]=t[r],e.push(s.stringify(n))}),e.join("&")},p.prototype.request=function(t,e,r,n,s){this.deferred=a.defer(),this.callback=s||d;var u=o.parse(e,!0),f=p.qs(i.defaults({},r||{},u.query||{},this.params||{}));this.path="".concat(this.endpoint,u.pathname),f&&(this.path=this.path.concat("?",f)),n?(this.payload=JSON.stringify(n),this.headers["Content-Type"]="application/json"):this.payload="",l&&(this.headers["Content-Length"]=this.payload?this.payload.length:0),!0===this.contentMd5&&(this.headers["Content-MD5"]="GET"===t||"DELETE"===t?c("md5").update(this.path).digest().toString("hex"):c("md5").update(this.payload).digest().toString("hex")),h("%s %s %s",t,this.host,this.path);var b={hostname:this.host,path:this.path,port:this.port,method:t,headers:this.headers,auth:this.auth,agent:!1,withCredentials:!1};return this.performRequest(b),this.deferred.promise},p.prototype.performRequest=function(t){var e=this,r=t.method,n=!1;"http-signature"===t.auth&&(n=!0,delete t.auth);var o=(e.https?"https://":"http://")+t.hostname+t.path,s=u(r,o);if(!e.payload||"DELETE"!==r&&"POST"!==r&&"PUT"!==r&&"PATCH"!==r||s.send(e.payload),i.forEach(t.headers,function(t,e){s.set(e,t)}),n){if(!e.apiSecret){var a=new Error("Missing apiSecret! required to sign POST requests!");return e.deferred.reject(a),e.callback(a)}s.use(f({headers:["(request-target)","content-md5"],algorithm:"hmac-sha256",key:e.apiSecret,keyId:e.apiKey}))}return s.end(function(t,r){var n;if(t){var i=p.handleFailure(t.response&&t.response.body,t.status);return e.deferred.reject(i),e.callback(i,t.response&&t.response.body)}if(h("response status code: %s content type: %s",r.status,r.headers["content-type"]),!t&&r.headers["content-type"].indexOf("application/json")>=0)try{n=JSON.parse(r.text)}catch(e){t=e}return n||(n=r.text),t||200===r.status||(t=p.handleFailure(r.text,r.statusCode)),t?e.deferred.reject(t):e.deferred.resolve(n),e.callback(t,n)}),e.deferred},p.handleFailure=function(t,e){var r,n;if("object"==typeof t)r=t;else try{r=JSON.parse(t)}catch(t){}if(r){var i=r.msg||"";i||429===e&&(i="Too Many Request"),n=new Error(i),Object.keys(r).forEach(function(t){"msg"!==t&&(n[t]=r[t])})}else n=t?new Error(t):new Error("Unknown Server Error");return e&&(n.statusCode=e),p.convertError(n)},p.convertError=function(t){return t.requires_2fa&&!t.requires_email_2fa?new n.WalletMissing2FAError:t.requires_email_2fa?new n.WalletMissingEmail2FAError:t.message.match(/Invalid two_factor_token/)?new n.WalletInvalid2FAError:t},e.exports=p}).call(this)}).call(this,t("_process"))},{"./blocktrail":3,_process:270,"create-hash":118,debug:185,lodash:261,q:299,querystring:302,superagent:343,"superagent-http-signature/index-hmac-only":339,url:354}],11:[function(t,e,r){var n=t("lodash"),i=t("./request"),o=t("q"),s=function(e){this.apiKey=e.apiKey,this.apiSecret=e.apiSecret,this.https=e.https,this.host=e.host,this.port=e.port,this.endpoint=e.endpoint,this.btccom=!!e.btccom,void 0!==e.throttleRequestsTimeout?this.throttleRequestsTimeout=e.throttleRequestsTimeout:this.btccom?this.throttleRequestsTimeout=350:this.throttleRequestsTimeout=0,this.throttleRequests=this.throttleRequestsTimeout>0,this.nextRequest=null,this.defaultParams={},this.btccom||(this.apiKey&&(this.defaultParams.api_key=this.apiKey),this.defaultHeaders=n.defaults({},{"X-SDK-Version":"blocktrail-sdk-nodejs/"+t("./pkginfo").VERSION},e.defaultHeaders))};s.prototype.throttle=function(){var t=this,e=o.defer();return this.throttleRequests?this.nextRequest?this.nextRequest=this.nextRequest.then(function(){return e.resolve(),o.delay(t.throttleRequestsTimeout)}):(this.nextRequest=o.delay(t.throttleRequestsTimeout),e.resolve()):e.resolve(),e.promise},s.prototype.create_request=function(t){return t=n.defaults({},t,{https:this.https,host:this.host,port:this.port,endpoint:this.endpoint,apiKey:this.apiKey,apiSecret:this.apiSecret,contentMd5:!this.btccom,params:n.defaults({},this.defaultParams),headers:n.defaults({},this.defaultHeaders)}),new i(t)},s.prototype.post=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("POST",t,e,r,n)})},s.prototype.put=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("PUT",t,e,r,n)})},s.prototype.get=function(t,e,r,n){var i=this;"function"==typeof r&&(n=r,r=!1);var o={};if(r&&(o.auth="http-signature"),i.btccom&&void 0!==n)throw new Error("we should be using callbackify!");return i.throttle().then(function(){return i.create_request(o).request("GET",t,e,null,n)})},s.prototype.delete=function(t,e,r,n,i){var o=this,s={};return(i=void 0===i||i)&&(s.auth="http-signature"),o.throttle().then(function(){return o.create_request(s).request("DELETE",t,e,r,n)})},e.exports=function(t){return new s(t)}},{"./pkginfo":9,"./request":10,lodash:261,q:299}],12:[function(t,e,r){var n=t("../api_client"),i=t("lodash"),o=t("q"),s=t("async"),a=function(t){this.defaultSettings={apiKey:null,apiSecret:null,network:"BTC",testnet:!1,retryLimit:5,retryDelay:20,paginationLimit:200},this.settings=i.merge({},this.defaultSettings,t);var e=this.normaliseNetwork(this.settings.network,this.settings.testnet);this.settings.network=e.network,this.settings.testnet=e.testnet,this.client=new n(this.settings)};a.prototype.normaliseNetwork=function(t,e){switch(t.toLowerCase()){case"btc":case"bitcoin":return e?{network:"BTC",testnet:!0}:{network:"BTC",testnet:!1};case"tbtc":case"bitcoin-testnet":return{network:"BTC",testnet:!0};case"bcc":return e?{network:"BCC",testnet:!0}:{network:"BCC",testnet:!1};case"tbcc":return{network:"BCC",testnet:!0};default:throw new Error("Unknown network "+t)}},a.prototype.setPaginationLimit=function(t){this.settings.paginationLimit=t},a.prototype.estimateFee=function(){return this.client.feePerKB().then(function(t){return Math.max(t.optimal,t.min_relay_fee)})},a.prototype.getBatchUnspentOutputs=function(t){var e=this,r=o.defer(),n=1,i=[];return s.doWhilst(function(r){var o={page:n,limit:e.settings.paginationLimit};e.client.batchAddressUnspentOutputs(t,o).then(function(t){i=i.concat(t.data),n++,r()},function(t){console.log("error happened:",t),r(t)})},function(){return null},function(t){t&&console.log("complete, but with errors",t.message);var e={};i.forEach(function(t){var r=t.address;void 0===e[r]&&(e[r]=[]),e[r].push({hash:t.hash,index:t.index,value:t.value,script_hex:t.script_hex})}),r.resolve(e)}),r.promise},a.prototype.batchAddressHasTransactions=function(t){return this.client.batchAddressHasTransactions(t).then(function(t){return t.has_transactions})},e.exports=a},{"../api_client":1,async:27,lodash:261,q:299}],13:[function(t,e,r){var n=t("../blocktrail"),i=t("superagent"),o=t("lodash"),s=t("q"),a=function(t){this.defaultSettings={host:"https://insight.bitpay.com/api",testnet:!1,retryLimit:5,retryDelay:20},void 0===t.host&&t.testnet&&(this.defaultSettings.host="https://test-insight.bitpay.com/api"),this.settings=o.merge({},this.defaultSettings,t),this.DEFAULT_ENDPOINT_MAINNET="https://insight.bitpay.com/api",this.DEFAULT_ENDPOINT_TESTNET="https://test-insight.bitpay.com/api"};a.prototype.getBatchUnspentOutputs=function(t){var e=s.defer(),r={addrs:t.join(",")};return this.postEndpoint("addrs/utxo",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.txid,index:t.vout,value:n.toSatoshi(t.amount),script_hex:t.scriptPubKey,confirmations:t.confirmations})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={addrs:t.join(",")};return this.postEndpoint("addrs/txs",e).then(function(t){return t.items.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("utils/estimatefee?nbBlocks=4").then(function(t){return-1===t[4]?1e5:t[4]<1e-5?1e3:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("tx/send",{rawtx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=s.defer();return i.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=s.defer();return i.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,lodash:261,q:299,superagent:343}],14:[function(t,e,r){t("../blocktrail");var n=t("superagent"),i=t("lodash"),o=t("q"),s=t("bitcoinjs-lib"),a=function(t){if(!("host"in t))throw new Error("provide a fully qualified URL for the server host in options!");this.defaultSettings={retryLimit:5,retryDelay:20},this.settings=i.merge({},this.defaultSettings,t)};a.prototype.getBatchUnspentOutputs=function(t){var e=o.defer(),r={address:t};return this.postEndpoint("addressListUnspent",r).then(function(t){var r={};t.forEach(function(t){var e=t.address;void 0===r[e]&&(r[e]=[]),r[e].push({hash:t.tx_hash,index:t.tx_pos,value:t.value,script_hex:s.address.toOutputScript(e,s.networks.bitcoincash),confirmations:1})}),e.resolve(r)},function(t){e.reject(t)}),e.promise},a.prototype.batchAddressHasTransactions=function(t){var e={address:t};return this.postEndpoint("addressHasTransactions",e).then(function(t){return t.length>0})},a.prototype.estimateFee=function(){return this.getEndpoint("estimateFeeRate?confirmations=4").then(function(t){return-1===t[4]?1e5:parseInt(1e8*t[4],10)})},a.prototype.sendTx=function(t){return this.postEndpoint("publishTx",{tx:t})},a.prototype.getEndpoint=function(t){return this.getRequest(this.settings.host+"/"+t)},a.prototype.postEndpoint=function(t,e){return this.postRequest(this.settings.host+"/"+t,e)},a.prototype.getRequest=function(t){var e=o.defer();return n.get(t).end(function(t,r){if(t)e.reject(t);else{if(!r.ok)return e.reject(r.text);if(!(r.headers["content-type"].indexOf("application/json")>=0))return e.resolve(r.body);try{var n=JSON.parse(r.text);return e.resolve(n)}catch(r){return e.reject(t)}}}),e.promise},a.prototype.postRequest=function(t,e){var r=o.defer();return n.post(t).send(e).set("Content-Type","application/json").end(function(t,e){if(t)r.reject(t);else{if(!e.ok)return r.reject(e.text);try{var n=JSON.parse(e.text);return r.resolve(n)}catch(n){return e.headers["content-type"].indexOf("application/json")>=0?r.reject(t):r.resolve(e.body)}}}),r.promise},e.exports=a},{"../blocktrail":3,"bitcoinjs-lib":49,lodash:261,q:299,superagent:343}],15:[function(t,e,r){(function(Buffer){(function(){var r=t("assert"),n=t("bitcoinjs-lib"),i={SIZE_DER_SIGNATURE:72,SIZE_V0_P2WSH:36,getPublicKeySize:function(t){return t?33:65},getLengthForScriptPush:function(t){if(t<75)return 1;if(t<=255)return 2;if(t<=65535)return 3;if(t<=4294967295)return 5;throw new Error("Size of pushdata too large")},getLengthForVarInt:function(t){if(t<253)return 1;var e;if(t<65535)e=2;else if(t<4294967295)e=4;else{if(!(t<0x10000000000000000))throw new Error("Size of varint too large");e=8}return 1+e},estimateMultisigStackSize:function(t,e){var r,n=[0];for(r=0;r0&&(s.map(function(t){u+=a.getLengthForVarInt(t)+t}),u+=a.getLengthForVarInt(s.length)),[c,u]},estimateInputFromScripts:function(t,e,i,o,s){var a;if(r(null===i||o),n.script.multisig.output.check(t)){var c=n.script.multisig.output.decode(t);a=this.estimateMultisigStackSize(c.m,c.pubKeys)[0]}else if(n.script.pubKey.output.check(t)){var u=n.script.pubKey.output.decode(t);a=this.estimateP2PKStackSize(u)[0]}else{if(!n.script.pubKeyHash.output.check(t))throw new Error("Unsupported script type");a=this.estimateP2PKHStackSize(s)[0]}return this.estimateStackSignatureSize(a,o,e,i)},estimateUtxo:function(t,e){var r=Buffer.from(t.scriptpubkey_hex,"hex"),i=null,o=null;t.redeem_script&&("string"==typeof t.redeem_script?i=Buffer.from(t.redeem_script,"hex"):t.redeem_script instanceof Buffer&&(i=t.redeem_script)),t.witness_script&&("string"==typeof t.witness_script?o=Buffer.from(t.witness_script,"hex"):t.witness_script instanceof Buffer&&(o=t.witness_script));var s=!1,a=r;if(n.script.scriptHash.output.check(a)){if(null===i)throw new Error("Cant estimate, missing redeem script");a=i}if(n.script.witnessPubKeyHash.output.check(a)){var c=n.script.witnessPubKeyHash.output.decode(a);a=n.script.pubKeyHash.output.encode(c),s=!0}else if(n.script.witnessScriptHash.output.check(a)){if(null===o)throw new Error("Can't estimate, missing witness script");a=o,s=!0}var u=n.script.types,f=[u.MULTISIG,u.P2PKH,u.P2PK],h=n.script.classifyOutput(a);if(-1===f.indexOf(h))throw new Error("Unsupported script type");var l=this.estimateInputFromScripts(a,i,o,s,e);return{scriptSig:l[0],witness:l[1]}},estimateInputsSize:function(t,e){var r=0,n=0;return t.map(function(t){var o=i.estimateUtxo(t);r+=40+o.scriptSig,e&&(n+=o.witness)}),e&&n>0&&(r+=2+n),r},calculateOutputsSize:function(t){var e=0;return t.map(function(t){var r=i.getLengthForVarInt(t.script.length);e+=8+r+t.script.length}),e},estimateTxWeight:function(t,e){var r=i.calculateOutputsSize(t.outs);return 3*(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!1)+i.getLengthForVarInt(t.outs.length)+r+4)+(4+i.getLengthForVarInt(e.length)+this.estimateInputsSize(e,!0)+i.getLengthForVarInt(t.outs.length)+r+4)},estimateTxVsize:function(t,e){return parseInt(Math.ceil(i.estimateTxWeight(t,e)/4),10)}};e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{assert:23,"bitcoinjs-lib":49,buffer:110}],16:[function(t,e,r){var n=t("lodash"),i=t("q"),o=t("async"),s=function(t,e){this.defaultSettings={logging:!1,batchChunkSize:200},this.settings=n.merge({},this.defaultSettings,e),this.dataClient=t};s.prototype.getUTXOs=function(t){var e=this,r={},s=i.defer();return o.eachSeries(n.chunk(t,e.settings.batchChunkSize),function(t,i){e.settings.logging&&console.log("checking batch of "+t.length+" addresses for UTXOs",t.join(",")),e.dataClient.getBatchUnspentOutputs(t).done(function(t){n.each(t,function(t,e){t.length>0&&(r[e]=t)}),i()},function(t){i(t)})},function(t){t&&console.log("error encountered",t),s.resolve(r)}),s.promise},e.exports=s},{async:27,lodash:261,q:299}],17:[function(t,e,r){(function(t){(function(){var r=!!t.browser&&"undefined"!=typeof window&&void 0!==window.Worker,n=("undefined"!=typeof navigator&&navigator.userAgent||"").match(/Android (\d)\.(\d)(\.(\d))/);n&&n[1]<=4&&(r=!1),e.exports=function(){return r}}).call(this)}).call(this,t("_process"))},{_process:270}],18:[function(t,e,r){(function(Buffer){(function(){var r=t("lodash"),n=t("assert"),i=t("q"),o=t("async"),s=t("bitcoinjs-lib"),a=t("bitcoinjs-message"),c=t("./blocktrail"),u=t("crypto-js"),f=t("./encryption"),h=t("./encryption_mnemonic"),l=t("./size_estimation"),d=t("bip39"),p="sign",b=function(t,e,i,o,a,c,u,f,h,l,d,p,y,m,v,g,w){this.sdk=t,this.identifier=e,this.walletVersion=i,this.locked=!0,this.bypassNewAddressCheck=!!w,this.bitcoinCash=this.sdk.bitcoinCash,this.segwit=!!d,this.useNewCashAddr=!!g,n(!this.segwit||!this.bitcoinCash),this.testnet=p,this.regtest=y,this.bitcoinCash?this.regtest?this.network=s.networks.bitcoincashregtest:this.testnet?this.network=s.networks.bitcoincashtestnet:this.network=s.networks.bitcoincash:this.regtest?this.network=s.networks.regtest:this.testnet?this.network=s.networks.testnet:this.network=s.networks.bitcoin,n(f instanceof s.HDNode),n(r.every(u,function(t){return t instanceof s.HDNode})),n(r.every(h,function(t){return t instanceof s.HDNode})),this.primaryMnemonic=o,this.encryptedPrimarySeed=a,this.encryptedSecret=c,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.backupPublicKey=f,this.blocktrailPublicKeys=h,this.primaryPublicKeys=u,this.keyIndex=l,this.bitcoinCash?(this.chain=b.CHAIN_BCC_DEFAULT,this.changeChain=b.CHAIN_BCC_DEFAULT):this.segwit?(this.chain=b.CHAIN_BTC_SEGWIT,this.changeChain=b.CHAIN_BTC_SEGWIT):(this.chain=b.CHAIN_BTC_DEFAULT,this.changeChain=b.CHAIN_BTC_DEFAULT),this.checksum=m,this.upgradeToKeyIndex=v,this.secret=null,this.seedHex=null};function y(t,e){var r,n;try{r=s.address.fromBech32(t,e),n=null}catch(t){n=t}if(!n&&r.prefix!==e.bech32)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}function m(t,e){var r,n;t=t.toLowerCase();try{r=s.address.fromCashAddress(t),n=null}catch(t){n=t}if(n)try{r=s.address.fromCashAddress(e.cashAddrPrefix+":"+t),n=null}catch(t){n=t}if(!n&&r.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix");return[n,r]}function v(t,e){var r,n;try{r=s.address.fromBase58Check(t),n=null}catch(t){n=t}if(!n&&r.version!==e.pubKeyHash&&r.version!==e.scriptHash)throw new c.InvalidAddressError("Address invalid on this network");return[n,r]}b.WALLET_VERSION_V1="v1",b.WALLET_VERSION_V2="v2",b.WALLET_VERSION_V3="v3",b.WALLET_ENTROPY_BITS=256,b.OP_RETURN="opreturn",b.DATA=b.OP_RETURN,b.PAY_PROGRESS_START=0,b.PAY_PROGRESS_COIN_SELECTION=10,b.PAY_PROGRESS_CHANGE_ADDRESS=20,b.PAY_PROGRESS_SIGN=30,b.PAY_PROGRESS_SEND=40,b.PAY_PROGRESS_DONE=100,b.CHAIN_BTC_DEFAULT=0,b.CHAIN_BTC_SEGWIT=2,b.CHAIN_BCC_DEFAULT=1,b.FEE_STRATEGY_FORCE_FEE=c.FEE_STRATEGY_FORCE_FEE,b.FEE_STRATEGY_BASE_FEE=c.FEE_STRATEGY_BASE_FEE,b.FEE_STRATEGY_HIGH_PRIORITY=c.FEE_STRATEGY_HIGH_PRIORITY,b.FEE_STRATEGY_OPTIMAL=c.FEE_STRATEGY_OPTIMAL,b.FEE_STRATEGY_LOW_PRIORITY=c.FEE_STRATEGY_LOW_PRIORITY,b.FEE_STRATEGY_MIN_RELAY_FEE=c.FEE_STRATEGY_MIN_RELAY_FEE,b.prototype.isSegwit=function(){return!!this.segwit},b.prototype.unlock=function(t,e){var n=this,o=i.defer();return o.promise.nodeify(e),t=r.merge({},t),i.fcall(function(){switch(n.walletVersion){case b.WALLET_VERSION_V1:return n.unlockV1(t);case b.WALLET_VERSION_V2:return n.unlockV2(t);case b.WALLET_VERSION_V3:return n.unlockV3(t);default:return i.reject(new c.WalletInitError("Invalid wallet version"))}}).then(function(t){n.primaryPrivateKey=t;var e=n.primaryPrivateKey.getAddress();if(e!==n.checksum)throw new c.WalletChecksumError("Generated checksum ["+e+"] does not match ["+n.checksum+"], most likely due to incorrect password");if(n.locked=!1,void 0!==n.upgradeToKeyIndex&&null!==n.upgradeToKeyIndex)return n.upgradeKeyIndex(n.upgradeToKeyIndex)}).then(function(t){o.resolve(t)},function(t){o.reject(t)}),o.promise},b.prototype.unlockV1=function(t){var e=this;return t.primaryMnemonic=void 0!==t.primaryMnemonic?t.primaryMnemonic:e.primaryMnemonic,t.secretMnemonic=void 0!==t.secretMnemonic?t.secretMnemonic:e.secretMnemonic,e.sdk.resolvePrimaryPrivateKeyFromOptions(t).then(function(t){return e.primarySeed=t.primarySeed,t.primaryPrivateKey})},b.prototype.unlockV2=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletDecryptError("specifying primaryPrivateKey has been deprecated");if(t.primarySeed)r.primarySeed=t.primarySeed;else if(t.secret)try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}else{if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");t.passphrase=t.passphrase||t.password;try{if(r.secret=u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedSecret),t.passphrase).toString(u.enc.Utf8),!r.secret.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt secret")}try{if(r.primarySeed=new Buffer(u.AES.decrypt(u.format.OpenSSL.parse(t.encryptedPrimarySeed),r.secret).toString(u.enc.Utf8),"base64"),!r.primarySeed.length)throw new Error}catch(t){throw new c.WalletDecryptError("Failed to decrypt primarySeed")}}return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})),n.promise},b.prototype.unlockV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),n.resolve(i.fcall(function(){return i.when().then(function(){if(t.encryptedPrimarySeed=void 0!==t.encryptedPrimarySeed?t.encryptedPrimarySeed:r.encryptedPrimarySeed,t.encryptedSecret=void 0!==t.encryptedSecret?t.encryptedSecret:r.encryptedSecret,t.secret&&(r.secret=t.secret),t.primaryPrivateKey)throw new c.WalletInitError("specifying primaryPrivateKey has been deprecated");if(!t.primarySeed){if(t.secret)return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")});if(t.passphrase&&t.password)throw new c.WalletCreateError("Can't specify passphrase and password");return t.passphrase=t.passphrase||t.password,delete t.password,r.sdk.promisedDecrypt(new Buffer(t.encryptedSecret,"base64"),new Buffer(t.passphrase)).then(function(t){r.secret=t},function(){throw new c.WalletDecryptError("Failed to decrypt secret")}).then(function(){return r.sdk.promisedDecrypt(new Buffer(t.encryptedPrimarySeed,"base64"),r.secret).then(function(t){r.primarySeed=t},function(){throw new c.WalletDecryptError("Failed to decrypt primarySeed")})})}r.primarySeed=t.primarySeed}).then(function(){return s.HDNode.fromSeedBuffer(r.primarySeed,r.network)})})),n.promise},b.prototype.lock=function(){this.secret=null,this.primarySeed=null,this.primaryPrivateKey=null,this.backupPrivateKey=null,this.locked=!0},b.prototype.upgradeToV3=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.when(!0).then(function(){if(r.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to upgrade");if(r.walletVersion===b.WALLET_VERSION_V3)throw new c.WalletUpgradeError("Wallet is already V3");return r.walletVersion===b.WALLET_VERSION_V2?r._upgradeV2ToV3(t,n.notify.bind(n)):r.walletVersion===b.WALLET_VERSION_V1?r._upgradeV1ToV3(t,n.notify.bind(n)):void 0}).then(function(t){n.resolve(t)},function(t){n.reject(t)}),n.promise},b.prototype._upgradeV2ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed,recoverySecret:!1};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.sdk.updateWallet(r.identifier,{encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype._upgradeV1ToV3=function(t,e){var r=this;return i.when(!0).then(function(){var n={storeDataOnServer:!0,passphrase:t,primarySeed:r.primarySeed};return r.sdk.produceEncryptedDataV3(n,e||function(){}).then(function(t){return r.recoveryEncryptedSecret=t.recoveryEncryptedSecret,r.sdk.updateWallet(r.identifier,{primary_mnemonic:"",encrypted_primary_seed:t.encryptedPrimarySeed.toString("base64"),encrypted_secret:t.encryptedSecret.toString("base64"),recovery_secret:t.recoverySecret.toString("hex"),wallet_version:b.WALLET_VERSION_V3}).then(function(){return r.secret=t.secret,r.encryptedPrimarySeed=t.encryptedPrimarySeed,r.encryptedSecret=t.encryptedSecret,r.walletVersion=b.WALLET_VERSION_V3,r})})})},b.prototype.doPasswordChange=function(t){var e=this;return i.when(null).then(function(){if(e.walletVersion===b.WALLET_VERSION_V1)throw new c.WalletLockedError("Wallet version does not support password change!");if(e.locked)throw new c.WalletLockedError("Wallet needs to be unlocked to change password");if(!e.secret)throw new c.WalletLockedError("No secret");var r,n;if(e.walletVersion===b.WALLET_VERSION_V2)r=u.AES.encrypt(e.secret,t).toString(u.format.OpenSSL),n=d.entropyToMnemonic(c.convert(r,"base64","hex"));else{if("string"==typeof t)t=new Buffer(t);else if(!(t instanceof Buffer))throw new Error("New password must be provided as a string or a Buffer");r=f.encrypt(e.secret,t),n=h.encode(r),r=r.toString("base64")}return[r,n]})},b.prototype.passwordChange=function(t,e){var r=this,n=i.defer();return n.promise.nodeify(e),i.fcall(function(){return r.doPasswordChange(t).then(function(t){var e=t[0],n=t[1];return r.sdk.updateWallet(r.identifier,{encrypted_secret:e}).then(function(){return r.encryptedSecret=e,{encryptedSecret:n}})}).then(function(t){n.resolve(t)},function(t){n.reject(t)})}),n.promise},b.prototype.getAddressByPath=function(t){return this.getWalletScriptByPath(t).address},b.prototype.getRedeemScriptByPath=function(t){return this.getWalletScriptByPath(t).redeemScript},b.prototype.getWalletScriptByPath=function(t){var e,r,n=this.getPrimaryPublicKey(t),i=this.getBlocktrailPublicKey(t),o=b.deriveByPath(this.backupPublicKey,t.replace("'",""),"M"),a=b.sortMultiSigKeys([n.keyPair.getPublicKeyBuffer(),o.keyPair.getPublicKeyBuffer(),i.keyPair.getPublicKeyBuffer()]),c=s.script.multisig.output.encode(2,a),u=parseInt(t.split("/")[2]);"bitcoincash"!==this.network&&u===b.CHAIN_BTC_SEGWIT?(e=c,r=s.script.witnessScriptHash.output.encode(s.crypto.sha256(e))):(e=null,r=c);var f=s.script.scriptHash.output.encode(s.crypto.hash160(r));return{witnessScript:e,redeemScript:r,scriptPubKey:f,address:s.address.fromOutputScript(f,this.network,this.useNewCashAddr)}},b.prototype.getPrimaryPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.primaryPublicKeys[e]){if(!this.primaryPrivateKey)throw new c.KeyPathError("Wallet.getPrimaryPublicKey keyIndex ("+e+") is unknown to us");this.primaryPublicKeys[e]=b.deriveByPath(this.primaryPrivateKey,"M/"+e+"'","m")}var r=this.primaryPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.getBlocktrailPublicKey=function(t){var e=(t=t.replace("m","M")).split("/")[1].replace("'","");if(!this.blocktrailPublicKeys[e])throw new c.KeyPathError("Wallet.getBlocktrailPublicKey keyIndex ("+e+") is unknown to us");var r=this.blocktrailPublicKeys[e];return b.deriveByPath(r,t,"M/"+e+"'")},b.prototype.upgradeKeyIndex=function(t,e){var n=this,o=i.defer();if(o.promise.nodeify(e),n.locked)return o.reject(new c.WalletLockedError("Wallet needs to be unlocked to upgrade key index")),o.promise;var a=n.primaryPrivateKey.deriveHardened(t).neutered();return o.resolve(n.sdk.upgradeKeyIndex(n.identifier,t,[a.toBase58(),"M/"+t+"'"]).then(function(e){return n.keyIndex=t,r.forEach(e.blocktrail_public_keys,function(t,e){n.blocktrailPublicKeys[e]=s.HDNode.fromBase58(t[0],n.network)}),n.primaryPublicKeys[t]=a,!0})),o.promise},b.prototype.getNewAddress=function(t,e){var r=this;"function"==typeof t&&(e=t,t=null);var n=i.defer();if(n.promise.spreadNodeify(e),t!==parseInt(t,10)){if(void 0!==t&&null!==t)return n.reject(new Error("Invalid chain index")),n.promise;t=r.chain}return n.resolve(r.sdk.getNewDerivation(r.identifier,"M/"+r.keyIndex+"'/"+t).then(function(t){var e,n=t.path,i=t.address;try{e=r.decodeAddress(i),"cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type&&(r.bypassNewAddressCheck=!1)}catch(e){throw new c.WalletAddressError("Failed to decode address ["+t.address+"]")}if(!r.bypassNewAddressCheck){var o=r.getAddressByPath(t.path);if("cashAddrPrefix"in r.network&&r.useNewCashAddr&&"base58"===e.type){var a;try{a=r.decodeAddress(o)}catch(t){throw new c.WalletAddressError("Error while verifying address from server ["+t.message+"]")}if(a.decoded.hash.toString("hex")!==e.decoded.hash.toString("hex"))throw new c.WalletAddressError("Failed to verify legacy address [hash mismatch]");var u=a.decoded.version===s.script.types.P2PKH&&e.decoded.version===r.network.pubKeyHash,f=a.decoded.version===s.script.types.P2SH&&e.decoded.version===r.network.scriptHash;if(!u&&!f)throw new c.WalletAddressError("Failed to verify legacy address [prefix mismatch]");i=a.address}if(o!==i)throw new c.WalletAddressError("Failed to verify address ["+t.address+"] !== ["+i+"]")}return[i,n]})),n.promise},b.prototype.getBalance=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier).then(function(t){return[t.confirmed,t.unconfirmed]})),e.promise},b.prototype.getInfo=function(t){var e=i.defer();return e.promise.spreadNodeify(t),e.resolve(this.sdk.getWalletBalance(this.identifier)),e.promise},b.prototype.deleteWallet=function(t,e){"function"==typeof t&&(e=t,t=!1);var r=i.defer();if(r.promise.nodeify(e),this.locked)return r.reject(new c.WalletDeleteError("Wallet needs to be unlocked to delete wallet")),r.promise;var n=this.primaryPrivateKey.getAddress(),o=this.primaryPrivateKey.keyPair.d.toBuffer(32),s=a.sign(n,this.network.messagePrefix,o,!0).toString("base64");return r.resolve(this.sdk.deleteWallet(this.identifier,n,s,t).then(function(t){return t.deleted})),r.promise},b.prototype.pay=function(t,e,r,n,o,s,a,u){var f=this;"function"==typeof e?(u=e,e=null):"function"==typeof r?(u=r,r=!1):"function"==typeof n?(u=n,n=!0):"function"==typeof o?(u=o,o=null):"function"==typeof s?(u=s,s=null):"function"==typeof a&&(u=a,a={}),n=void 0===n||n,o=o||b.FEE_STRATEGY_OPTIMAL;var h=void 0===(a=a||{}).checkFee||a.checkFee,l=i.defer();return l.promise.nodeify(u),f.locked?(l.reject(new c.WalletLockedError("Wallet needs to be unlocked to send coins")),l.promise):(i.nextTick(function(){l.notify(b.PAY_PROGRESS_START),f.buildTransaction(t,e,r,n,o,a).then(function(t){return t},function(t){l.reject(t)},function(t){l.notify(t)}).spread(function(t,e){l.notify(b.PAY_PROGRESS_SEND);var r={signed_transaction:t.toHex(),base_transaction:t.__toBuffer(null,null,!1).toString("hex")};return f.sendTransaction(r,e.map(function(t){return t.path}),h,s,a.prioboost,a).then(function(t){if(l.notify(b.PAY_PROGRESS_DONE),t&&t.complete&&"false"!==t.complete)return t.txid;l.reject(new c.TransactionSignError("Failed to completely sign transaction"))})},function(t){throw t}).then(function(t){l.resolve(t)},function(t){l.reject(t)})}),l.promise)},b.prototype.decodeAddress=function(t){return b.getAddressAndType(t,this.network,this.useNewCashAddr)},b.getAddressAndType=function(t,e,r){var n,i,o;function a(r,s){var a=r(t,e);null===a[0]?(n=a[1],i=s):o=a[0]}if(e!==s.networks.bitcoin&&e!==s.networks.testnet&&e!==s.networks.regtest||a(y,"bech32"),!n&&"cashAddrPrefix"in e&&r&&a(m,"cashaddr"),n||a(v,"base58"),n)return{address:t,decoded:n,type:i};throw new c.InvalidAddressError(o.message)},b.convertPayToOutputs=function(t,e,r){var n,i=[];if(Array.isArray(t))n=function(t,e,r){if("object"!=typeof e)throw new Error("Invalid transaction output for numerically indexed list [1]");var n=Object.keys(e);if(-1!==n.indexOf("scriptPubKey")&&-1!==n.indexOf("value"))r.scriptPubKey=e.scriptPubKey,r.value=e.value;else if(-1!==n.indexOf("address")&&-1!==n.indexOf("value"))r.address=e.address,r.value=e.value;else{if(2!==n.length||2!==e.length||"0"!==n[0]||"1"!==n[1])throw new Error("Invalid transaction output for numerically indexed list [2]");r.address=e[0],r.value=e[1]}};else{if("object"!=typeof t)throw new Error("Invalid input");n=function(t,e,r){if(r.address=t.trim(),r.value=e,r.address===b.OP_RETURN){var n=Buffer.isBuffer(e)?e:new Buffer(e,"utf-8");r.scriptPubKey=s.script.nullData.output.encode(n).toString("hex"),r.value=0,r.address=null}}}return Object.keys(t).forEach(function(o){var a={};if(n(o,t[o],a),parseInt(a.value,10).toString()!==a.value.toString())throw new c.WalletSendError("Values should be in Satoshis");if("string"==typeof a.address)try{var u=b.getAddressAndType(a.address,e,r);a.scriptPubKey=s.address.toOutputScript(u.address,e,r).toString("hex"),delete a.address}catch(t){throw new c.InvalidAddressError("Invalid address ["+a.address+"] ("+t.message+")")}if("6a"!==a.scriptPubKey.slice(0,2)){if(!(a.value=parseInt(a.value,10)))throw new c.WalletSendError("Values should be non zero");if(a.value<=c.DUST)throw new c.WalletSendError("Values should be more than dust ("+c.DUST+")")}a.value=parseInt(a.value,10),i.push(a)}),i},b.prototype.buildTransaction=function(t,e,n,a,u,f,h){var l=this;"function"==typeof e?(h=e,e=null):"function"==typeof n?(h=n,n=!1):"function"==typeof a?(h=a,a=!0):"function"==typeof u?(h=u,u=null):"function"==typeof f&&(h=f,f={}),a=void 0===a||a,u=u||b.FEE_STRATEGY_OPTIMAL,f=f||{};var d=i.defer();return d.promise.spreadNodeify(h),i.nextTick(function(){var h;try{h=b.convertPayToOutputs(t,l.network,l.useNewCashAddr)}catch(t){return d.reject(t),d.promise}if(!h.length)return d.reject(new c.WalletSendError("Need at least one recipient")),d.promise;d.notify(b.PAY_PROGRESS_COIN_SELECTION),d.resolve(l.coinSelection(h,!0,n,u,f).spread(function(t,n,f){var d,y,m=[],v=i.defer();return o.waterfall([function(e){var r=t.map(function(t){return t.value}).reduce(function(t,e){return t+e})-h.map(function(t){return t.value}).reduce(function(t,e){return t+e})-n;if(r>2*c.DUST&&r!==f)return e(new c.WalletFeeError("the amount of change ("+f+") suggested by the coin selection seems incorrect ("+r+")"));e()},function(t){y=new s.TransactionBuilder(l.network),l.bitcoinCash&&y.enableBitcoinCash(),t()},function(e){var r;for(r=0;r0)if(f<=c.DUST)f=0;else if(!e)return v.notify(b.PAY_PROGRESS_CHANGE_ADDRESS),l.getNewAddress(l.changeChain,function(r,n){if(r)return t(r);e=n,t()});t()},function(t){if(f>0){var n={scriptPubKey:s.address.toOutputScript(e,l.network,l.useNewCashAddr),value:f};a?m.splice(r.random(0,m.length),0,n):m.push(n)}t()},function(t){m.forEach(function(t){y.addOutput(t.scriptPubKey,t.value)}),t()},function(e){var r,n,i,o,a;for(v.notify(b.PAY_PROGRESS_SIGN),r=0;rc.BASE_FEE)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems incorrect ("+r+") for FEE_STRATEGY_BASE_FEE"));break;case b.FEE_STRATEGY_HIGH_PRIORITY:case b.FEE_STRATEGY_OPTIMAL:case b.FEE_STRATEGY_LOW_PRIORITY:if(n>r*l.feeSanityCheckBaseFeeMultiplier)return e(new c.WalletFeeError("the fee suggested by the coin selection ("+n+") seems awefully high ("+r+") for FEE_STRATEGY_OPTIMAL"))}e()}],function(e){e?v.reject(new c.WalletSendError(e)):v.resolve([d,t])}),v.promise}))}),d.promise},b.prototype.coinSelection=function(t,e,r,n,o,s){var a;"function"==typeof e?(s=e,e=!0):"function"==typeof r?(s=r,r=!1):"function"==typeof n?(s=n,n=null):"function"==typeof o&&(s=o,o={}),e=void 0===e||e,n=n||b.FEE_STRATEGY_OPTIMAL,o=o||{};try{a=b.convertPayToOutputs(t,this.network,this.useNewCashAddr)}catch(t){var c=i.defer();return c.promise.nodeify(s),c.reject(t),c.promise}return this.sdk.coinSelection(this.identifier,a,e,r,n,o,s)},b.prototype.sendTransaction=function(t,e,r,n,o,s,a){"function"==typeof n?(a=n,n=null,o=!1):"function"==typeof o?(a=o,o=!1):"function"==typeof s&&(a=s,s={});var u=i.defer();return u.promise.nodeify(a),this.sdk.sendTransaction(this.identifier,t,e,r,n,o,s).then(function(t){u.resolve(t)},function(t){t.requires_2fa?u.reject(new c.WalletMissing2FAError):t.message.match(/Invalid two_factor_token/)?u.reject(new c.WalletInvalid2FAError):u.reject(t)}),u.promise},b.prototype.setupWebhook=function(t,e,r){return"function"==typeof e&&(r=e,e=null),e=e||"WALLET-"+this.identifier,this.sdk.setupWalletWebhook(this.identifier,e,t,r)},b.prototype.deleteWebhook=function(t,e){return"function"==typeof t&&(e=t,t=null),t=t||"WALLET-"+this.identifier,this.sdk.deleteWalletWebhook(this.identifier,t,e)},b.prototype.transactions=function(t,e){return this.sdk.walletTransactions(this.identifier,t,e)},b.prototype.maxSpendable=function(t,e,r,n){return"function"==typeof t?(n=t,t=!1):"function"==typeof e?(n=e,e=null):"function"==typeof r&&(n=r,r={}),"object"==typeof t?(r=t,t=!1):"object"==typeof e&&(r=e,e=null),void 0!==(r=r||{}).allowZeroConf&&(t=r.allowZeroConf),void 0!==r.feeStrategy&&(e=r.feeStrategy),e=e||b.FEE_STRATEGY_OPTIMAL,this.sdk.walletMaxSpendable(this.identifier,t,e,r,n)},b.prototype.addresses=function(t,e){return this.sdk.walletAddresses(this.identifier,t,e)},b.prototype.labelAddress=function(t,e,r){return this.sdk.labelWalletAddress(this.identifier,t,e,r)},b.prototype.utxos=function(t,e){return this.sdk.walletUTXOs(this.identifier,t,e)},b.prototype.unspentOutputs=b.prototype.utxos,b.sortMultiSigKeys=function(t){return t.sort(function(t,e){return t.toString("hex").localeCompare(e.toString("hex"))}),t},b.estimateIncompleteTxFee=function(t,e){var r=b.estimateIncompleteTxSize(t),n=r/1e3,i=Math.ceil(r/1e3);return e?parseInt(n*e,10):parseInt(i*c.BASE_FEE,10)},b.estimateVsizeFee=function(t,e,r){var n=l.estimateTxVsize(t,e),i=n/1e3,o=Math.ceil(n/1e3);return r?parseInt(i*r,10):parseInt(o*c.BASE_FEE,10)},b.estimateIncompleteTxSize=function(t){var e=16;return e+=34*t.outs.length,t.ins.forEach(function(t){var r=t.script,n=s.script.classifyInput(r),i=[2,3];if(!i&&"scripthash"===n){var o=s.script.decompile(r),a=o.slice(-1)[0];if(r=s.script.compile(o.slice(0,-1)),n=s.script.classifyInput(r),s.script.classifyOutput(a)!==n)throw new c.TransactionInputError("Non-matching scriptSig and scriptPubKey in input");if("multisig"===n){var u=s.script.decompile(a),f=u[0];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var h=u[a.chunks.length-2];if(f===s.opcodes.OP_0||fs.opcodes.OP_16)throw new c.TransactionInputError("Invalid multisig redeemScript");var l=f-(s.opcodes.OP_1-1),d=h-(s.opcodes.OP_1-1);if(d "+(p+t)+" using blocktrail key index: "+r+", chain: "+c),u.notify({message:"generating addresses "+p+" -> "+(p+t),increment:t,btPubKeyIndex:r,chain:c,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),l.nextTick(function(){n.createBatchAddresses(p,t,r,c).then(function(c){return s+=Object.keys(c).length,n.settings.logging&&console.log("starting fund discovery for "+t+" addresses..."),u.notify({message:"starting fund discovery for "+t+" addresses",increment:t,btPubKeyIndex:r,totalAddresses:s,addressUTXOs:a,totalUTXOs:o,totalBalance:i}),n.bitcoinDataClient.batchAddressHasTransactions(f.keys(c)).then(function(l){return b=l,n.settings.logging&&console.log("batch "+(b?"has":"does not have")+" transactions..."),h.when(b).then(function(h){if(h)return n.utxoFinder.getUTXOs(f.keys(c)).then(function(h){if(e.excludeZeroConf)for(var l in h)if(h.hasOwnProperty(l)&&Array.isArray(h[l]))for(var d=h[l],p=0;pe?e:p.length,a=0,c=p.length;a=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!g(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function w(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function E(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&s.isError(i),c=!t&&i&&!r;if((a&&o&&_(i,r)||c)&&m(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=b(y((e=this).actual),128)+" "+e.operator+" "+b(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),s=i.indexOf("\n"+o);if(s>=0){var a=i.indexOf("\n",s+1);i=i.substring(a+1)}this.stack=i}}},s.inherits(l.AssertionError,Error),l.fail=m,l.ok=v,l.equal=function(t,e,r){t!=e&&m(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&m(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){g(t,e,!1)||m(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){g(t,e,!0)||m(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){g(t,e,!1)&&m(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){g(e,r,!0)&&m(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&m(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&m(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){E(!0,t,e,r)},l.doesNotThrow=function(t,e,r){E(!1,t,e,r)},l.ifError=function(t){if(t)throw t},l.strict=n(function t(e,r){e||m(e,!0,r,"==",t)},l,{equal:l.strictEqual,deepEqual:l.deepStrictEqual,notEqual:l.notStrictEqual,notDeepEqual:l.notDeepStrictEqual}),l.strict.strict=l.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"object-assign":268,"util/":26}],24:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],25:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],26:[function(t,e,r){(function(e,n){(function(){var i=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(e)?n.showHidden=e:e&&r._extend(n,e),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function f(t,e,n){if(t.customInspect&&e&&S(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(y(e))return t.stylize(""+e,"number");if(p(e))return t.stylize(""+e,"boolean");if(b(e))return t.stylize("null","null")}(t,e);if(o)return o;var s=Object.keys(e),a=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),E(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(e);if(0===s.length){if(S(e)){var c=e.name?": "+e.name:"";return t.stylize("[Function"+c+"]","special")}if(g(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(_(e))return t.stylize(Date.prototype.toString.call(e),"date");if(E(e))return h(e)}var u,w="",k=!1,A=["{","}"];(d(e)&&(k=!0,A=["[","]"]),S(e))&&(w=" [Function"+(e.name?": "+e.name:"")+"]");return g(e)&&(w=" "+RegExp.prototype.toString.call(e)),_(e)&&(w=" "+Date.prototype.toUTCString.call(e)),E(e)&&(w=" "+h(e)),0!==s.length||k&&0!=e.length?n<0?g(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=k?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,w,A)):A[0]+w+A[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),M(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=b(r)?f(t,c.value,null):f(t,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function y(t){return"number"==typeof t}function m(t){return"string"==typeof t}function v(t){return void 0===t}function g(t){return w(t)&&"[object RegExp]"===k(t)}function w(t){return"object"==typeof t&&null!==t}function _(t){return w(t)&&"[object Date]"===k(t)}function E(t){return w(t)&&("[object Error]"===k(t)||t instanceof Error)}function S(t){return"function"==typeof t}function k(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}r.debuglog=function(t){if(v(o)&&(o=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!s[t])if(new RegExp("\\b"+t+"\\b","i").test(o)){var n=e.pid;s[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else s[t]=function(){};return s[t]},r.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=p,r.isNull=b,r.isNullOrUndefined=function(t){return null==t},r.isNumber=y,r.isString=m,r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=v,r.isRegExp=g,r.isObject=w,r.isDate=_,r.isError=E,r.isFunction=S,r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t("./support/isBuffer");var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}r.log=function(){var t,e;console.log("%s - %s",(t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],e].join(" ")),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":25,_process:270,inherits:24}],27:[function(t,e,r){(function(t,r){(function(){!function(){var n,i,o={};function s(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}null!=(n=this)&&(i=n.async),o.noConflict=function(){return n.async=i,o};var a=Object.prototype.toString,c=Array.isArray||function(t){return"[object Array]"===a.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r=t.length&&r()}u(t,function(t){e(t,s(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){l(e).apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;s=e.length?n():a())})}()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},b=function(t,e,r,n){if(e=f(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=d(b),o.mapSeries=p(b),o.mapLimit=function(t,e,r,n){return y(e)(t,r,n)};var y=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}}(t,b)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=f(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var m=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=d(m),o.filterSeries=p(m),o.select=o.filter,o.selectSeries=o.filterSeries;var v=function(t,e,r,n){var i=[];t(e=f(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(f(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=d(v),o.rejectSeries=p(v);var g=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=d(g),o.detectSeries=p(g),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,f(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return rn?1:0}),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],a=function(t){s.unshift(t)},f=function(){n--,u(s.slice(0),function(t){t()})};a(function(){if(!n){var t=e;e=function(){},t(null,i)}}),u(r,function(r){var n=c(t[r])?t[r]:[t[r]],l=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};u(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(f)},d=n.slice(0,Math.abs(n.length-1))||[],p=function(){return e=function(t,e){return t&&i.hasOwnProperty(e)},n=!0,((t=d).reduce?t.reduce(e,n):(u(t,function(t,r,i){n=e(n,t,r,i)}),n))&&!i.hasOwnProperty(r);var t,e,n};if(p())n[n.length-1](l,i);else{var b=function(){p()&&(!function(t){for(var e=0;e>>1);r(e,t[o])>=0?n=o:i=o-1}return n}(t.tasks,s,r)+1,0,s),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}(n,t,e,i)},delete n.unshift,n},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){c(t)||(t=[t]),u(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=f(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;u(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&u(r,function(e){console[t](e)}))}]))}};o.log=E("log"),o.dir=E("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;e2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=d(S),o.applyEachSeries=p(S),o.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},void 0!==e&&e.exports?e.exports=o:n.async=o}()}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],28:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer;e.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(s);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,d=s-1;(0!==h||l>>0,f[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=l,r++}if(" "!==t[r]){for(var p=s-o;p!==s&&0===f[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=f[p++];return b}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var l=e[o],d=0,p=u-1;(0!==l||d>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");i=d,o++}for(var b=u-i;b!==u&&0===h[b];)b++;for(var y=c.repeat(r);b>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function c(t){for(var e=1,r=0;r126)throw new Error("Invalid prefix ("+t+")");e=a(e)^n>>5}e=a(e);for(var i=0;i=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+t);var o=t.slice(0,n),s=t.slice(n+1);if(s.length<6)throw new Error("Data too short");for(var u=c(o),f=[],h=0;h=s.length||f.push(d)}if(1!==u)throw new Error("Invalid checksum for "+t);return{prefix:o,words:f}},encode:function(t,e){if(t.length+7+e.length>90)throw new TypeError("Exceeds Bech32 maximum length");for(var r=c(t=t.toLowerCase()),i=t+"1",o=0;o>5!=0)throw new Error("Non 5-bit word");r=a(r)^s,i+=n.charAt(s)}for(var u=0;u<6;++u)r=a(r);r^=1;for(var f=0;f<6;++f){var h=r>>5*(5-f)&31;i+=n.charAt(h)}return i},toWords:function(t){return u(t,8,5,!0)},fromWords:function(t){return u(t,5,8,!1)}}},{}],30:[function(t,e,r){function BigInteger(t,e,r){if(!(this instanceof BigInteger))return new BigInteger(t,e,r);null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}var n=BigInteger.prototype;n.__bigi=t("../package.json").version,BigInteger.isBigInteger=function(t,e){return t&&t.__bigi&&(!e||t.__bigi===n.__bigi)},BigInteger.prototype.am=function(t,e,r,n,i,o){for(;--o>=0;){var s=e*this[t++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,s,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(o="0".charCodeAt(0),s=0;s<=9;++s)c[o++]=s;for(o="a".charCodeAt(0),s=10;s<36;++s)c[o++]=s;for(o="A".charCodeAt(0),s=10;s<36;++s)c[o++]=s;function u(t){return a.charAt(t)}function f(t,e){var r=c[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=new BigInteger;return e.fromInt(t),e}function l(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function d(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function w(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function _(){}function E(t){return t}function S(t){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}d.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},d.prototype.revert=function(t){return t},d.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},d.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},d.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=new BigInteger;return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(BigInteger.ZERO)>0&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+i:this.t=0},n.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,o=0;--n>=0;){var s=8==r?255&t[n]:f(t,n);s<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},n.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.drShiftTo=function(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},n.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,o=(1<>n;for(var s=r+1;s>n;n>0&&(e[this.t-r-1]|=(this.s&o)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},n.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,f=o[u-1];if(0!=f){var h=f*(1<1?o[u-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),BigInteger.ONE.dlShiftTo(u,v),v.subTo(o,o);o.t=0;){var g=r[--y]==f?this.DM:Math.floor(r[y]*d+(r[y-1]+b)*p);if((r[y]+=o.am(0,g,r,m,0,u))0&&r.rShiftTo(c,r),s<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=e.convert(this),o=l(t)-1;for(i.copyTo(r);--o>=0;)if(e.sqrTo(r,n),(t&1<0)e.mulTo(n,i,r);else{var s=r;r=n,n=s}return e.revert(r)},n.toString=function(t){var e;if(this.s<0)return"-"+this.negate().toString(t);if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<0)for(a>a)>0&&(i=!0,o=u(r));s>=0;)a>(a+=this.DB-e)):(r=this[s]>>(a-=e)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var t=new BigInteger;return BigInteger.ZERO.subTo(this,t),t},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(t){var e=new BigInteger;return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e},n.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new d(e):new p(e),this.exp(t,r)},_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},_.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=new BigInteger;return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/k[k.length-1];n.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),i=new BigInteger,o=new BigInteger,s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(t)+s},n.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,o=0,s=0,a=0;a=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},n.millerRabin=function(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>k.length&&(t=k.length);for(var i=new BigInteger(null),o=[],s=0;s>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<=0;)n<8?(r=(this[t]&(1<>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},n.equals=function(t){return 0==this.compareTo(t)},n.min=function(t){return this.compareTo(t)<0?this:t},n.max=function(t){return this.compareTo(t)>0?this:t},n.and=function(t){var e=new BigInteger;return this.bitwiseTo(t,b,e),e},n.or=function(t){var e=new BigInteger;return this.bitwiseTo(t,y,e),e},n.xor=function(t){var e=new BigInteger;return this.bitwiseTo(t,m,e),e},n.andNot=function(t){var e=new BigInteger;return this.bitwiseTo(t,v,e),e},n.not=function(){for(var t=new BigInteger,e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var f=new BigInteger;for(n.sqrTo(s[1],f);a<=u;)s[a]=new BigInteger,n.mulTo(f,s[a-2],s[a]),a+=2}var b,y,m=t.t-1,v=!0,g=new BigInteger;for(i=l(t[m])-1;m>=0;){for(i>=c?b=t[m]>>i-c&u:(b=(t[m]&(1<0&&(b|=t[m-1]>>this.DB+i-c)),a=r;0==(1&b);)b>>=1,--a;if((i-=a)<0&&(i+=this.DB,--m),v)s[b].copyTo(o),v=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(y=o,o=g,g=y),n.mulTo(g,s[b],o)}for(;m>=0&&0==(t[m]&1<=0?(r.subTo(n,r),e&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),e&&s.subTo(i,s),a.subTo(o,a))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;a.compareTo(t)>=0;)a.subTo(t,a);for(;a.signum()<0;)a.addTo(t,a);return a},n.pow=function(t){return this.exp(t,new _)},n.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(i0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=k[k.length-1]){for(e=0;e-1});n(i,"Invalid mnemonic");var o=r.map(function(t){return p(e.indexOf(t).toString(2),"0",11)}).join(""),s=32*Math.floor(o.length/33),c=o.slice(0,s),u=o.slice(s),f=c.match(/(.{1,8})/g).map(function(t){return parseInt(t,2)}),l=new Buffer(f),d=h(l);return n(d===u,"Invalid mnemonic checksum"),l.toString("hex")}function f(t,e){e=e||a;var r=new Buffer(t,"hex");return(d([].slice.call(r))+h(r)).match(/(.{1,11})/g).map(function(t){var r=parseInt(t,2);return e[r]}).join(" ")}function h(t){var e=i("sha256").update(t).digest(),r=8*t.length/32;return d([].slice.call(e)).slice(0,r)}function l(t){return"mnemonic"+(s.nfkd(t)||"")}function d(t){return t.map(function(t){return p(t.toString(2),"0",8)}).join("")}function p(t,e,r){for(;t.length>>24]^y[a>>16&255]^m[c>>8&255]^v[255&e]^i[p],f=t[a>>>24]^y[c>>16&255]^m[e>>8&255]^v[255&o]^i[p+1],h=t[c>>>24]^y[e>>16&255]^m[o>>8&255]^v[255&a]^i[p+2],e=t[e>>>24]^y[o>>16&255]^m[a>>8&255]^v[255&c]^i[p+3],p+=4,o=u,a=f,c=h;for(l=0;4>l;l++)b[r?3&-l:l]=g[o>>>24]<<24^g[a>>16&255]<<16^g[c>>8&255]<<8^g[255&e]^i[p++],u=o,o=a,a=c,c=e,e=u;return b}function c(t,e){var r,n=s.random.D[t],i=[];for(r in n)n.hasOwnProperty(r)&&i.push(n[r]);for(r=0;re&&(t.i[e]=t.i[e]+1|0,!t.i[e]);e++);return t.F.encrypt(t.i)}function l(t,e){return function(){e.apply(t,arguments)}}void 0!==e&&e.exports&&(e.exports=s),s.cipher.aes=function(t){this.o[0][0][0]||this.t();var e,r,i,o,a=this.o[0][4],c=this.o[1],u=1;for(4!==(e=t.length)&&6!==e&&8!==e&&n(new s.exception.invalid("invalid aes key size")),this.b=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=a[r>>>24]<<24^a[r>>16&255]<<16^a[r>>8&255]<<8^a[255&r],0==t%e&&(r=r<<8^r>>>24^u<<24,u=u<<1^283*(u>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:c[0][a[r>>>24]]^c[1][a[r>>16&255]]^c[2][a[r>>8&255]]^c[3][a[255&r]]},s.cipher.aes.prototype={encrypt:function(t){return a(this,t,0)},decrypt:function(t){return a(this,t,1)},o:[[[],[],[],[],[]],[[],[],[],[],[]]],t:function(){var t,e,r,n,i,o,s,a=this.o[0],c=this.o[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},s.bitArray={bitSlice:function(t,e,r){return t=s.bitArray.R(t.slice(e/32),32-(31&e)).slice(1),r===i?t:s.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(s.bitArray.bitLength(t)!==s.bitArray.bitLength(e))return o;var r,n=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=s.bitArray.getPartial(o),n.push(s.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},s.codec.utf8String={fromBits:function(t){var e,r,n="",i=s.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e>>i)>>>26),6>i?(a=t[r]<<6-i,i+=26,r++):(a<<=6,i-=6);for(;3&n.length&&!e;)n+="=";return n},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,i,o=[],a=0,c=s.codec.base64.M,u=0;for(e&&(c=c.substr(0,62)+"-_"),r=0;r(i=c.indexOf(t.charAt(r)))&&n(new s.exception.invalid("this isn't base64!")),26>>a),u=i<<32-a):u^=i<<32-(a+=6);return 56&a&&o.push(s.bitArray.partial(56&a,u,1)),o}},s.codec.base64url={fromBits:function(t){return s.codec.base64.fromBits(t,1,1)},toBits:function(t){return s.codec.base64.toBits(t,1)}},s.hash.sha256=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha256.hash=function(t){return(new s.hash.sha256).update(t).finalize()},s.hash.sha256.prototype={blockSize:512,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=512+e&-512;e<=t;e+=512)this.r(r.splice(0,16));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,16));return this.reset(),r},l:[],b:[],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}var e,r=0,n=2;t:for(;64>r;n++){for(e=2;e*e<=n;e++)if(0==n%e)continue t;8>r&&(this.l[r]=t(Math.pow(n,.5))),this.b[r]=t(Math.pow(n,1/3)),r++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(t=0;64>t;t++)16>t?e=n[t]:(e=n[t+1&15],r=n[t+14&15],e=n[15&t]=(e>>>7^e>>>18^e>>>3^e<<25^e<<14)+(r>>>17^r>>>19^r>>>10^r<<15^r<<13)+n[15&t]+n[t+9&15]|0),e=e+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[t],d=l,l=h,h=f,f=u+e|0,u=c,c=a,s=e+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},s.hash.sha512=function(t){this.b[0]||this.t(),t?(this.e=t.e.slice(0),this.d=t.d.slice(0),this.c=t.c):this.reset()},s.hash.sha512.hash=function(t){return(new s.hash.sha512).update(t).finalize()},s.hash.sha512.prototype={blockSize:1024,reset:function(){return this.e=this.l.slice(0),this.d=[],this.c=0,this},update:function(t){"string"==typeof t&&(t=s.codec.utf8String.toBits(t));var e,r=this.d=s.bitArray.concat(this.d,t);for(e=this.c,t=this.c=e+s.bitArray.bitLength(t),e=1024+e&-1024;e<=t;e+=1024)this.r(r.splice(0,32));return this},finalize:function(){var t,e=this.d,r=this.e;for(t=(e=s.bitArray.concat(e,[s.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.c/4294967296)),e.push(0|this.c);e.length;)this.r(e.splice(0,32));return this.reset(),r},l:[],ca:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],ea:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],t:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}var r,n=0,i=2;t:for(;80>n;i++){for(r=2;r*r<=i;r++)if(0==i%r)continue t;8>n&&(this.l[2*n]=t(Math.pow(i,.5)),this.l[2*n+1]=e(Math.pow(i,.5))<<24|this.ca[n]),this.b[2*n]=t(Math.pow(i,1/3)),this.b[2*n+1]=e(Math.pow(i,1/3))<<24|this.ea[n],n++}},r:function(t){var e,r,n=t.slice(0),i=this.e,o=this.b,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15],E=s,S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},s.mode.ccm={name:"ccm",w:[],listenProgress:function(t){s.mode.ccm.w.push(t)},unListenProgress:function(t){-1<(t=s.mode.ccm.w.indexOf(t))&&s.mode.ccm.w.splice(t,1)},X:function(t){var e,r=s.mode.ccm.w.slice();for(e=0;ef&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),a=2;4>a&&h>>>8*a;a++);return a<15-f&&(a=15-f),r=u.clamp(r,8*(15-a)),e=s.mode.ccm.O(t,e,r,i,o,a),c=s.mode.ccm.s(t,c,r,e,o,a),u.concat(c.data,c.tag)},decrypt:function(t,e,r,i,o){o=o||64,i=i||[];var a=s.bitArray,c=a.bitLength(r)/8,u=a.bitLength(e),f=a.clamp(e,u-o),h=a.bitSlice(e,u-o);u=(u-o)/8;for(7>c&&n(new s.exception.invalid("ccm: iv must be at least 7 bytes")),e=2;4>e&&u>>>8*e;e++);return e<15-c&&(e=15-c),r=a.clamp(r,8*(15-e)),f=s.mode.ccm.s(t,f,r,h,o,e),t=s.mode.ccm.O(t,f.data,r,i,o,e),a.equal(f.tag,t)||n(new s.exception.corrupt("ccm: tag doesn't match")),f.data},ga:function(t,e,r,n,i,o){var a=[],c=s.bitArray,u=c.j;if(n=[c.partial(8,(e.length?64:0)|n-2<<2|o-1)],(n=c.concat(n,r))[3]|=i,n=t.encrypt(n),e.length)for(65279>=(r=c.bitLength(e)/8)?a=[c.partial(16,r)]:4294967295>=r&&(a=c.concat([c.partial(16,65534)],[r])),a=c.concat(a,e),e=0;eo||16h&&(s.mode.ccm.X(a/u),h+=l),r[3]++,i=t.encrypt(r),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:n,data:c.clamp(e,f)}}},s.mode.ocb2={name:"ocb2",encrypt:function(t,e,r,i,o,a){128!==s.bitArray.bitLength(r)&&n(new s.exception.invalid("ocb iv must be 128 bits"));var c,u=s.mode.ocb2.K,f=s.bitArray,h=f.j,l=[0,0,0,0];r=u(t.encrypt(r));var d,p=[];for(i=i||[],o=o||64,c=0;c+4i.bitLength(r)&&(c=o(c,n(c)),r=i.concat(r,[-2147483648,0,0,0])),a=o(a,r),t.encrypt(o(n(o(c,n(c))),a))},K:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},s.mode.gcm={name:"gcm",encrypt:function(t,e,r,n,i){var o=e.slice(0);return e=s.bitArray,n=n||[],t=s.mode.gcm.s(!0,t,o,n,r,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,a){var c=e.slice(0),u=s.bitArray,f=u.bitLength(c);return a=a||128,i=i||[],a<=f?(e=u.bitSlice(c,f-a),c=u.bitSlice(c,0,f-a)):(e=c,c=[]),t=s.mode.gcm.s(o,t,c,i,r,a),u.equal(t.tag,e)||n(new s.exception.corrupt("gcm: tag doesn't match")),t.data},ba:function(t,e){var r,n,i,o,a,c=s.bitArray.j;for(i=[0,0,0,0],o=e.slice(0),r=0;128>r;r++){for((n=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(i=c(i,o)),a=0!=(1&o[3]),n=3;0>>1|(1&o[n-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},k:function(t,e,r){var n,i=r.length;for(e=e.slice(0),n=0;ni&&(t=e.hash(t)),r=0;ri||0>r)&&n(s.exception.invalid("invalid params to pbkdf2")),"string"==typeof t&&(t=s.codec.utf8String.toBits(t)),"string"==typeof e&&(e=s.codec.utf8String.toBits(e)),t=new(o=o||s.misc.hmac)(t);var a,c,u,f,h=[],l=s.bitArray;for(f=1;32*h.length<(i||1);f++){for(o=a=t.encrypt(l.concat(e,[f])),c=1;ca;a++)i.push(4294967296*Math.random()|0);for(a=0;a=1<this.n&&(this.n=c),this.I++,this.b=s.hash.sha256.hash(this.b.concat(i)),this.F=new s.cipher.aes(this.b),r=0;4>r&&(this.i[r]=this.i[r]+1|0,!this.i[r]);r++);}for(r=0;r>>=1;this.f[f].update([o,this.H++,2,e,u,t.length].concat(t))}break;case"string":e===i&&(e=t.length),this.f[f].update([o,this.H++,3,e,u,t.length]),this.f[f].update(t);break;default:l=1}l&&n(new s.exception.bug("random: addEntropy only supports number, array of numbers or string")),this.m[f]+=e,this.g+=e,h===this.p&&(this.isReady()!==this.p&&c("seeded",Math.max(this.n,this.g)),c("progress",this.getProgress()))},isReady:function(t){return t=this.L[t!==i?t:this.G],this.n&&this.n>=t?this.m[0]>this.T&&(new Date).valueOf()>this.Q?this.C|this.B:this.B:this.g>=t?this.C|this.p:this.p},getProgress:function(t){return t=this.L[t||this.G],this.n>=t?1:this.g>t?1:this.g/t},startCollectors:function(){this.u||(this.a={loadTimeCollector:l(this,this.fa),mouseCollector:l(this,this.ha),keyboardCollector:l(this,this.da),accelerometerCollector:l(this,this.W),touchCollector:l(this,this.ja)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,o),window.addEventListener("mousemove",this.a.mouseCollector,o),window.addEventListener("keypress",this.a.keyboardCollector,o),window.addEventListener("devicemotion",this.a.accelerometerCollector,o),window.addEventListener("touchmove",this.a.touchCollector,o)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):n(new s.exception.bug("can't attach event")),this.u=!0)},stopCollectors:function(){this.u&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,o),window.removeEventListener("mousemove",this.a.mouseCollector,o),window.removeEventListener("keypress",this.a.keyboardCollector,o),window.removeEventListener("devicemotion",this.a.accelerometerCollector,o),window.removeEventListener("touchmove",this.a.touchCollector,o)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.u=o)},addEventListener:function(t,e){this.D[t][this.Y++]=e},removeEventListener:function(t,e){var r,n,i=this.D[t],o=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&o.push(n);for(r=0;r=c.iter||64!==c.ts&&96!==c.ts&&128!==c.ts||128!==c.ks&&192!==c.ks&&256!==c.ks||2>c.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||472)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;var e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;var r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},decode:function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");var e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");var r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},encode:function(t,e){var r=t.length,n=e.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=t.length,t.copy(i,4),i[4+r]=2,i[5+r]=e.length,e.copy(i,6+r),i}}},{"safe-buffer":321}],39:[function(t,e,r){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},{}],40:[function(t,e,r){var n=t("./index.json"),i={};for(var o in n){i[n[o]]=o}e.exports=i},{"./index.json":39}],41:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bech32"),i=t("cashaddress"),o=t("bs58check"),s=t("./script"),a=t("./templates"),c=t("./networks"),u=t("typeforce"),f=t("./types");function h(t){var e=o.decode(t);if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function l(t){var e=n.decode(t),r=n.fromWords(e.words.slice(1));return{version:e.words[0],prefix:e.prefix,data:Buffer.from(r)}}function d(t){return i.decode(t)}function p(t,e){u(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=Buffer.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),o.encode(r)}function b(t,e,r){var i=n.toWords(t);return i.unshift(e),n.encode(r,i)}function y(t,e,r){return i.encode(r,e,t)}e.exports={fromBase58Check:h,fromBech32:l,fromCashAddress:d,fromOutputScript:function(t,e,r){if(e=e||c.bitcoin,r=r||!1,"cashAddrPrefix"in e&&r){if(s.pubKeyHash.output.check(t))return y(s.compile(t).slice(3,23),a.types.P2PKH,e.cashAddrPrefix);if(s.scriptHash.output.check(t))return y(s.compile(t).slice(2,22),a.types.P2SH,e.cashAddrPrefix)}else{if(s.pubKeyHash.output.check(t))return p(s.compile(t).slice(3,23),e.pubKeyHash);if(s.scriptHash.output.check(t))return p(s.compile(t).slice(2,22),e.scriptHash)}if(s.witnessPubKeyHash.output.check(t))return b(s.compile(t).slice(2,22),0,e.bech32);if(s.witnessScriptHash.output.check(t))return b(s.compile(t).slice(2,34),0,e.bech32);throw new Error(s.toASM(t)+" has no matching Address")},toBase58Check:p,toBech32:b,toCashAddress:y,toOutputScript:function(t,e,r){var n;if("cashAddrPrefix"in(e=e||c.bitcoin)&&r){try{if("pubkeyhash"===(n=d(t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}try{if("pubkeyhash"===(n=d(e.cashAddrPrefix+":"+t)).version)return s.pubKeyHash.output.encode(n.hash);if("scripthash"===n.version)return s.scriptHash.output.encode(n.hash)}catch(t){}if(n&&n.prefix!==e.cashAddrPrefix)throw new Error(t+" has an invalid prefix")}try{if((n=h(t)).version===e.pubKeyHash)return s.pubKeyHash.output.encode(n.hash);if(n.version===e.scriptHash)return s.scriptHash.output.encode(n.hash)}catch(t){}if(!n&&"bech32"in e){try{n=l(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return s.witnessPubKeyHash.output.encode(n.data);if(32===n.data.length)return s.witnessScriptHash.output.encode(n.data)}}}throw new Error(t+" has no matching Script")}}},{"./networks":50,"./script":51,"./templates":53,"./types":77,bech32:29,bs58check:106,cashaddress:113,"safe-buffer":321,typeforce:351}],42:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("merkle-lib/fastRoot"),s=t("typeforce"),a=t("./types"),c=t("varuint-bitcoin"),u=t("./transaction");function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var e=0;function r(r){return e+=r,t.slice(e-r,e)}function n(){var r=t.readUInt32LE(e);return e+=4,r}var i=new f;if(i.version=function(){var r=t.readInt32LE(e);return e+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===t.length)return i;function o(){var r=u.fromBuffer(t.slice(e),!0);return e+=r.byteLength(),r}var s,a=(s=c.decode(t,e),e+=c.decode.bytes,s);i.transactions=[];for(var h=0;h>24)-3,r=8388607&t,n=Buffer.alloc(32,0);return n.writeUInt32BE(r,28-e),n},f.calculateMerkleRoot=function(t){if(s([{getHash:a.Function}],t),0===t.length)throw TypeError("Cannot compute merkle root for zero transactions");var e=t.map(function(t){return t.getHash()});return o(e,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var t=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)},f.prototype.checkProofOfWork=function(){var t=n(this.getHash()),e=f.calculateTarget(this.bits);return t.compare(e)<=0},e.exports=f},{"./crypto":44,"./transaction":75,"./types":77,"buffer-reverse":108,"merkle-lib/fastRoot":263,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],43:[function(t,e,r){var n=t("pushdata-bitcoin"),i=t("varuint-bitcoin");function o(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(t,e){var r=t.readUInt32LE(e),n=t.readUInt32LE(e+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(t,e){return{number:i.decode(t,e),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(t,e,r){return o(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8},writeVarInt:function(t,e,r){return i.encode(e,t,r),i.encode.bytes}}},{"pushdata-bitcoin":298,"varuint-bitcoin":357}],44:[function(t,e,r){var n=t("create-hash");function i(t){return n("rmd160").update(t).digest()}function o(t){return n("sha256").update(t).digest()}e.exports={hash160:function(t){return i(o(t))},hash256:function(t){return o(o(t))},ripemd160:i,sha1:function(t){return n("sha1").update(t).digest()},sha256:o}},{"create-hash":118}],45:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("typeforce"),o=t("./types"),BigInteger=t("bigi"),s=t("./ecsignature"),a=Buffer.alloc(1,0),c=Buffer.alloc(1,1),u=t("ecurve").getCurveByName("secp256k1");function f(t,e,r){i(o.tuple(o.Hash256bit,o.Buffer256bit,o.Function),arguments);var s=Buffer.alloc(32,0),f=Buffer.alloc(32,1);s=n("sha256",s).update(f).update(a).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),s=n("sha256",s).update(f).update(c).update(e).update(t).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest();for(var h=BigInteger.fromBuffer(f);h.signum()<=0||h.compareTo(u.n)>=0||!r(h);)s=n("sha256",s).update(f).update(a).digest(),f=n("sha256",s).update(f).digest(),f=n("sha256",s).update(f).digest(),h=BigInteger.fromBuffer(f);return h}var h=u.n.shiftRight(1);e.exports={deterministicGenerateK:f,sign:function(t,e){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,a=e.toBuffer(32),c=BigInteger.fromBuffer(t),l=u.n,d=u.G;return f(t,a,function(t){var i=d.multiply(t);return!u.isInfinity(i)&&0!==(r=i.affineX.mod(l)).signum()&&0!==(n=t.modInverse(l).multiply(c.add(e.multiply(r))).mod(l)).signum()}),n.compareTo(h)>0&&(n=l.subtract(n)),new s(r,n)},verify:function(t,e,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=u.n,s=u.G,a=e.r,c=e.s;if(a.signum()<=0||a.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=BigInteger.fromBuffer(t),h=c.modInverse(n),l=f.multiply(h).mod(n),d=a.multiply(h).mod(n),p=s.multiplyTwo(l,r,d);return!u.isInfinity(p)&&p.affineX.mod(n).equals(a)},__curve:u}},{"./ecsignature":47,"./types":77,bigi:32,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],46:[function(t,e,r){var n=t("./address"),i=t("./crypto"),o=t("./ecdsa"),s=t("randombytes"),a=t("typeforce"),c=t("./types"),u=t("wif"),f=t("./networks"),BigInteger=t("bigi"),h=t("ecurve"),l=o.__curve;function ECPair(t,e,r){if(r&&a({compressed:c.maybe(c.Boolean),network:c.maybe(c.Network)},r),r=r||{},t){if(t.signum()<=0)throw new Error("Private key must be greater than 0");if(t.compareTo(l.n)>=0)throw new Error("Private key must be less than the curve order");if(e)throw new TypeError("Unexpected publicKey parameter");this.d=t}else a(c.ECPoint,e),this.__Q=e;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=l.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(t,e){var r=h.Point.decodeFrom(l,t);return new ECPair(null,r,{compressed:r.compressed,network:e})},ECPair.fromWIF=function(t,e){var r=u.decode(t),n=r.version;if(c.Array(e)){if(!(e=e.filter(function(t){return n===t.wif}).pop()))throw new Error("Unknown network version")}else if(e=e||f.bitcoin,n!==e.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:e})},ECPair.makeRandom=function(t){var e,r=(t=t||{}).rng||s;do{var n=r(32);a(c.Buffer256bit,n),e=BigInteger.fromBuffer(n)}while(e.signum()<=0||e.compareTo(l.n)>=0);return new ECPair(e,null,t)},ECPair.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.sign=function(t){if(!this.d)throw new Error("Missing private key");return o.sign(t,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(t,e){return o.verify(t,e,this.Q)},e.exports=ECPair},{"./address":41,"./crypto":44,"./ecdsa":45,"./networks":50,"./types":77,bigi:32,ecurve:199,randombytes:303,typeforce:351,wif:359}],47:[function(t,e,r){(function(Buffer){(function(){var r=t("bip66"),n=t("typeforce"),i=t("./types"),BigInteger=t("bigi");function o(t,e){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=t,this.s=e}o.parseCompact=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e!==(7&e))throw new Error("Invalid signature parameter");return{compressed:!!(4&e),i:3&e,signature:new o(BigInteger.fromBuffer(t.slice(1,33)),BigInteger.fromBuffer(t.slice(33)))}},o.fromDER=function(t){var e=r.decode(t);return new o(BigInteger.fromDERInteger(e.r),BigInteger.fromDERInteger(e.s))},o.parseScriptSignature=function(t){var e=t.readUInt8(t.length-1),r=-193&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);return{signature:o.fromDER(t.slice(0,-1)),hashType:e}},o.prototype.toCompact=function(t,e){e&&(t+=4),t+=27;var r=Buffer.alloc(65);return r.writeUInt8(t,0),this.r.toBuffer(32).copy(r,1),this.s.toBuffer(32).copy(r,33),r},o.prototype.toDER=function(){var t=Buffer.from(this.r.toDERInteger()),e=Buffer.from(this.s.toDERInteger());return r.encode(t,e)},o.prototype.toScriptSignature=function(t){var e=-193&t;if(e<=0||e>=4)throw new Error("Invalid hashType "+t);var r=Buffer.alloc(1);return r.writeUInt8(t,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./types":77,bigi:32,bip66:38,buffer:110,typeforce:351}],48:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bs58check"),i=t("./crypto"),o=t("create-hmac"),s=t("typeforce"),a=t("./types"),c=t("./networks"),BigInteger=t("bigi"),ECPair=t("./ecpair"),u=t("ecurve"),f=u.getCurveByName("secp256k1");function HDNode(t,e){if(s(a.tuple("ECPair",a.Buffer256bit),arguments),!t.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=t,this.chainCode=e,this.depth=0,this.index=0,this.parentFingerprint=0}HDNode.HIGHEST_BIT=2147483648,HDNode.LENGTH=78,HDNode.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),HDNode.fromSeedBuffer=function(t,e){if(s(a.tuple(a.Buffer,a.maybe(a.Network)),arguments),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",HDNode.MASTER_SECRET).update(t).digest(),n=r.slice(0,32),i=r.slice(32),c=BigInteger.fromBuffer(n);return new HDNode(new ECPair(c,null,{network:e}),i)},HDNode.fromSeedHex=function(t,e){return HDNode.fromSeedBuffer(Buffer.from(t,"hex"),e)},HDNode.fromBase58=function(t,e){var r=n.decode(t);if(78!==r.length)throw new Error("Invalid buffer length");var i,o=r.readUInt32BE(0);if(Array.isArray(e)){if(!(i=e.filter(function(t){return o===t.bip32.private||o===t.bip32.public}).pop()))throw new Error("Unknown network version")}else i=e||c.bitcoin;if(o!==i.bip32.private&&o!==i.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var h=r.readUInt32BE(9);if(0===s&&0!==h)throw new Error("Invalid index");var l,d=r.slice(13,45);if(o===i.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var p=BigInteger.fromBuffer(r.slice(46,78));l=new ECPair(p,null,{network:i})}else{var b=u.Point.decodeFrom(f,r.slice(45,78));f.validate(b),l=new ECPair(null,b,{network:i})}var y=new HDNode(l,d);return y.depth=s,y.index=h,y.parentFingerprint=a,y},HDNode.prototype.getAddress=function(){return this.keyPair.getAddress()},HDNode.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},HDNode.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},HDNode.prototype.getNetwork=function(){return this.keyPair.getNetwork()},HDNode.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},HDNode.prototype.neutered=function(){var t=new HDNode(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return t.depth=this.depth,t.index=this.index,t.parentFingerprint=this.parentFingerprint,t},HDNode.prototype.sign=function(t){return this.keyPair.sign(t)},HDNode.prototype.verify=function(t,e){return this.keyPair.verify(t,e)},HDNode.prototype.toBase58=function(t){if(void 0!==t)throw new TypeError("Unsupported argument in 2.0.0");var e=this.keyPair.network,r=this.isNeutered()?e.bip32.public:e.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},HDNode.prototype.derive=function(t){s(a.UInt32,t);var e=t>=HDNode.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(e){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(t,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(t,33);var n,i=o("sha512",this.chainCode).update(r).digest(),c=i.slice(0,32),u=i.slice(32),h=BigInteger.fromBuffer(c);if(h.compareTo(f.n)>=0)return this.derive(t+1);if(this.isNeutered()){var l=f.G.multiply(h).add(this.keyPair.Q);if(f.isInfinity(l))return this.derive(t+1);n=new ECPair(null,l,{network:this.keyPair.network})}else{var d=h.add(this.keyPair.d).mod(f.n);if(0===d.signum())return this.derive(t+1);n=new ECPair(d,null,{network:this.keyPair.network})}var p=new HDNode(n,u);return p.depth=this.depth+1,p.index=t,p.parentFingerprint=this.getFingerprint().readUInt32BE(0),p},HDNode.prototype.deriveHardened=function(t){return s(a.UInt31,t),this.derive(t+HDNode.HIGHEST_BIT)},HDNode.prototype.isNeutered=function(){return!this.keyPair.d},HDNode.prototype.derivePath=function(t){s(a.BIP32Path,t);var e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new Error("Not a master node");e=e.slice(1)}return e.reduce(function(t,e){var r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))},this)},e.exports=HDNode},{"./crypto":44,"./ecpair":46,"./networks":50,"./types":77,bigi:32,bs58check:106,"create-hmac":120,ecurve:199,"safe-buffer":321,typeforce:351}],49:[function(t,e,r){e.exports={Block:t("./block"),ECPair:t("./ecpair"),ECSignature:t("./ecsignature"),HDNode:t("./hdnode"),Transaction:t("./transaction"),TransactionBuilder:t("./transaction_builder"),address:t("./address"),bufferutils:t("./bufferutils"),crypto:t("./crypto"),networks:t("./networks"),opcodes:t("bitcoin-ops"),script:t("./script")}},{"./address":41,"./block":42,"./bufferutils":43,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./hdnode":48,"./networks":50,"./script":51,"./transaction":75,"./transaction_builder":76,"bitcoin-ops":39}],50:[function(t,e,r){e.exports={bitcoincashregtest:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchreg",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoincash:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:76067358,private:76066276},cashAddrPrefix:"bitcoincash",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:0,scriptHash:5,wif:128},bitcoincashtestnet:{messagePrefix:"Bitcoin Signed Message:\n",bip32:{public:70617039,private:70615956},cashAddrPrefix:"bchtest",cashAddrTypes:{pubkeyhash:0,scripthash:1},pubKeyHash:111,scriptHash:196,wif:239},bitcoingold:{messagePrefix:"Bitcoin Gold Signed Message:\n",bip32:{public:76067358,private:76066276},pubKeyHash:38,scriptHash:23,wif:128},bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},{}],51:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=t("pushdata-bitcoin"),o=t("typeforce"),s=t("./types"),a=t("./script_number"),c=t("bitcoin-ops"),u=t("bitcoin-ops/map"),f=c.OP_RESERVED;function h(t){return s.Buffer(t)||function(t){return s.Number(t)&&(t===c.OP_0||t>=c.OP_1&&t<=c.OP_16||t===c.OP_1NEGATE)}(t)}function l(t){return s.Array(t)&&t.every(h)}function d(t){return 0===t.length?c.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?c.OP_1NEGATE:void 0:void 0}function p(t){if(Buffer.isBuffer(t))return t;o(s.Array,t);var e=t.reduce(function(t,e){return Buffer.isBuffer(e)?1===e.length&&void 0!==d(e)?t+1:t+i.encodingLength(e.length)+e.length:t+1},0),r=Buffer.allocUnsafe(e),n=0;if(t.forEach(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0!==e)return r.writeUInt8(e,n),void(n+=1);n+=i.encode(r,t.length,n),t.copy(r,n),n+=t.length}else r.writeUInt8(t,n),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(s.Array(t))return t;o(s.Buffer,t);for(var e=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var a=i.decode(t,r);if(null===a)return[];if((r+=a.size)+a.number>t.length)return[];var u=t.slice(r,r+a.number);r+=a.number;var f=d(u);void 0!==f?e.push(f):e.push(u)}else e.push(n),r+=1}return e}function y(t){var e=-193&t;return e>0&&e<4}e.exports={compile:p,decompile:b,fromASM:function(asm){return o(s.String,asm),p(asm.split(" ").map(function(t){return void 0!==c[t]?c[t]:(o(s.Hex,t),Buffer.from(t,"hex"))}))},toASM:function(t){return Buffer.isBuffer(t)&&(t=b(t)),t.map(function(t){if(Buffer.isBuffer(t)){var e=d(t);if(void 0===e)return t.toString("hex");t=e}return u[t]}).join(" ")},toStack:function(t){return t=b(t),o(l,t),t.map(function(t){return Buffer.isBuffer(t)?t:t===c.OP_0?Buffer.allocUnsafe(0):a.encode(t-f)})},number:t("./script_number"),isCanonicalPubKey:function(t){if(!Buffer.isBuffer(t))return!1;if(t.length<33)return!1;switch(t[0]){case 2:case 3:return 33===t.length;case 4:return 65===t.length}return!1},isCanonicalSignature:function(t){return!!Buffer.isBuffer(t)&&!!y(t[t.length-1])&&n.check(t.slice(0,-1))},isPushOnly:l,isDefinedHashType:y};var m=t("./templates");for(var v in m)e.exports[v]=m[v]},{"./script_number":52,"./templates":53,"./types":77,bip66:38,"bitcoin-ops":39,"bitcoin-ops/map":40,"pushdata-bitcoin":298,"safe-buffer":321,typeforce:351}],52:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;e.exports={decode:function(t,e,r){e=e||4,r=void 0===r||r;var n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&0==(127&t[n-1])&&(n<=1||0==(128&t[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=t.readUInt32LE(0),o=t.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),n=Buffer.allocUnsafe(r),i=t<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},{"safe-buffer":321}],53:[function(t,e,r){var n=t("../script").decompile,i=t("./multisig"),o=t("./nulldata"),s=t("./pubkey"),a=t("./pubkeyhash"),c=t("./scripthash"),u=t("./witnesspubkeyhash"),f=t("./witnessscripthash"),h=t("./witnesscommitment"),l={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(t,e){var r=n(t);return a.input.check(r)?l.P2PKH:i.input.check(r,e)?l.MULTISIG:c.input.check(r,e)?l.P2SH:s.input.check(r)?l.P2PK:l.NONSTANDARD},classifyOutput:function(t){if(u.output.check(t))return l.P2WPKH;if(f.output.check(t))return l.P2WSH;if(a.output.check(t))return l.P2PKH;if(c.output.check(t))return l.P2SH;var e=n(t);return i.output.check(e)?l.MULTISIG:s.output.check(e)?l.P2PK:h.output.check(e)?l.WITNESS_COMMITMENT:o.output.check(e)?l.NULLDATA:l.NONSTANDARD},classifyWitness:function(t,e){var r=n(t);return u.input.check(r)?l.P2WPKH:f.input.check(r,e)?l.P2WSH:l.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:c,witnessPubKeyHash:u,witnessScriptHash:f,witnessCommitment:h,types:l}},{"../script":51,"./multisig":54,"./nulldata":57,"./pubkey":58,"./pubkeyhash":61,"./scripthash":64,"./witnesscommitment":67,"./witnesspubkeyhash":69,"./witnessscripthash":72}],54:[function(t,e,r){e.exports={input:t("./input"),output:t("./output")}},{"./input":55,"./output":56}],55:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){return t===o.OP_0||n.isCanonicalSignature(t)}function a(t,e){var r=n.decompile(t);return!(r.length<2)&&(r[0]===o.OP_0&&(e?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}a.toJSON=function(){return"multisig input"};var c=Buffer.allocUnsafe(0);function u(t,e){if(i([s],t),e){var r=n.multisig.output.decode(e);if(t.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(c,t.map(function(t){return t===o.OP_0?c:t}))}function f(t,e){return i(a,t,e),t.slice(1)}e.exports={check:a,decode:function(t,e){return f(n.decompile(t),e)},decodeStack:f,encode:function(t,e){return n.compile(u(t,e))},encodeStack:u}},{"../../script":51,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],56:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=s.OP_RESERVED;function c(t,e){var r=n.decompile(t);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,c=r[r.length-2]-a;return!(o<=0)&&(!(c>16)&&(!(o>c)&&(c===r.length-3&&(!!e||r.slice(1,-2).every(n.isCanonicalPubKey)))))}c.toJSON=function(){return"multi-sig output"},e.exports={check:c,decode:function(t,e){var r=n.decompile(t);return o(c,r,e),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(t,e){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:t,pubKeys:e});var r=e.length;if(r1&&e[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Buffer,t),n.compile([s.OP_RETURN,t])}}}},{"../script":51,"../types":77,"bitcoin-ops":39,typeforce:351}],58:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":59,"./output":60,dup:54}],59:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 1===e.length&&n.isCanonicalSignature(e[0])}function s(t){return i(n.isCanonicalSignature,t),[t]}function a(t){return i(o,t),t[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t){return n.compile(s(t))},encodeStack:s}},{"../../script":51,typeforce:351}],60:[function(t,e,r){var n=t("../../script"),i=t("typeforce"),o=t("bitcoin-ops");function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalPubKey(e[0])&&e[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(t){var e=n.decompile(t);return i(s,e),e[0]},encode:function(t){return i(n.isCanonicalPubKey,t),n.compile([t,o.OP_CHECKSIG])}}},{"../../script":51,"bitcoin-ops":39,typeforce:351}],61:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":62,"./output":63,dup:54}],62:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&n.isCanonicalPubKey(e[1])}function s(t,e){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:t,pubKey:e}),[t,e]}function a(t){return i(o,t),{signature:t[0],pubKey:t[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(t){return a(n.decompile(t))},decodeStack:a,encode:function(t,e){return n.compile(s(t,e))},encodeStack:s}},{"../../script":51,typeforce:351}],63:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 25===e.length&&e[0]===s.OP_DUP&&e[1]===s.OP_HASH160&&20===e[2]&&e[23]===s.OP_EQUALVERIFY&&e[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(3,23)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_DUP,s.OP_HASH160,t,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],64:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":65,"./output":66,dup:54}],65:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("typeforce");function o(t,e){var r=n.decompile(t);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var o=n.decompile(n.compile(r.slice(0,-1))),s=n.decompile(i);if(0===s.length)return!1;if(!n.isPushOnly(o))return!1;var a=n.classifyInput(o,e),c=n.classifyOutput(s);return 1===r.length?c===n.types.P2WSH||c===n.types.P2WPKH:a===c}function s(t,e){var r=n.compile(e);return[].concat(t,r)}function a(t){return i(o,t),{redeemScriptStack:t.slice(0,-1),redeemScript:t[t.length-1]}}o.toJSON=function(){return"scriptHash input"},e.exports={check:o,decode:function(t){var e=a(n.decompile(t));return e.redeemScriptSig=n.compile(e.redeemScriptStack),delete e.redeemScriptStack,e},decodeStack:a,encode:function(t,e){var r=n.decompile(t);return n.compile(s(r,e))},encodeStack:s}},{"../../script":51,"safe-buffer":321,typeforce:351}],66:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 23===e.length&&e[0]===s.OP_HASH160&&20===e[1]&&e[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2,22)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_HASH160,t,s.OP_EQUAL])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],67:[function(t,e,r){e.exports={output:t("./output")}},{"./output":68}],68:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops"),a=Buffer.from("aa21a9ed","hex");function c(t){var e=n.compile(t);return e.length>37&&e[0]===s.OP_RETURN&&36===e[1]&&e.slice(2,6).equals(a)}c.toJSON=function(){return"Witness commitment output"},e.exports={check:c,decode:function(t){return o(c,t),n.decompile(t)[1].slice(4,36)},encode:function(t){o(i.Hash256bit,t);var e=Buffer.allocUnsafe(36);return a.copy(e,0),t.copy(e,4),n.compile([s.OP_RETURN,e])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,"safe-buffer":321,typeforce:351}],69:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":70,"./output":71,dup:54}],70:[function(t,e,r){var n=t("../../script"),i=t("typeforce");function o(t){return n.isCanonicalPubKey(t)&&33===t.length}function s(t){var e=n.decompile(t);return 2===e.length&&n.isCanonicalSignature(e[0])&&o(e[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(t){return i(s,t),{signature:t[0],pubKey:t[1]}},encodeStack:function(t,e){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:t,pubKey:e}),[t,e]}}},{"../../script":51,typeforce:351}],71:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 22===e.length&&e[0]===s.OP_0&&20===e[1]}a.toJSON=function(){return"Witness pubKeyHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash160bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],72:[function(t,e,r){arguments[4][54][0].apply(r,arguments)},{"./input":73,"./output":74,dup:54}],73:[function(t,e,r){var n=t("../scripthash/input");e.exports={check:n.check,decodeStack:n.decodeStack,encodeStack:n.encodeStack}},{"../scripthash/input":65}],74:[function(t,e,r){var n=t("../../script"),i=t("../../types"),o=t("typeforce"),s=t("bitcoin-ops");function a(t){var e=n.compile(t);return 34===e.length&&e[0]===s.OP_0&&32===e[1]}a.toJSON=function(){return"Witness scriptHash output"},e.exports={check:a,decode:function(t){return o(a,t),t.slice(2)},encode:function(t){return o(i.Hash256bit,t),n.compile([s.OP_0,t])}}},{"../../script":51,"../../types":77,"bitcoin-ops":39,typeforce:351}],75:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./crypto"),o=t("./script"),s=t("./bufferutils"),a=t("bitcoin-ops"),c=t("typeforce"),u=t("./types"),f=t("varuint-bitcoin");function h(t){var e=t.length;return f.encodingLength(e)+e}function l(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}l.DEFAULT_SEQUENCE=4294967295,l.SIGHASH_ALL=1,l.SIGHASH_NONE=2,l.SIGHASH_SINGLE=3,l.SIGHASH_ANYONECANPAY=128,l.SIGHASH_BITCOINCASHBIP143=64,l.ADVANCED_TRANSACTION_MARKER=0,l.ADVANCED_TRANSACTION_FLAG=1,l.FORKID_BTG=79,l.FORKID_BCH=0;var d=Buffer.allocUnsafe(0),p=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),y=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=Buffer.from("ffffffffffffffff","hex"),v={script:d,valueBuffer:m};l.fromBuffer=function(t,e){var r=0;function n(e){return r+=e,t.slice(r-e,r)}function i(){var e=t.readUInt32LE(r);return r+=4,e}function o(){var e=s.readUInt64LE(t,r);return r+=8,e}function a(){var e=f.decode(t,r);return r+=f.decode.bytes,e}function c(){return n(a())}function u(){for(var t=a(),e=[],r=0;r=this.ins.length)return y;var n=o.compile(o.decompile(e).filter(function(t){return t!==a.OP_CODESEPARATOR})),s=this.clone();if((31&r)===l.SIGHASH_NONE)s.outs=[],s.ins.forEach(function(e,r){r!==t&&(e.sequence=0)});else if((31&r)===l.SIGHASH_SINGLE){if(t>=this.outs.length)return y;s.outs.length=t+1;for(var f=0;f0;if(s&&(o|=l.FORKID_BTG<<8),i||s){if(u.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(t,e,r,o)}return this.hashForSignature(t,e,o)},l.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},l.prototype.getId=function(){return n(this.getHash()).toString("hex")},l.prototype.toBuffer=function(t,e){return this.__toBuffer(t,e,!0)},l.prototype.__toBuffer=function(t,e,r){t||(t=Buffer.allocUnsafe(this.__byteLength(r)));var n,i=e||0;function o(e){i+=e.copy(t,i)}function a(e){i=t.writeUInt8(e,i)}function c(e){i=t.writeUInt32LE(e,i)}function u(e){f.encode(e,t,i),i+=f.encode.bytes}function h(t){u(t.length),o(t)}n=this.version,i=t.writeInt32LE(n,i);var d=r&&this.hasWitnesses();return d&&(a(l.ADVANCED_TRANSACTION_MARKER),a(l.ADVANCED_TRANSACTION_FLAG)),u(this.ins.length),this.ins.forEach(function(t){o(t.hash),c(t.index),h(t.script),c(t.sequence)}),u(this.outs.length),this.outs.forEach(function(e){var r;e.valueBuffer?o(e.valueBuffer):(r=e.value,i=s.writeUInt64LE(t,r,i)),h(e.script)}),d&&this.ins.forEach(function(t){var e;u((e=t.witness).length),e.forEach(h)}),c(this.locktime),void 0!==e?t.slice(e,i):t},l.prototype.toHex=function(){return this.toBuffer().toString("hex")},l.prototype.setInputScript=function(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e},l.prototype.setWitness=function(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e},e.exports=l},{"./bufferutils":43,"./crypto":44,"./script":51,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351,"varuint-bitcoin":357}],76:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-reverse"),i=t("./address"),o=t("./crypto"),s=t("./script"),a=t("./networks"),c=t("bitcoin-ops"),u=t("typeforce"),f=t("./types"),h=s.types,l=[s.types.P2PKH,s.types.P2PK,s.types.MULTISIG],d=l.concat([s.types.P2WPKH,s.types.P2WSH]),ECPair=t("./ecpair"),p=t("./ecsignature"),b=t("./transaction");function y(t){return-1!==l.indexOf(t)}function m(t){return-1!==d.indexOf(t)}function v(t,e){if(0===t.length&&0===e.length)return{};var r,n,i,a,c,u,f,l,d,p,b=!1,v=!1,g=!1,w=s.decompile(t);s.classifyInput(w,!0)===h.P2SH&&(g=!0,c=w[w.length-1],l=s.classifyOutput(c),r=s.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,a=c);var _=s.classifyWitness(e,!0);if(_===h.P2WSH){if(u=e[e.length-1],f=s.classifyOutput(u),v=!0,b=!0,0===t.length){if(r=s.witnessScriptHash.output.encode(o.sha256(u)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=s.witnessScriptHash.output.encode(o.sha256(u)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!y(s.classifyOutput(u)))throw new Error("unsupported witness script");a=u,i=f,p=e.slice(0,-1)}else if(_===h.P2WPKH){b=!0;var E=e[e.length-1],S=o.hash160(E);if(0===t.length){if(r=s.witnessPubKeyHash.output.encode(S),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=s.witnessPubKeyHash.output.encode(S),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,p=e}else if(c){if(!m(l))throw new Error("Bad redeemscript!");a=c,i=l,p=w.slice(0,-1)}else n=i=s.classifyInput(t),p=w;var k=function(t,e,r){var n=[],i=[];switch(t){case h.P2PKH:n=e.slice(1),i=e.slice(0,1);break;case h.P2PK:n[0]=r?s.pubKey.output.decode(r):void 0,i=e.slice(0,1);break;case h.MULTISIG:r&&(n=s.multisig.output.decode(r).pubKeys),i=e.slice(1).map(function(t){return 0===t.length?void 0:t})}return{pubKeys:n,signatures:i}}(i,p,a),A={pubKeys:k.pubKeys,signatures:k.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:a,witness:Boolean(b)};return g&&(A.redeemScript=c,A.redeemScriptType=l),v&&(A.witnessScript=u,A.witnessScriptType=f),A}function g(t,e,r){u(f.Buffer,t);var n=s.decompile(t);e||(e=s.classifyOutput(t));var i=[];switch(e){case h.P2PKH:if(!r)break;var a=n[2],c=o.hash160(r);a.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var l=n[1],d=o.hash160(r);l.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:e}}return{pubKeys:i,scriptType:e,signatures:i.map(function(){})}}function w(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent hash160(RedeemScript)")}}function _(t,e,r,n,i){var a,c,l,d,p,b,y,m,v,_=!1,E=!1,S=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),w(t,p),!r.equals(s.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=E=S=!0,d=s.types.P2WSH,m=b=a.scriptType,v=i}else if(r){if(w(t,p=o.hash160(r)),!(a=g(r,void 0,e)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=s.types.P2SH,l=s.scriptHash.output.encode(p),_=!0,v=r,E=(m=d=a.scriptType)===s.types.P2WPKH}else if(i){if(function(t,e){if(t.prevOutType){if(t.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(t.prevOutScript)[1].equals(e))throw new Error("Inconsistent sha25(WitnessScript)")}}(t,y=o.sha256(i)),!(a=g(i,void 0,e)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=s.types.P2WSH,l=s.witnessScriptHash.output.encode(y),E=S=!0,m=b=a.scriptType,v=i}else if(t.prevOutType){if(t.prevOutType===h.P2SH||t.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+t.prevOutType+", requires redeemScript");if(c=t.prevOutType,l=t.prevOutScript,!(a=g(t.prevOutScript,t.prevOutType,e)).pubKeys)return;E=t.prevOutType===h.P2WPKH,m=c,v=l}else a=g(l=s.pubKeyHash.output.encode(o.hash160(e)),h.P2PKH,e),E=!1,m=c=h.P2PKH,v=l;if(void 0!==n||E){if(u(f.Satoshi,n),void 0!==t.value&&t.value!==n)throw new Error("Input didn't match witnessValue");t.value=n}m===h.P2WPKH&&(v=s.pubKeyHash.output.encode(s.witnessPubKeyHash.output.decode(v))),_&&(t.redeemScript=r,t.redeemScriptType=d),S&&(t.witnessScript=i,t.witnessScriptType=b),t.pubKeys=a.pubKeys,t.signatures=a.signatures,t.signScript=v,t.signType=m,t.prevOutScript=l,t.prevOutType=c,t.witness=E}function E(t,e,r,n){if(t===h.P2PKH){if(1===e.length&&Buffer.isBuffer(e[0])&&1===r.length)return s.pubKeyHash.input.encodeStack(e[0],r[0])}else if(t===h.P2PK){if(1===e.length&&Buffer.isBuffer(e[0]))return s.pubKey.input.encodeStack(e[0])}else{if(t!==h.MULTISIG)throw new Error("Not yet supported");if(e.length>0)return e=e.map(function(t){return t||c.OP_0}),n||(e=e.filter(function(t){return t!==c.OP_0})),s.multisig.input.encodeStack(e)}if(!n)throw new Error("Not enough signatures provided");return[]}function S(t,e){this.prevTxMap={},this.network=t||a.bitcoin,this.maximumFeeRate=e||1e3,this.inputs=[],this.bitcoinCash=!1,this.bitcoinGold=!1,this.tx=new b}function k(t){return void 0!==t.prevOutScript&&void 0!==t.signScript&&void 0!==t.pubKeys&&void 0!==t.signatures&&t.signatures.length===t.pubKeys.length&&t.pubKeys.length>0&&void 0!==t.witness}function A(t){return t.readUInt8(t.length-1)}S.prototype.enableBitcoinCash=function(t){void 0===t&&(t=!0),this.bitcoinCash=t},S.prototype.enableBitcoinGold=function(t){void 0===t&&(t=!0),this.bitcoinGold=t},S.prototype.setLockTime=function(t){if(u(f.UInt32,t),this.inputs.some(function(t){return!!t.signatures&&t.signatures.some(function(t){return t})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=t},S.prototype.setVersion=function(t){u(f.UInt32,t),this.tx.version=t},S.fromTransaction=function(t,e,r){var n=new S(e);return"number"==typeof r&&(r===b.FORKID_BTG?n.enableBitcoinGold(!0):r===b.FORKID_BCH&&n.enableBitcoinCash(!0)),n.setVersion(t.version),n.setLockTime(t.locktime),t.outs.forEach(function(t){n.addOutput(t.script,t.value)}),t.ins.forEach(function(t){n.__addInputUnsafe(t.hash,t.index,{sequence:t.sequence,script:t.script,witness:t.witness,value:t.value})}),n.inputs.forEach(function(e,n){!function(t,e,r,n,i){if(t.signType===h.MULTISIG&&t.signScript&&t.pubKeys.length!==t.signatures.length){var o=t.signatures.concat();t.signatures=t.pubKeys.map(function(s){var a,c=ECPair.fromPublicKeyBuffer(s);return o.some(function(s,u){if(!s)return!1;var f,h=p.parseScriptSignature(s);switch(i){case b.FORKID_BCH:f=e.hashForCashSignature(r,t.signScript,n,h.hashType);break;case b.FORKID_BTG:f=e.hashForGoldSignature(r,t.signScript,n,h.hashType);break;default:f=t.witness?e.hashForWitnessV0(r,t.signScript,n,h.hashType):e.hashForSignature(r,t.signScript,h.hashType)}return!!c.verify(f,h.signature)&&(o[u]=void 0,a=s,!0)}),a})}}(e,t,n,e.value,r)}),n},S.prototype.addInput=function(t,e,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof t)t=n(Buffer.from(t,"hex"));else if(t instanceof b){var s=t.outs[e];i=s.script,o=s.value,t=t.getHash()}return this.__addInputUnsafe(t,e,{sequence:r,prevOutScript:i,value:o})},S.prototype.__addInputUnsafe=function(t,e,r){if(b.isCoinbaseHash(t))throw new Error("coinbase inputs not supported");var n=t.toString("hex")+":"+e;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=v(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var a=g(r.prevOutScript);a.pubKeys&&(i.pubKeys=a.pubKeys,i.signatures=a.signatures),o=a.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||s.classifyOutput(r.prevOutScript)}var c=this.tx.addInput(t,e,r.sequence,r.scriptSig);return this.inputs[c]=i,this.prevTxMap[n]=c,c},S.prototype.addOutput=function(t,e){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof t&&(t=i.toOutputScript(t,this.network)),this.tx.addOutput(t,e)},S.prototype.build=function(){return this.__build(!1)},S.prototype.buildIncomplete=function(){return this.__build(!0)},S.prototype.__build=function(t){if(!t){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var e=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!t)throw new Error("Transaction is not complete");var i=function(t,e){var r=t.prevOutType,n=[],i=[];y(r)&&(n=E(r,t.signatures,t.pubKeys,e));var o=!1;if(r===s.types.P2SH){if(!e&&!m(t.redeemScriptType))throw new Error("Impossible to sign this type");y(t.redeemScriptType)&&(n=E(t.redeemScriptType,t.signatures,t.pubKeys,e)),t.redeemScriptType&&(o=!0,r=t.redeemScriptType)}switch(r){case s.types.P2WPKH:i=E(s.types.P2PKH,t.signatures,t.pubKeys,e);break;case s.types.P2WSH:if(!e&&!y(t.witnessScriptType))throw new Error("Impossible to sign this type");y(t.witnessScriptType)&&((i=E(t.witnessScriptType,t.signatures,t.pubKeys,e)).push(t.witnessScript),r=t.witnessScriptType)}return o&&n.push(t.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,t);if(!t&&!y(i.type)&&i.type!==s.types.P2WPKH)throw new Error(i.type+" not supported");e.setInputScript(n,i.script),e.setWitness(n,i.witness)}),!t&&this.__overMaximumFees(e.virtualSize()))throw new Error("Transaction has absurd fees");return e},S.prototype.sign=function(t,e,r,n,i,o){if(e.network!==this.network)throw new Error("Inconsistent network");if(!this.inputs[t])throw new Error("No input at index: "+t);n=n||b.SIGHASH_ALL;var s=this.inputs[t];if(void 0!==s.redeemScript&&r&&!s.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var a,c=e.getPublicKeyBuffer();if(!k(s)&&(_(s,c,r,i,o),!k(s)))throw Error(s.prevOutType+" not supported");if(a=this.bitcoinGold?this.tx.hashForGoldSignature(t,s.signScript,i,n,s.witness):this.bitcoinCash?this.tx.hashForCashSignature(t,s.signScript,i,n):s.witness?this.tx.hashForWitnessV0(t,s.signScript,i,n):this.tx.hashForSignature(t,s.signScript,n),!s.pubKeys.some(function(t,r){if(!c.equals(t))return!1;if(s.signatures[r])throw new Error("Signature already exists");if(!e.compressed&&s.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");return s.signatures[r]=e.sign(a).toScriptSignature(n),!0}))throw new Error("Key pair cannot sign for this input")},S.prototype.__canModifyInputs=function(){return this.inputs.every(function(t){return void 0===t.signatures||t.signatures.every(function(t){return!t||A(t)&b.SIGHASH_ANYONECANPAY})})},S.prototype.__canModifyOutputs=function(){var t=this.tx.ins.length,e=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&A(r);return n===b.SIGHASH_NONE||(n===b.SIGHASH_SINGLE?t<=e:void 0)})})},S.prototype.__overMaximumFees=function(t){return(this.inputs.reduce(function(t,e){return t+(e.value>>>0)},0)-this.tx.outs.reduce(function(t,e){return t+e.value},0))/t>this.maximumFeeRate},e.exports=S},{"./address":41,"./crypto":44,"./ecpair":46,"./ecsignature":47,"./networks":50,"./script":51,"./transaction":75,"./types":77,"bitcoin-ops":39,"buffer-reverse":108,"safe-buffer":321,typeforce:351}],77:[function(t,e,r){var n=t("typeforce"),i=Math.pow(2,31)-1;function o(t){return n.String(t)&&t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),c=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),h={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:c,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(t){return n.UInt53(t)&&t<=s},UInt31:function(t){return n.UInt32(t)&&t<=i}};for(var l in n)h[l]=n[l];e.exports=h},{typeforce:351}],78:[function(t,e,r){(function(Buffer){(function(){var r=t("bs58check"),n=t("buffer-equals"),i=t("create-hash"),o=t("secp256k1"),s=t("varuint-bitcoin");function a(t,e){var r=s.encodingLength(t.length),n=new Buffer(e.length+r+t.length);return n.write(e,0),s.encode(t.length,n,e.length),n.write(t,e.length+r),function(t){var e=i("sha256").update(t).digest();return i("sha256").update(e).digest()}(n)}e.exports={magicHash:a,sign:function(t,e,r,n){var i=a(t,e),s=o.sign(i,r);return function(t,e,r){return r&&(e+=4),Buffer.concat([new Buffer([e+27]),t])}(s.signature,s.recovery,n)},verify:function(t,e,s,c){Buffer.isBuffer(c)||(c=new Buffer(c,"base64"));var u,f,h=function(t){if(65!==t.length)throw new Error("Invalid signature length");var e=t.readUInt8(0)-27;if(e>7)throw new Error("Invalid signature parameter");return{compressed:!!(4&e),recovery:3&e,signature:t.slice(1)}}(c),l=a(t,e),d=o.recover(l,h.signature,h.recovery,h.compressed),p=(u=d,f=i("sha256").update(u).digest(),i("ripemd160").update(f).digest()),b=r.decode(s).slice(1);return n(p,b)}}}).call(this)}).call(this,t("buffer").Buffer)},{bs58check:81,buffer:110,"buffer-equals":107,"create-hash":118,secp256k1:323,"varuint-bitcoin":357}],79:[function(t,e,r){e.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i>=8;for(;c>0;)i.push(255&c),c>>=8}for(var u=0;t[u]===n&&u0;)n.push(s%r),s=s/r|0}for(var a="",c=0;0===e[c]&&c=0;--u)a+=t[n[u]];return a},decodeUnsafe:o,decode:function(t){var e=o(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}},{}],80:[function(t,e,r){var n=t("base-x");e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},{"base-x":79}],81:[function(t,e,r){(function(Buffer){(function(){"use strict";var r=t("bs58"),n=t("create-hash");function i(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}function o(t){var e=t.slice(0,-4),r=t.slice(-4),n=i(e);if(!(r[0]^n[0]|r[1]^n[1]|r[2]^n[2]|r[3]^n[3]))return e}function s(t){var e=r.decodeUnsafe(t);if(e)return o(new Buffer(e))}e.exports={encode:function(t){var e=i(t);return r.encode(Buffer.concat([t,e],t.length+4))},decode:function(t){var e=r.decode(t),n=o(new Buffer(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:s,decodeRaw:s}}).call(this)}).call(this,t("buffer").Buffer)},{bs58:80,buffer:110,"create-hash":118}],82:[function(t,e,r){!function(e,r){"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 Buffer;"object"==typeof e?e.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{Buffer="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:t("buffer").Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+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=f[t],d=h[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(d).toString(t);r=(p=p.idivn(d)).isZero()?b+r:u[l-b.length]+b+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!==Buffer),this.toArrayLike(Buffer,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,a,c="le"===e,u=new t(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a=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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function p(t,e,r){return(new b).mulp(t,e,r)}function b(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>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},b.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},b.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=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>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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,a},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 E(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function m(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function g(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},m.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},m.prototype.split=function(t,e){t.iushrn(this.n,0,e)},m.prototype.imulK=function(t){return t.imul(this.k)},i(v,m),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new g;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return y[t]=e,e},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},i(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],83:[function(t,e,r){var n;function i(t){this.rand=t}if(e.exports=function(t){return n||(n=new i(null)),n.generate(t)},e.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r>>24]^f[p>>>16&255]^h[b>>>8&255]^l[255&y]^e[m++],s=u[p>>>24]^f[b>>>16&255]^h[y>>>8&255]^l[255&d]^e[m++],a=u[b>>>24]^f[y>>>16&255]^h[d>>>8&255]^l[255&p]^e[m++],c=u[y>>>24]^f[d>>>16&255]^h[p>>>8&255]^l[255&b]^e[m++],d=o,p=s,b=a,y=c;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&y])^e[m++],s=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^e[m++],a=(n[b>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^e[m++],c=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[m++],[o>>>=0,s>>>=0,a>>>=0,c>>>=0]}var s=[0,1,2,4,8,16,32,64,128,27,54],a=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],s=0,a=0,c=0;c<256;++c){var u=a^a<<1^a<<2^a<<3^a<<4;u=u>>>8^255&u^99,r[s]=u,n[u]=s;var f=t[s],h=t[f],l=t[h],d=257*t[u]^16843008*u;i[0][s]=d<<24|d>>>8,i[1][s]=d<<16|d>>>16,i[2][s]=d<<8|d>>>24,i[3][s]=d,d=16843009*l^65537*h^257*f^16843008*s,o[0][u]=d<<24|d>>>8,o[1][u]=d<<16|d>>>16,o[2][u]=d<<8|d>>>24,o[3][u]=d,0===s?s=a=1:(s=f^t[t[t[l^f]]],a^=t[t[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(t){this._key=n(t),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o>>24,c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c],c^=s[o/e|0]<<24):e>6&&o%e==4&&(c=a.SBOX[c>>>24]<<24|a.SBOX[c>>>16&255]<<16|a.SBOX[c>>>8&255]<<8|a.SBOX[255&c]),i[o]=i[o-e]^c}for(var u=[],f=0;f>>24]]^a.INV_SUB_MIX[1][a.SBOX[l>>>16&255]]^a.INV_SUB_MIX[2][a.SBOX[l>>>8&255]]^a.INV_SUB_MIX[3][a.SBOX[255&l]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u},c.prototype.encryptBlockRaw=function(t){return o(t=n(t),this._keySchedule,a.SUB_MIX,a.SBOX,this._nRounds)},c.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r},c.prototype.decryptBlock=function(t){var e=(t=n(t))[1];t[1]=t[3],t[3]=e;var r=o(t,this._invKeySchedule,a.INV_SUB_MIX,a.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},c.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=c},{"safe-buffer":321}],85:[function(t,e,r){var n=t("./aes"),Buffer=t("safe-buffer").Buffer,i=t("cipher-base"),o=t("inherits"),s=t("./ghash"),a=t("buffer-xor"),c=t("./incr32");function u(t,e,r,o){i.call(this);var a=Buffer.alloc(4,0);this._cipher=new n.AES(e);var u=this._cipher.encryptBlock(a);this._ghash=new s(u),r=function(t,e,r){if(12===e.length)return t._finID=Buffer.concat([e,Buffer.from([0,0,0,1])]),Buffer.concat([e,Buffer.from([0,0,0,2])]);var n=new s(r),i=e.length,o=i%16;n.update(e),o&&(o=16-o,n.update(Buffer.alloc(o,0))),n.update(Buffer.alloc(8,0));var a=8*i,u=Buffer.alloc(8);u.writeUIntBE(a,0,8),n.update(u),t._finID=n.state;var f=Buffer.from(t._finID);return c(f),f}(this,r,u),this._prev=Buffer.from(r),this._cache=Buffer.allocUnsafe(0),this._secCache=Buffer.allocUnsafe(0),this._decrypt=o,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1}o(u,i),u.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=Buffer.alloc(e,0),this._ghash.update(e))}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r},u.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=a(this._ghash.final(8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null},f.prototype.flush=function(){if(this.cache.length)return this.cache},r.createDecipher=function(t,e){var r=i[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=c(e,!1,r.key,r.iv);return h(t,n.key,n.iv)},r.createDecipheriv=h},{"./aes":84,"./authCipher":85,"./modes":97,"./streamCipher":100,"cipher-base":114,evp_bytestokey:218,inherits:258,"safe-buffer":321}],88:[function(t,e,r){var n=t("./modes"),i=t("./authCipher"),Buffer=t("safe-buffer").Buffer,o=t("./streamCipher"),s=t("cipher-base"),a=t("./aes"),c=t("evp_bytestokey");function u(t,e,r){s.call(this),this._cache=new h,this._cipher=new a.AES(e),this._prev=Buffer.from(r),this._mode=t,this._autopadding=!0}t("inherits")(u,s),u.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return Buffer.concat(n)};var f=Buffer.alloc(16,16);function h(){this.cache=Buffer.allocUnsafe(0)}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=Buffer.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new o(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new u(s.module,e,r)}u.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(f))throw this._cipher.scrub(),new Error("data not multiple of block length")},u.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this},h.prototype.add=function(t){this.cache=Buffer.concat([this.cache,t])},h.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t}return null},h.prototype.flush=function(){for(var t=16-this.cache.length,e=Buffer.allocUnsafe(t),r=-1;++r>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e}function o(t){this.h=t,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(t){for(var e=-1;++e0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(t){var e;for(this.cache=Buffer.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e)},o.prototype.final=function(t,e){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,t,0,e])),this.state},e.exports=o},{"safe-buffer":321}],90:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break}t.writeUInt8(0,r)}}},{}],91:[function(t,e,r){var n=t("buffer-xor");r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r)}},{"buffer-xor":109}],92:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("buffer-xor");function i(t,e,r){var i=e.length,o=n(e,t._cache);return t._cache=t._cache.slice(i),t._prev=Buffer.concat([t._prev,r?e:o]),o}r.encrypt=function(t,e,r){for(var n,o=Buffer.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=Buffer.allocUnsafe(0)),!(t._cache.length<=e.length)){o=Buffer.concat([o,i(t,e,r)]);break}n=t._cache.length,o=Buffer.concat([o,i(t,e.slice(0,n),r)]),e=e.slice(n)}return o}},{"buffer-xor":109,"safe-buffer":321}],93:[function(t,e,r){var Buffer=t("safe-buffer").Buffer;function n(t,e,r){for(var n,o,s,a=-1,c=0;++a<8;)n=t._cipher.encryptBlock(t._prev),o=e&1<<7-a?128:0,c+=(128&(s=n[0]^o))>>a%8,t._prev=i(t._prev,r?o:s);return c}function i(t,e){var r=t.length,n=-1,i=Buffer.allocUnsafe(t.length);for(t=Buffer.concat([t,Buffer.from([e])]);++n>7;return i}r.encrypt=function(t,e,r){for(var i=e.length,o=Buffer.allocUnsafe(i),s=-1;++si)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=Buffer.prototype,e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|h(t,e),n=o(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return u(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(D(t,ArrayBuffer)||t&&D(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function h(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||D(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return n?-1:L(t).length;e=(""+e).toLowerCase(),i=!0}}function l(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),U(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:p(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):p(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function p(t,e,r,n,i){var o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function _(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function E(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return E(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return A(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},Buffer.prototype.compare=function(t,e,r,n,i){if(D(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,s=r-e,a=Math.min(o,s),c=this.slice(n,i),u=t.slice(e,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return v(this,t,e,r);case"base64":return g(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function R(t,e,r,i,o){return e=+e,r>>>=0,o||P(t,0,r,8),n.write(t,e,r,i,52,8),r+8}Buffer.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Buffer.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Buffer.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),n.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),n.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n)||I(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o>0)-a&255;return e+r},Buffer.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);I(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},Buffer.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||I(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeFloatLE=function(t,e,r){return B(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function(t,e,r){return B(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},Buffer.prototype.copy=function(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},Buffer.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(C,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function N(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function D(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this)}).call(this,t("buffer").Buffer)},{"base64-js":111,buffer:110,ieee754:257}],111:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],112:[function(t,e,r){"use strict";for(var BigInteger=t("bigi"),n="qpzry9x8gf2tvdw0s3jn54khce6mua7l",i=":",o=8,s={},a=0;a0&&(n=n.xor(BigInteger.fromHex("98f2bc8e61"))),e.and(new BigInteger("2")).intValue()&&(n=n.xor(BigInteger.fromHex("79b76d99e2"))),e.and(new BigInteger("4")).intValue()&&(n=n.xor(BigInteger.fromHex("f33e5fb3c4"))),e.and(new BigInteger("8")).intValue()&&(n=n.xor(BigInteger.fromHex("ae2eabe2a8"))),e.and(new BigInteger("16")).intValue()&&(n=n.xor(BigInteger.fromHex("1e4f43e470"))),n}function f(t){for(var e=new BigInteger("1"),r=0;r=r;)o-=r,a.push(i>>>o&s);if(n)o>0&&a.push(i<=e)throw new Error("Excess padding");if(i<90)throw new TypeError(t+" too long");var e=t.toLowerCase(),r=t.toUpperCase();if(t!==e&&t!==r)throw new Error("Mixed-case string "+t);var n=(t=e).lastIndexOf(i);if(-1===n)throw new Error("No separator character for "+t);if(0===n)throw new Error("Missing prefix for "+t);var a=t.slice(0,n),c=t.slice(n+1);if(c.length<6)throw new Error("Data too short");for(var h=f(a),l=[],d=0;d=c.length||l.push(b)}if("1"!==h.toString(10))throw new Error("Invalid checksum for "+t);return{prefix:a,words:l}},encode:function(t,e){if(t.length+o+1+e.length>90)throw new TypeError("Exceeds Base32 maximum length");for(var r=f(t=t.toLowerCase()),s=t+i,a=0;a>>5!=0)throw new Error("Non 5-bit word");r=u(r).xor(new BigInteger(""+c)),s+=n.charAt(c)}for(var h=0;h>>7;if(1&e||e>0)throw new Error("Invalid version, most significant bit is reserved");var r=a(s,t>>3&15);if(null===r)throw new Error("Invalid script type");var c=parseInt(a(o,7&t),10);if((r===i||r===n)&&160!==c)throw new Error("Mismatch between script type and hash length");return{scriptType:r,hashSize:c}}(c[0]);if(1+u.hashSize/8!==c.length)throw new Error("Hash length does not match version");return{version:u.scriptType,prefix:e.prefix,hash:Buffer.from(c.slice(1))}},encode:function(t,e,n){if(!(n instanceof Buffer))throw new Error("Hash should be passed as a Buffer");if(!(e in s))throw new Error("Unsupported script type");return r.encode(t,r.toWords(c(e,n)))}}}).call(this)}).call(this,t("buffer").Buffer)},{"./base32":112,buffer:110}],114:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("stream").Transform,i=t("string_decoder").StringDecoder;function o(t){n.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}t("inherits")(o,n),o.prototype.update=function(t,e,r){"string"==typeof t&&(t=Buffer.from(t,e));var n=this._update(t);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},o.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},o.prototype._finalOrDigest=function(t){var e=this.__final()||Buffer.alloc(0);return t&&(e=this._toString(e,t,!0)),e},o.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new i(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},e.exports=o},{inherits:258,"safe-buffer":321,stream:238,string_decoder:239}],115:[function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}void 0!==e&&(e.exports=n),n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;ir)?e=("rmd160"===t?new a:c(t)).update(e).digest():e.lengths?e=t(e):e.length>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=t.readUInt8(e),t.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:a.tag[r]}}function h(t,e,r){let n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(let e=0;e=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6}(t,e,r,this.reporter);if(n.length<128){const t=Buffer.alloc(2);return t[0]=i,t[1]=n.length,this._createEncoderBuffer([t,n])}let s=1;for(let t=n.length;t>=256;t>>=8)s++;const a=Buffer.alloc(2+s);a[0]=i,a[1]=128|s;for(let t=1+s,e=n.length;e>0;t--,e>>=8)a[t]=255&e;return this._createEncoderBuffer([a,n])},a.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){const e=Buffer.alloc(2*t.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1])}let n=0;for(let e=0;e=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let e=t.length-1;e>=0;e--){let r=t[e];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},a.prototype._encodeTime=function(t,e){let r;const n=new Date(t);return"gentime"===e?r=[c(n.getUTCFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[c(n.getUTCFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr")},a.prototype._encodeNull=function(){return this._createEncoderBuffer("")},a.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t]}if("number"!=typeof t&&!Buffer.isBuffer(t)){const e=t.toArray();!t.sign&&128&e[0]&&e.unshift(0),t=Buffer.from(e)}if(Buffer.isBuffer(t)){let e=t.length;0===t.length&&e++;const r=Buffer.alloc(e);return t.copy(r),0===t.length&&(r[0]=0),this._createEncoderBuffer(r)}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);let r=1;for(let e=t;e>=256;e>>=8)r++;const n=new Array(r);for(let e=n.length-1;e>=0;e--)n[e]=255&t,t>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},a.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0)},a.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree},a.prototype._skipDefault=function(t,e,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=t.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,e,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function c(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),c=e;c=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&s0?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++,this.negative=1),i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n=e;n-=2)i=a(t,e,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;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,a=Math.min(o,o-s)+r,u=0,f=r;f1&&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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(t){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}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"],l=[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];o.prototype.toString=function(t,e){var r;if(t=t||10,e=0|e||1,16===t||"hex"===t){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-c.length]+c+r:c+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 u=l[t],f=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modrn(f).toString(t);r=(p=p.idivn(f)).isZero()?b+r:h[u-b.length]+b+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,2)},Buffer&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(Buffer,t,e)}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function p(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,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,l=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=l;d++){var p=u-d|0;f+=(s=(i=0|t.words[p])*(o=0|e.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}o.prototype.toArrayLike=function(t,e,r){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},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;et.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;rt.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;nt.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;i0&&(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<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.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>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,b=d>>>13,y=0|s[2],m=8191&y,v=y>>>13,g=0|s[3],w=8191&g,_=g>>>13,E=0|s[4],S=8191&E,k=E>>>13,A=0|s[5],x=8191&A,M=A>>>13,T=0|s[6],I=8191&T,P=T>>>13,B=0|s[7],R=8191&B,C=B>>>13,O=0|s[8],L=8191&O,j=O>>>13,N=0|s[9],D=8191&N,U=N>>>13,K=0|a[0],H=8191&K,q=K>>>13,z=0|a[1],F=8191&z,W=z>>>13,V=0|a[2],G=8191&V,Y=V>>>13,J=0|a[3],Z=8191&J,X=J>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,lt=ft>>>13,dt=0|a[9],pt=8191&dt,bt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var yt=(u+(n=Math.imul(h,H))|0)+((8191&(i=(i=Math.imul(h,q))+Math.imul(l,H)|0))<<13)|0;u=((o=Math.imul(l,q))+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(b,H)|0,o=Math.imul(b,q);var mt=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,F)|0))<<13)|0;u=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(v,H)|0,o=Math.imul(v,q),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,o=o+Math.imul(b,W)|0;var vt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(l,G)|0))<<13)|0;u=((o=o+Math.imul(l,Y)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(v,F)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var gt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;u=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(k,H)|0,o=Math.imul(k,q),n=n+Math.imul(w,F)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,G)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,Y)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,X)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(l,Q)|0))<<13)|0;u=((o=o+Math.imul(l,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(x,H),i=(i=Math.imul(x,q))+Math.imul(M,H)|0,o=Math.imul(M,q),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(v,Z)|0,o=o+Math.imul(v,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(l,rt)|0))<<13)|0;u=((o=o+Math.imul(l,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(I,H),i=(i=Math.imul(I,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(x,F)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(v,Q)|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(b,rt)|0,o=o+Math.imul(b,nt)|0;var Et=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(l,ot)|0))<<13)|0;u=((o=o+Math.imul(l,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(P,F)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,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(b,ot)|0,o=o+Math.imul(b,st)|0;var St=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(l,ct)|0))<<13)|0;u=((o=o+Math.imul(l,ut)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,H),i=(i=Math.imul(L,q))+Math.imul(j,H)|0,o=Math.imul(j,q),n=n+Math.imul(R,F)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(I,G)|0,i=(i=i+Math.imul(I,Y)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ut)|0;var kt=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,lt)|0)+Math.imul(l,ht)|0))<<13)|0;u=((o=o+Math.imul(l,lt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,H),i=(i=Math.imul(D,q))+Math.imul(U,H)|0,o=Math.imul(U,q),n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(j,F)|0,o=o+Math.imul(j,W)|0,n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(C,G)|0,o=o+Math.imul(C,Y)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ct)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(v,ct)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0;var At=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(l,pt)|0))<<13)|0;u=((o=o+Math.imul(l,bt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(U,F)|0,o=Math.imul(U,W),n=n+Math.imul(L,G)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(j,G)|0,o=o+Math.imul(j,Y)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,st)|0,n=n+Math.imul(w,ct)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0;var xt=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,G),i=(i=Math.imul(D,Y))+Math.imul(U,G)|0,o=Math.imul(U,Y),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,Z)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,lt)|0;var Mt=(u+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,bt)|0)+Math.imul(v,pt)|0))<<13)|0;u=((o=o+Math.imul(v,bt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0;var Tt=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,tt))+Math.imul(U,Q)|0,o=Math.imul(U,tt),n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(j,rt)|0,o=o+Math.imul(j,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,lt)|0)+Math.imul(M,ht)|0,o=o+Math.imul(M,lt)|0;var It=(u+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(j,ot)|0,o=o+Math.imul(j,st)|0,n=n+Math.imul(R,ct)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0;var Pt=(u+(n=n+Math.imul(x,pt)|0)|0)+((8191&(i=(i=i+Math.imul(x,bt)|0)+Math.imul(M,pt)|0))<<13)|0;u=((o=o+Math.imul(M,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ut)|0)+Math.imul(j,ct)|0,o=o+Math.imul(j,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0;var Bt=(u+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,bt)|0)+Math.imul(P,pt)|0))<<13)|0;u=((o=o+Math.imul(P,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(D,ct),i=(i=Math.imul(D,ut))+Math.imul(U,ct)|0,o=Math.imul(U,ut),n=n+Math.imul(L,ht)|0,i=(i=i+Math.imul(L,lt)|0)+Math.imul(j,ht)|0,o=o+Math.imul(j,lt)|0;var Rt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(C,pt)|0))<<13)|0;u=((o=o+Math.imul(C,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ht),i=(i=Math.imul(D,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt);var Ct=(u+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,bt)|0)+Math.imul(j,pt)|0))<<13)|0;u=((o=o+Math.imul(j,bt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Ot=(u+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,bt))+Math.imul(U,pt)|0))<<13)|0;return u=((o=Math.imul(U,bt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,c[0]=yt,c[1]=mt,c[2]=vt,c[3]=gt,c[4]=wt,c[5]=_t,c[6]=Et,c[7]=St,c[8]=kt,c[9]=At,c[10]=xt,c[11]=Mt,c[12]=Tt,c[13]=It,c[14]=Pt,c[15]=Bt,c[16]=Rt,c[17]=Ct,c[18]=Ot,0!==u&&(c[19]=u,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(t,e,r){return y(t,e,r)}function v(t,e){this.x=t,this.y=e}Math.imul||(b=p),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?b(this,t,e):r<63?p(this,t,e):r<1024?y(this,t,e):m(this,t,e)},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},v.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,r+=o/67108864|0,r+=s>>>26,this.words[i]=67108863&s}return 0!==r&&(this.words[i]=r,this.length++),e?this.ineg():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>>i&1}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=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>>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=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),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<=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<=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>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this._strip();for(n(-1===a),a=0,i=0;i>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 a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var l=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,h);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=l)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||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?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},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.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t}return this._strip(),e?this.ineg():this},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),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=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(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},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),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,l=1;0==(r.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).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<>>26,a&=67108863,this.words[s]=a}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:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(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 A(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 red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function w(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function _(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function E(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){A.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},i(_,w),_.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},_.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new _;else if("p224"===t)e=new E;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return g[t]=e,e},A.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},A.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),l=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var b=d,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new x(t)},i(x,A),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},x.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},x.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)},{buffer:219}],139:[function(t,e,r){(function(Buffer){(function(){var r=t("bn.js"),n=t("randombytes");function i(t){var e,i=t.modulus.byteLength();do{e=new r(n(i))}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e}function o(t,e){var n=function(t){var e=i(t);return{blinder:e.toRed(r.mont(t.modulus)).redPow(new r(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)}}(e),o=e.modulus.byteLength(),s=new r(t).mul(n.blinder).umod(e.modulus),a=s.toRed(r.mont(e.prime1)),c=s.toRed(r.mont(e.prime2)),u=e.coefficient,f=e.prime1,h=e.prime2,l=a.redPow(e.exponent1).fromRed(),d=c.redPow(e.exponent2).fromRed(),p=l.isub(d).imul(u).umod(f).imul(h);return d.iadd(p).imul(n.unblinder).umod(e.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"bn.js":138,buffer:110,randombytes:303}],140:[function(t,e,r){e.exports=t("./browser/algorithms.json")},{"./browser/algorithms.json":141}],141:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}}},{}],142:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"}},{}],143:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("readable-stream"),o=t("inherits"),s=t("./sign"),a=t("./verify"),c=t("./algorithms.json");function u(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function f(t){i.Writable.call(this);var e=c[t];if(!e)throw new Error("Unknown message digest");this._hash=n(e.hash),this._tag=e.id,this._signType=e.sign}function h(t){return new u(t)}function l(t){return new f(t)}Object.keys(c).forEach(function(t){c[t].id=Buffer.from(c[t].id,"hex"),c[t.toLowerCase()]=c[t]}),o(u,i.Writable),u.prototype._write=function(t,e,r){this._hash.update(t),r()},u.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},u.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n},o(f,i.Writable),f.prototype._write=function(t,e,r){this._hash.update(t),r()},f.prototype.update=function(t,e){return"string"==typeof t&&(t=Buffer.from(t,e)),this._hash.update(t),this},f.prototype.verify=function(t,e,r){"string"==typeof e&&(e=Buffer.from(e,r)),this.end();var n=this._hash.digest();return a(e,n,t,this._signType,this._tag)},e.exports={Sign:h,Verify:l,createSign:h,createVerify:l}},{"./algorithms.json":141,"./sign":144,"./verify":145,"create-hash":118,inherits:258,"readable-stream":319,"safe-buffer":321}],144:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("create-hmac"),i=t("browserify-rsa"),o=t("elliptic").ec,s=t("bn.js"),a=t("parse-asn1"),c=t("./curves.json");function u(t,e,r,i){if((t=Buffer.from(t.toArray())).length0&&r.ishrn(n),r}function h(t,e,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=e)throw new Error("invalid sig")}e.exports=function(t,e,r,c,u){var f=o(r);if("ec"===f.type){if("ecdsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),a=r.data.subjectPrivateKey.data;return o.verify(e,t,a)}(t,e,f)}if("dsa"===f.type){if("dsa"!==c)throw new Error("wrong public key type");return function(t,e,r){var i=r.data.p,s=r.data.q,c=r.data.g,u=r.data.pub_key,f=o.signature.decode(t,"der"),h=f.s,l=f.r;a(h,s),a(l,s);var d=n.mont(i),p=h.invm(s);return 0===c.toRed(d).redPow(new n(e).mul(p).mod(s)).fromRed().mul(u.toRed(d).redPow(l.mul(p).mod(s)).fromRed()).mod(i).mod(s).cmp(l)}(t,e,f)}if("rsa"!==c&&"ecdsa/rsa"!==c)throw new Error("wrong public key type");e=Buffer.concat([u,e]);for(var h=f.modulus.byteLength(),l=[1],d=0;e.length+l.length+2>>8^255&p^99,i[r]=p,o[p]=r;var b=t[r],y=t[b],m=t[y],v=257*t[p]^16843008*p;s[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,u[r]=v;v=16843009*m^65537*y^257*b^16843008*r;f[p]=v<<24|v>>>8,h[p]=v<<16|v>>>16,l[p]=v<<8|v>>>24,d[p]=v,r?(r=b^t[t[t[m^b]]],n^=t[t[n]]):r=n=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],b=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],s=0;s6&&s%r==4&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=p[s/r|0]<<24),o[s]=o[s-r]^a}for(var c=this._invKeySchedule=[],u=0;u>>24]]^h[i[a>>>16&255]]^l[i[a>>>8&255]]^d[i[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,c,u,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,h,l,d,o);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,s,a){for(var c=this._nRounds,u=t[e]^r[0],f=t[e+1]^r[1],h=t[e+2]^r[2],l=t[e+3]^r[3],d=4,p=1;p>>24]^i[f>>>16&255]^o[h>>>8&255]^s[255&l]^r[d++],y=n[f>>>24]^i[h>>>16&255]^o[l>>>8&255]^s[255&u]^r[d++],m=n[h>>>24]^i[l>>>16&255]^o[u>>>8&255]^s[255&f]^r[d++],v=n[l>>>24]^i[u>>>16&255]^o[f>>>8&255]^s[255&h]^r[d++];u=b,f=y,h=m,l=v}b=(a[u>>>24]<<24|a[f>>>16&255]<<16|a[h>>>8&255]<<8|a[255&l])^r[d++],y=(a[f>>>24]<<24|a[h>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[d++],m=(a[h>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&f])^r[d++],v=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[f>>>8&255]<<8|a[255&h])^r[d++];t[e]=b,t[e+1]=y,t[e+2]=m,t[e+3]=v},keySize:8});e.AES=r._createHelper(b)}(),t.AES},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],152:[function(t,e,r){var n,i;n=this,i=function(t){t.lib.Cipher||function(e){var r=t,n=r.lib,i=n.Base,o=n.WordArray,s=n.BufferedBlockAlgorithm,a=r.enc,c=(a.Utf8,a.Base64),u=r.algo.EvpKDF,f=n.Cipher=s.extend({cfg:i.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){s.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?g:m}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),h=(n.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),r.mode={}),l=n.BlockCipherMode=i.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),d=h.CBC=function(){var t=l.extend();function r(t,r,n){var i=this._iv;if(i){var o=i;this._iv=e}else o=this._prevBlock;for(var s=0;s>>2];t.sigBytes-=e}},b=(n.BlockCipher=f.extend({cfg:f.cfg.extend({mode:d,padding:p}),reset:function(){f.reset.call(this);var t=this.cfg,e=t.iv,r=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=r.createEncryptor;else{n=r.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==n?this._mode.init(this,e&&e.words):(this._mode=n.call(r,this,e&&e.words),this._mode.__creator=n)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{e=this._process(!0);t.unpad(e)}return e},blockSize:4}),n.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),y=(r.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;if(r)var n=o.create([1398893684,1701076831]).concat(r).concat(e);else n=e;return n.toString(c)},parse:function(t){var e=c.parse(t),r=e.words;if(1398893684==r[0]&&1701076831==r[1]){var n=o.create(r.slice(2,4));r.splice(0,4),e.sigBytes-=16}return b.create({ciphertext:e,salt:n})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:y}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),s=i.cfg;return b.create({ciphertext:o,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),v=(r.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=o.random(8));var i=u.create({keySize:e+r}).compute(t,n),s=o.create(i.words.slice(e),4*r);return i.sigBytes=4*e,b.create({key:i,iv:s,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:v}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=m.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,m.decrypt.call(this,t,e,i.key,n)}})}()},"object"==typeof r?e.exports=r=i(t("./core"),t("./evpkdf")):i(n.CryptoJS)},{"./core":153,"./evpkdf":156}],153:[function(t,e,r){var n,i;n=this,i=function(){var t=t||function(t,e){var r=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),n={},i=n.lib={},o=i.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=void 0!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r,n=[],i=function(e){e=e;var r=987654321,n=4294967295;return function(){var i=((r=36969*(65535&r)+(r>>16)&n)<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n;return i/=4294967296,(i+=.5)*(t.random()>.5?1:-1)}},o=0;o>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},u=a.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},f=a.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,n=r.words,i=r.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*o,u=t.min(4*c,i);if(c){for(var f=0;f>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,a=0;a<4&&o+.75*a>>6*(3-a)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(t){var e=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return r.create(i,o)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),t.enc.Base64},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],155:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.WordArray,n=e.enc;n.Utf16=n.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>16-i%4*8&65535;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,n=[],i=0;i>>1]|=t.charCodeAt(i)<<16-i%2*16;return r.create(n,2*e)}};function i(t){return t<<8&4278255360|t>>>8&16711935}n.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],o=0;o>>2]>>>16-o%4*8&65535);n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>1]|=i(t.charCodeAt(o)<<16-o%2*16);return r.create(n,2*e)}}}(),t.enc.Utf16},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],156:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.MD5,a=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=r.hasher.create(),o=i.create(),s=o.words,a=r.keySize,c=r.iterations;s.lengthi&&(e=t.finalize(e)),e.clamp();for(var o=this._oKey=e.clone(),s=this._iKey=e.clone(),a=o.words,c=s.words,u=0;u>>2]|=t[i]<<24-i%4*8;r.call(this,n,e)}else r.apply(this,arguments)}).prototype=e}}(),t.lib.WordArray},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],161:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=t[e+0],c=t[e+1],d=t[e+2],p=t[e+3],b=t[e+4],y=t[e+5],m=t[e+6],v=t[e+7],g=t[e+8],w=t[e+9],_=t[e+10],E=t[e+11],S=t[e+12],k=t[e+13],A=t[e+14],x=t[e+15],M=o[0],T=o[1],I=o[2],P=o[3];T=l(T=l(T=l(T=l(T=h(T=h(T=h(T=h(T=f(T=f(T=f(T=f(T=u(T=u(T=u(T=u(T,I=u(I,P=u(P,M=u(M,T,I,P,s,7,a[0]),T,I,c,12,a[1]),M,T,d,17,a[2]),P,M,p,22,a[3]),I=u(I,P=u(P,M=u(M,T,I,P,b,7,a[4]),T,I,y,12,a[5]),M,T,m,17,a[6]),P,M,v,22,a[7]),I=u(I,P=u(P,M=u(M,T,I,P,g,7,a[8]),T,I,w,12,a[9]),M,T,_,17,a[10]),P,M,E,22,a[11]),I=u(I,P=u(P,M=u(M,T,I,P,S,7,a[12]),T,I,k,12,a[13]),M,T,A,17,a[14]),P,M,x,22,a[15]),I=f(I,P=f(P,M=f(M,T,I,P,c,5,a[16]),T,I,m,9,a[17]),M,T,E,14,a[18]),P,M,s,20,a[19]),I=f(I,P=f(P,M=f(M,T,I,P,y,5,a[20]),T,I,_,9,a[21]),M,T,x,14,a[22]),P,M,b,20,a[23]),I=f(I,P=f(P,M=f(M,T,I,P,w,5,a[24]),T,I,A,9,a[25]),M,T,p,14,a[26]),P,M,g,20,a[27]),I=f(I,P=f(P,M=f(M,T,I,P,k,5,a[28]),T,I,d,9,a[29]),M,T,v,14,a[30]),P,M,S,20,a[31]),I=h(I,P=h(P,M=h(M,T,I,P,y,4,a[32]),T,I,g,11,a[33]),M,T,E,16,a[34]),P,M,A,23,a[35]),I=h(I,P=h(P,M=h(M,T,I,P,c,4,a[36]),T,I,b,11,a[37]),M,T,v,16,a[38]),P,M,_,23,a[39]),I=h(I,P=h(P,M=h(M,T,I,P,k,4,a[40]),T,I,s,11,a[41]),M,T,p,16,a[42]),P,M,m,23,a[43]),I=h(I,P=h(P,M=h(M,T,I,P,w,4,a[44]),T,I,S,11,a[45]),M,T,x,16,a[46]),P,M,d,23,a[47]),I=l(I,P=l(P,M=l(M,T,I,P,s,6,a[48]),T,I,v,10,a[49]),M,T,A,15,a[50]),P,M,y,21,a[51]),I=l(I,P=l(P,M=l(M,T,I,P,S,6,a[52]),T,I,p,10,a[53]),M,T,_,15,a[54]),P,M,c,21,a[55]),I=l(I,P=l(P,M=l(M,T,I,P,g,6,a[56]),T,I,x,10,a[57]),M,T,m,15,a[58]),P,M,k,21,a[59]),I=l(I,P=l(P,M=l(M,T,I,P,b,6,a[60]),T,I,E,10,a[61]),M,T,d,15,a[62]),P,M,w,21,a[63]),o[0]=o[0]+M|0,o[1]=o[1]+T|0,o[2]=o[2]+I|0,o[3]=o[3]+P|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),s=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(r.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var f=c[u];c[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return a},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function u(t,e,r,n,i,o,s){var a=t+(e&r|~e&n)+i+s;return(a<>>32-o)+e}function f(t,e,r,n,i,o,s){var a=t+(e&n|r&~n)+i+s;return(a<>>32-o)+e}function h(t,e,r,n,i,o,s){var a=t+(e^r^n)+i+s;return(a<>>32-o)+e}function l(t,e,r,n,i,o,s){var a=t+(r^(e|~n))+i+s;return(a<>>32-o)+e}r.MD5=o._createHelper(c),r.HmacMD5=o._createHmacHelper(c)}(Math),t.MD5},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],162:[function(t,e,r){var n,i;n=this,i=function(t){return t.mode.CFB=function(){var e=t.lib.BlockCipherMode.extend();function r(t,e,r,n){var i=this._iv;if(i){var o=i.slice(0);this._iv=void 0}else o=this._prevBlock;n.encryptBlock(o,0);for(var s=0;s>24&255)){var e=t>>16&255,r=t>>8&255,n=255&t;255===e?(e=0,255===r?(r=0,255===n?n=0:++n):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=n}else t+=1<<24;return t}var n=e.Encryptor=e.extend({processBlock:function(t,e){var n=this._cipher,i=n.blockSize,o=this._iv,s=this._counter;o&&(s=this._counter=o.slice(0),this._iv=void 0),function(t){0===(t[0]=r(t[0]))&&(t[1]=r(t[1]))}(s);var a=s.slice(0);n.encryptBlock(a,0);for(var c=0;c>>2]|=i<<24-o%4*8,t.sigBytes+=i},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Ansix923},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],168:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso10126={pad:function(e,r){var n=4*r,i=n-e.sigBytes%n;e.concat(t.lib.WordArray.random(i-1)).concat(t.lib.WordArray.create([i<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},t.pad.Iso10126},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],169:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.Iso97971={pad:function(e,r){e.concat(t.lib.WordArray.create([2147483648],1)),t.pad.ZeroPadding.pad(e,r)},unpad:function(e){t.pad.ZeroPadding.unpad(e),e.sigBytes--}},t.pad.Iso97971},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],170:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.NoPadding={pad:function(){},unpad:function(){}},t.pad.NoPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],171:[function(t,e,r){var n,i;n=this,i=function(t){return t.pad.ZeroPadding={pad:function(t,e){var r=4*e;t.clamp(),t.sigBytes+=r-(t.sigBytes%r||r)},unpad:function(t){for(var e=t.words,r=t.sigBytes-1;!(e[r>>>2]>>>24-r%4*8&255);)r--;t.sigBytes=r+1}},t.pad.ZeroPadding},"object"==typeof r?e.exports=r=i(t("./core"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153}],172:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a,c;return r=(e=t).lib,n=r.Base,i=r.WordArray,o=e.algo,s=o.SHA1,a=o.HMAC,c=o.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:s,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,n=a.create(r.hasher,t),o=i.create(),s=i.create([1]),c=o.words,u=s.words,f=r.keySize,h=r.iterations;c.length>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(var i=0;i<4;i++)a.call(this);for(i=0;i<8;i++)n[i]^=r[i+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;n[0]^=u,n[1]^=h,n[2]^=f,n[3]^=l,n[4]^=u,n[5]^=h,n[6]^=f,n[7]^=l;for(i=0;i<4;i++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.RabbitLegacy=r._createHelper(s)}(),t.RabbitLegacy},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],174:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=[],i=[],o=[],s=e.algo.Rabbit=r.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var n=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];this._b=0;for(r=0;r<4;r++)a.call(this);for(r=0;r<8;r++)i[r]^=n[r+4&7];if(e){var o=e.words,s=o[0],c=o[1],u=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),f=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8),h=u>>>16|4294901760&f,l=f<<16|65535&u;i[0]^=u,i[1]^=h,i[2]^=f,i[3]^=l,i[4]^=u,i[5]^=h,i[6]^=f,i[7]^=l;for(r=0;r<4;r++)a.call(this)}},_doProcessBlock:function(t,e){var r=this._X;a.call(this),n[0]=r[0]^r[5]>>>16^r[3]<<16,n[1]=r[2]^r[7]>>>16^r[5]<<16,n[2]=r[4]^r[1]>>>16^r[7]<<16,n[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)n[i]=16711935&(n[i]<<8|n[i]>>>24)|4278255360&(n[i]<<24|n[i]>>>8),t[e+i]^=n[i]},blockSize:4,ivSize:2});function a(){for(var t=this._X,e=this._C,r=0;r<8;r++)i[r]=e[r];e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0>>0?1:0)|0,this._b=e[7]>>>0>>0?1:0;for(r=0;r<8;r++){var n=t[r]+e[r],s=65535&n,a=n>>>16,c=((s*s>>>17)+s*a>>>15)+a*a,u=((4294901760&n)*n|0)+((65535&n)*n|0);o[r]=c^u}t[0]=o[0]+(o[7]<<16|o[7]>>>16)+(o[6]<<16|o[6]>>>16)|0,t[1]=o[1]+(o[0]<<8|o[0]>>>24)+o[7]|0,t[2]=o[2]+(o[1]<<16|o[1]>>>16)+(o[0]<<16|o[0]>>>16)|0,t[3]=o[3]+(o[2]<<8|o[2]>>>24)+o[1]|0,t[4]=o[4]+(o[3]<<16|o[3]>>>16)+(o[2]<<16|o[2]>>>16)|0,t[5]=o[5]+(o[4]<<8|o[4]>>>24)+o[3]|0,t[6]=o[6]+(o[5]<<16|o[5]>>>16)+(o[4]<<16|o[4]>>>16)|0,t[7]=o[7]+(o[6]<<8|o[6]>>>24)+o[5]|0}e.Rabbit=r._createHelper(s)}(),t.Rabbit},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],175:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.StreamCipher,n=e.algo,i=n.RC4=r.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,n=this._S=[],i=0;i<256;i++)n[i]=i;i=0;for(var o=0;i<256;i++){var s=i%r,a=e[s>>>2]>>>24-s%4*8&255;o=(o+n[i]+a)%256;var c=n[i];n[i]=n[o],n[o]=c}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=o.call(this)},keySize:8,ivSize:0});function o(){for(var t=this._S,e=this._i,r=this._j,n=0,i=0;i<4;i++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,n|=t[(t[e]+t[r])%256]<<24-8*i}return this._i=e,this._j=r,n}e.RC4=r._createHelper(i);var s=n.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;t>0;t--)o.call(this)}});e.RC4Drop=r._createHelper(s)}(),t.RC4},"object"==typeof r?e.exports=r=i(t("./core"),t("./enc-base64"),t("./md5"),t("./evpkdf"),t("./cipher-core")):i(n.CryptoJS)},{"./cipher-core":152,"./core":153,"./enc-base64":154,"./evpkdf":156,"./md5":161}],176:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=i.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),c=i.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=i.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=i.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=i.create([0,1518500249,1859775393,2400959708,2840853838]),l=i.create([1352829926,1548603684,1836072691,2053994217,0]),d=s.RIPEMD160=o.extend({_doReset:function(){this._hash=i.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var n=e+r,i=t[n];t[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o,s,d,w,_,E,S,k,A,x,M,T=this._hash.words,I=h.words,P=l.words,B=a.words,R=c.words,C=u.words,O=f.words;E=o=T[0],S=s=T[1],k=d=T[2],A=w=T[3],x=_=T[4];for(r=0;r<80;r+=1)M=o+t[e+B[r]]|0,M+=r<16?p(s,d,w)+I[0]:r<32?b(s,d,w)+I[1]:r<48?y(s,d,w)+I[2]:r<64?m(s,d,w)+I[3]:v(s,d,w)+I[4],M=(M=g(M|=0,C[r]))+_|0,o=_,_=w,w=g(d,10),d=s,s=M,M=E+t[e+R[r]]|0,M+=r<16?v(S,k,A)+P[0]:r<32?m(S,k,A)+P[1]:r<48?y(S,k,A)+P[2]:r<64?b(S,k,A)+P[3]:p(S,k,A)+P[4],M=(M=g(M|=0,O[r]))+x|0,E=x,x=A,A=g(k,10),k=S,S=M;M=T[1]+d+A|0,T[1]=T[2]+w+x|0,T[2]=T[3]+_+E|0,T[3]=T[4]+o+S|0,T[4]=T[0]+s+k|0,T[0]=M},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,o=i.words,s=0;s<5;s++){var a=o[s];o[s]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}return i},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});function p(t,e,r){return t^e^r}function b(t,e,r){return t&e|~t&r}function y(t,e,r){return(t|~e)^r}function m(t,e,r){return t&r|e&~r}function v(t,e,r){return t^(e|~r)}function g(t,e){return t<>>32-e}r.RIPEMD160=o._createHelper(d),r.HmacRIPEMD160=o._createHmacHelper(d)}(Math),t.RIPEMD160},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],177:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s;return r=(e=t).lib,n=r.WordArray,i=r.Hasher,o=[],s=e.algo.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)o[u]=0|t[e+u];else{var f=o[u-3]^o[u-8]^o[u-14]^o[u-16];o[u]=f<<1|f>>>31}var h=(n<<5|n>>>27)+c+o[u];h+=u<20?1518500249+(i&s|~i&a):u<40?1859775393+(i^s^a):u<60?(i&s|i&a|s&a)-1894007588:(i^s^a)-899497514,c=a,a=s,s=i<<30|i>>>2,i=n,n=h}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(n+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA1=i._createHelper(s),e.HmacSHA1=i._createHmacHelper(s),t.SHA1},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],178:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o;return r=(e=t).lib.WordArray,n=e.algo,i=n.SHA256,o=n.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),e.SHA224=i._createHelper(o),e.HmacSHA224=i._createHmacHelper(o),t.SHA224},"object"==typeof r?e.exports=r=i(t("./core"),t("./sha256")):i(n.CryptoJS)},{"./core":153,"./sha256":179}],179:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.algo,a=[],c=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(t){return 4294967296*(t-(0|t))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),c[i]=r(e.pow(n,1/3)),i++),n++}();var u=[],f=s.SHA256=o.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=0;d<64;d++){if(d<16)u[d]=0|t[e+d];else{var p=u[d-15],b=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=u[d-2],m=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;u[d]=b+u[d-7]+m+u[d-16]}var v=n&i^n&o^i&o,g=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),w=l+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&f^~a&h)+c[d]+u[d];l=h,h=f,f=a,a=s+w|0,s=o,o=i,i=n,n=w+(g+v)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+a|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}});r.SHA256=o._createHelper(f),r.HmacSHA256=o._createHmacHelper(f)}(Math),t.SHA256},"object"==typeof r?e.exports=r=i(t("./core")):i(n.CryptoJS)},{"./core":153}],180:[function(t,e,r){var n,i;n=this,i=function(t){return function(e){var r=t,n=r.lib,i=n.WordArray,o=n.Hasher,s=r.x64.Word,a=r.algo,c=[],u=[],f=[];!function(){for(var t=1,e=0,r=0;r<24;r++){c[t+5*e]=(r+1)*(r+2)/2%64;var n=(2*t+3*e)%5;t=e%5,e=n}for(t=0;t<5;t++)for(e=0;e<5;e++)u[t+5*e]=e+(2*t+3*e)%5*5;for(var i=1,o=0;o<24;o++){for(var a=0,h=0,l=0;l<7;l++){if(1&i){var d=(1<>>24)|4278255360&(o<<24|o>>>8),s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),(T=r[i]).high^=s,T.low^=o}for(var a=0;a<24;a++){for(var l=0;l<5;l++){for(var d=0,p=0,b=0;b<5;b++){d^=(T=r[l+5*b]).high,p^=T.low}var y=h[l];y.high=d,y.low=p}for(l=0;l<5;l++){var m=h[(l+4)%5],v=h[(l+1)%5],g=v.high,w=v.low;for(d=m.high^(g<<1|w>>>31),p=m.low^(w<<1|g>>>31),b=0;b<5;b++){(T=r[l+5*b]).high^=d,T.low^=p}}for(var _=1;_<25;_++){var E=(T=r[_]).high,S=T.low,k=c[_];if(k<32)d=E<>>32-k,p=S<>>32-k;else d=S<>>64-k,p=E<>>64-k;var A=h[u[_]];A.high=d,A.low=p}var x=h[0],M=r[0];x.high=M.high,x.low=M.low;for(l=0;l<5;l++)for(b=0;b<5;b++){var T=r[_=l+5*b],I=h[_],P=h[(l+1)%5+5*b],B=h[(l+2)%5+5*b];T.high=I.high^~P.high&B.high,T.low=I.low^~P.low&B.low}T=r[0];var R=f[a];T.high^=R.high,T.low^=R.low}},_doFinalize:function(){var t=this._data,r=t.words,n=(this._nDataBytes,8*t.sigBytes),o=32*this.blockSize;r[n>>>5]|=1<<24-n%32,r[(e.ceil((n+1)/o)*o>>>5)-1]|=128,t.sigBytes=4*r.length,this._process();for(var s=this._state,a=this.cfg.outputLength/8,c=a/8,u=[],f=0;f>>24)|4278255360&(l<<24|l>>>8),d=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),u.push(d),u.push(l)}return new i.init(u,a)},clone:function(){for(var t=o.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}});r.SHA3=o._createHelper(l),r.HmacSHA3=o._createHmacHelper(l)}(Math),t.SHA3},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],181:[function(t,e,r){var n,i;n=this,i=function(t){var e,r,n,i,o,s,a;return r=(e=t).x64,n=r.Word,i=r.WordArray,o=e.algo,s=o.SHA512,a=o.SHA384=s.extend({_doReset:function(){this._hash=new i.init([new n.init(3418070365,3238371032),new n.init(1654270250,914150663),new n.init(2438529370,812702999),new n.init(355462360,4144912697),new n.init(1731405415,4290775857),new n.init(2394180231,1750603025),new n.init(3675008525,1694076839),new n.init(1203062813,3204075428)])},_doFinalize:function(){var t=s._doFinalize.call(this);return t.sigBytes-=16,t}}),e.SHA384=s._createHelper(a),e.HmacSHA384=s._createHmacHelper(a),t.SHA384},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core"),t("./sha512")):i(n.CryptoJS)},{"./core":153,"./sha512":182,"./x64-core":184}],182:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib.Hasher,n=e.x64,i=n.Word,o=n.WordArray,s=e.algo;function a(){return i.create.apply(i,arguments)}var c=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],u=[];!function(){for(var t=0;t<80;t++)u[t]=a()}();var f=s.SHA512=r.extend({_doReset:function(){this._hash=new o.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],a=r[4],f=r[5],h=r[6],l=r[7],d=n.high,p=n.low,b=i.high,y=i.low,m=o.high,v=o.low,g=s.high,w=s.low,_=a.high,E=a.low,S=f.high,k=f.low,A=h.high,x=h.low,M=l.high,T=l.low,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_,D=E,U=S,K=k,H=A,q=x,z=M,F=T,W=0;W<80;W++){var V=u[W];if(W<16)var G=V.high=0|t[e+2*W],Y=V.low=0|t[e+2*W+1];else{var J=u[W-15],Z=J.high,X=J.low,$=(Z>>>1|X<<31)^(Z>>>8|X<<24)^Z>>>7,Q=(X>>>1|Z<<31)^(X>>>8|Z<<24)^(X>>>7|Z<<25),tt=u[W-2],et=tt.high,rt=tt.low,nt=(et>>>19|rt<<13)^(et<<3|rt>>>29)^et>>>6,it=(rt>>>19|et<<13)^(rt<<3|et>>>29)^(rt>>>6|et<<26),ot=u[W-7],st=ot.high,at=ot.low,ct=u[W-16],ut=ct.high,ft=ct.low;G=(G=(G=$+st+((Y=Q+at)>>>0>>0?1:0))+nt+((Y=Y+it)>>>0>>0?1:0))+ut+((Y=Y+ft)>>>0>>0?1:0);V.high=G,V.low=Y}var ht,lt=N&U^~N&H,dt=D&K^~D&q,pt=I&B^I&C^B&C,bt=P&R^P&O^R&O,yt=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),mt=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),vt=(N>>>14|D<<18)^(N>>>18|D<<14)^(N<<23|D>>>9),gt=(D>>>14|N<<18)^(D>>>18|N<<14)^(D<<23|N>>>9),wt=c[W],_t=wt.high,Et=wt.low,St=z+vt+((ht=F+gt)>>>0>>0?1:0),kt=mt+bt;z=H,F=q,H=U,q=K,U=N,K=D,N=L+(St=(St=(St=St+lt+((ht=ht+dt)>>>0

>>0?1:0))+_t+((ht=ht+Et)>>>0>>0?1:0))+G+((ht=ht+Y)>>>0>>0?1:0))+((D=j+ht|0)>>>0>>0?1:0)|0,L=C,j=O,C=B,O=R,B=I,R=P,I=St+(yt+pt+(kt>>>0>>0?1:0))+((P=ht+kt|0)>>>0>>0?1:0)|0}p=n.low=p+P,n.high=d+I+(p>>>0

>>0?1:0),y=i.low=y+R,i.high=b+B+(y>>>0>>0?1:0),v=o.low=v+O,o.high=m+C+(v>>>0>>0?1:0),w=s.low=w+j,s.high=g+L+(w>>>0>>0?1:0),E=a.low=E+D,a.high=_+N+(E>>>0>>0?1:0),k=f.low=k+K,f.high=S+U+(k>>>0>>0?1:0),x=h.low=x+q,h.high=A+H+(x>>>0>>0?1:0),T=l.low=T+F,l.high=M+z+(T>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(n+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32});e.SHA512=r._createHelper(f),e.HmacSHA512=r._createHmacHelper(f)}(),t.SHA512},"object"==typeof r?e.exports=r=i(t("./core"),t("./x64-core")):i(n.CryptoJS)},{"./core":153,"./x64-core":184}],183:[function(t,e,r){var n,i;n=this,i=function(t){return function(){var e=t,r=e.lib,n=r.WordArray,i=r.BlockCipher,o=e.algo,s=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],a=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],c=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],f=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],h=o.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var n=s[r]-1;e[r]=t[n>>>5]>>>31-n%32&1}for(var i=this._subKeys=[],o=0;o<16;o++){var u=i[o]=[],f=c[o];for(r=0;r<24;r++)u[r/6|0]|=e[(a[r]-1+f)%28]<<31-r%6,u[4+(r/6|0)]|=e[28+(a[r+24]-1+f)%28]<<31-r%6;u[0]=u[0]<<1|u[0]>>>31;for(r=1;r<7;r++)u[r]=u[r]>>>4*(r-1)+3;u[7]=u[7]<<5|u[7]>>>27}var h=this._invSubKeys=[];for(r=0;r<16;r++)h[r]=i[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],l.call(this,4,252645135),l.call(this,16,65535),d.call(this,2,858993459),d.call(this,8,16711935),l.call(this,1,1431655765);for(var n=0;n<16;n++){for(var i=r[n],o=this._lBlock,s=this._rBlock,a=0,c=0;c<8;c++)a|=u[c][((s^i[c])&f[c])>>>0];this._lBlock=s,this._rBlock=o^a}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,l.call(this,1,1431655765),d.call(this,8,16711935),d.call(this,2,858993459),l.call(this,16,65535),l.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function l(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},r.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(i())}).call(this)}).call(this,t("_process"))},{"./debug":186,_process:270}],186:[function(t,e,r){var n;function i(t){function e(){if(e.enabled){var t=e,i=+new Date,o=i-(n||i);t.diff=o,t.prev=n,t.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0;n--)e+=this._buffer(t,e),r+=this._flushBuffer(i,r);return e+=this._buffer(t,e),i},i.prototype.final=function(t){var e,r;return t&&(e=this.update(t)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),e?e.concat(r):r},i.prototype._pad=function(t,e){if(0===e)return!1;for(;e>>1];r=o.r28shl(r,a),i=o.r28shl(i,a),o.pc2(r,i,t.keys,s)}},a.prototype._update=function(t,e,r,n){var i=this._desState,s=o.readUInt32BE(t,e),a=o.readUInt32BE(t,e+4);o.ip(s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],"encrypt"===this.type?this._encrypt(i,s,a,i.tmp,0):this._decrypt(i,s,a,i.tmp,0),s=i.tmp[0],a=i.tmp[1],o.writeUInt32BE(r,s,n),o.writeUInt32BE(r,a,n+4)},a.prototype._pad=function(t,e){for(var r=t.length-e,n=e;n>>0,s=l}o.rip(a,s,n,i)},a.prototype._decrypt=function(t,e,r,n,i){for(var s=r,a=e,c=t.keys.length-2;c>=0;c-=2){var u=t.keys[c],f=t.keys[c+1];o.expand(s,t.tmp,0),u^=t.tmp[0],f^=t.tmp[1];var h=o.substitute(u,f),l=s;s=(a^o.permute(h))>>>0,a=l}o.rip(s,a,n,i)}},{"./cipher":189,"./utils":192,inherits:258,"minimalistic-assert":265}],191:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits"),o=t("./cipher"),s=t("./des");function a(t){o.call(this,t);var e=new function(t,e){n.equal(e.length,24,"Invalid key length");var r=e.slice(0,8),i=e.slice(8,16),o=e.slice(16,24);this.ciphers="encrypt"===t?[s.create({type:"encrypt",key:r}),s.create({type:"decrypt",key:i}),s.create({type:"encrypt",key:o})]:[s.create({type:"decrypt",key:o}),s.create({type:"encrypt",key:i}),s.create({type:"decrypt",key:r})]}(this.type,this.options.key);this._edeState=e}i(a,o),e.exports=a,a.create=function(t){return new a(t)},a.prototype._update=function(t,e,r,n){var i=this._edeState;i.ciphers[0]._update(t,e,r,n),i.ciphers[1]._update(r,n,r,n),i.ciphers[2]._update(r,n,r,n)},a.prototype._pad=s.prototype._pad,a.prototype._unpad=s.prototype._unpad},{"./cipher":189,"./des":190,inherits:258,"minimalistic-assert":265}],192:[function(t,e,r){"use strict";r.readUInt32BE=function(t,e){return(t[0+e]<<24|t[1+e]<<16|t[2+e]<<8|t[3+e])>>>0},r.writeUInt32BE=function(t,e,r){t[0+r]=e>>>24,t[1+r]=e>>>16&255,t[2+r]=e>>>8&255,t[3+r]=255&e},r.ip=function(t,e,r,n){for(var i=0,o=0,s=6;s>=0;s-=2){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>>a+s&1}for(s=6;s>=0;s-=2){for(a=1;a<=25;a+=8)o<<=1,o|=e>>>a+s&1;for(a=1;a<=25;a+=8)o<<=1,o|=t>>>a+s&1}r[n+0]=i>>>0,r[n+1]=o>>>0},r.rip=function(t,e,r,n){for(var i=0,o=0,s=0;s<4;s++)for(var a=24;a>=0;a-=8)i<<=1,i|=e>>>a+s&1,i<<=1,i|=t>>>a+s&1;for(s=4;s<8;s++)for(a=24;a>=0;a-=8)o<<=1,o|=e>>>a+s&1,o<<=1,o|=t>>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.pc1=function(t,e,r,n){for(var i=0,o=0,s=7;s>=5;s--){for(var a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(a=0;a<=24;a+=8)i<<=1,i|=t>>a+s&1}for(a=0;a<=24;a+=8)i<<=1,i|=e>>a+s&1;for(s=1;s<=3;s++){for(a=0;a<=24;a+=8)o<<=1,o|=e>>a+s&1;for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1}for(a=0;a<=24;a+=8)o<<=1,o|=t>>a+s&1;r[n+0]=i>>>0,r[n+1]=o>>>0},r.r28shl=function(t,e){return t<>>28-e};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];r.pc2=function(t,e,r,i){for(var o=0,s=0,a=n.length>>>1,c=0;c>>n[c]&1;for(c=a;c>>n[c]&1;r[i+0]=o>>>0,r[i+1]=s>>>0},r.expand=function(t,e,r){var n=0,i=0;n=(1&t)<<5|t>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=t>>>o&63;for(o=11;o>=3;o-=4)i|=t>>>o&63,i<<=6;i|=(31&t)<<1|t>>>31,e[r+0]=n>>>0,e[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];r.substitute=function(t,e){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(t>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(e>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];r.permute=function(t){for(var e=0,r=0;r>>o[r]&1;return e>>>0},r.padSplit=function(t,e,r){for(var n=t.toString(2);n.lengtht;)r.ishrn(1);if(r.isEven()&&r.iadd(a),r.testn(1)||r.iadd(c),e.cmp(c)){if(!e.cmp(u))for(;r.mod(f).cmp(h);)r.iadd(d)}else for(;r.mod(o).cmp(l);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&s.test(p)&&s.test(r))return r}}},{"bn.js":82,"miller-rabin":264,randombytes:303}],196:[function(t,e,r){e.exports={modp1:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},modp2:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},modp5:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},modp14:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},modp15:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},modp16:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},modp17:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},modp18:{gen:"02",prime:"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}},{}],197:[function(t,e,r){var n=t("assert"),BigInteger=t("bigi"),Point=t("./point");function i(t,e,r,n,i,o,s){this.p=t,this.a=e,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=s,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=t.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(t,e){var r=e.pow(3).add(this.a.multiply(e)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!t&&(n=this.p.subtract(n)),Point.fromAffine(this,e,n)},i.prototype.isInfinity=function(t){return t===this.infinity||0===t.z.signum()&&0!==t.y.signum()},i.prototype.isOnCurve=function(t){if(this.isInfinity(t))return!0;var e=t.affineX,r=t.affineY,n=this.a,i=this.b,o=this.p;if(e.signum()<0||e.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=e.pow(3).add(n.multiply(e)).add(i).mod(o);return s.equals(a)},i.prototype.validate=function(t){n(!this.isInfinity(t),"Point is at infinity"),n(this.isOnCurve(t),"Point is not on the curve");var e=t.multiply(this.n);return n(this.isInfinity(e),"Point is not a scalar multiple of G"),!0},e.exports=i},{"./point":201,assert:23,bigi:32}],198:[function(t,e,r){e.exports={secp128r1:{p:"fffffffdffffffffffffffffffffffff",a:"fffffffdfffffffffffffffffffffffc",b:"e87579c11079f43dd824993c2cee5ed3",n:"fffffffe0000000075a30d1b9038a115",h:"01",Gx:"161ff7528b899b2d0c28607ca52c5b86",Gy:"cf5ac8395bafeb13c02da292dded7a83"},secp160k1:{p:"fffffffffffffffffffffffffffffffeffffac73",a:"00",b:"07",n:"0100000000000000000001b8fa16dfab9aca16b6b3",h:"01",Gx:"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",Gy:"938cf935318fdced6bc28286531733c3f03c4fee"},secp160r1:{p:"ffffffffffffffffffffffffffffffff7fffffff",a:"ffffffffffffffffffffffffffffffff7ffffffc",b:"1c97befc54bd7a8b65acf89f81d4d4adc565fa45",n:"0100000000000000000001f4c8f927aed3ca752257",h:"01",Gx:"4a96b5688ef573284664698968c38bb913cbfc82",Gy:"23a628553168947d59dcc912042351377ac5fb32"},secp192k1:{p:"fffffffffffffffffffffffffffffffffffffffeffffee37",a:"00",b:"03",n:"fffffffffffffffffffffffe26f2fc170f69466a74defd8d",h:"01",Gx:"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",Gy:"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},secp192r1:{p:"fffffffffffffffffffffffffffffffeffffffffffffffff",a:"fffffffffffffffffffffffffffffffefffffffffffffffc",b:"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",n:"ffffffffffffffffffffffff99def836146bc9b1b4d22831",h:"01",Gx:"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",Gy:"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},secp256k1:{p:"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",a:"00",b:"07",n:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",h:"01",Gx:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",Gy:"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},secp256r1:{p:"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",a:"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",b:"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",n:"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",h:"01",Gx:"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",Gy:"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}},{}],199:[function(t,e,r){var Point=t("./point"),n=t("./curve"),i=t("./names");e.exports={Curve:n,Point:Point,getCurveByName:i}},{"./curve":197,"./names":200,"./point":201}],200:[function(t,e,r){var BigInteger=t("bigi"),n=t("./curves.json"),i=t("./curve");e.exports=function(t){var e=n[t];if(!e)return null;var r=new BigInteger(e.p,16),o=new BigInteger(e.a,16),s=new BigInteger(e.b,16),a=new BigInteger(e.n,16),c=new BigInteger(e.h,16),u=new BigInteger(e.Gx,16),f=new BigInteger(e.Gy,16);return new i(r,o,s,u,f,a,c)}},{"./curve":197,"./curves.json":198,bigi:32}],201:[function(t,e,r){var n=t("assert"),Buffer=t("safe-buffer").Buffer,BigInteger=t("bigi"),i=BigInteger.valueOf(3);function Point(t,e,r,i){n.notStrictEqual(i,void 0,"Missing Z coordinate"),this.curve=t,this.x=e,this.y=r,this.z=i,this._zInv=null,this.compressed=!0}Object.defineProperty(Point.prototype,"zInv",{get:function(){return null===this._zInv&&(this._zInv=this.z.modInverse(this.curve.p)),this._zInv}}),Object.defineProperty(Point.prototype,"affineX",{get:function(){return this.x.multiply(this.zInv).mod(this.curve.p)}}),Object.defineProperty(Point.prototype,"affineY",{get:function(){return this.y.multiply(this.zInv).mod(this.curve.p)}}),Point.fromAffine=function(t,e,r){return new Point(t,e,r,BigInteger.ONE)},Point.prototype.equals=function(t){return t===this||(this.curve.isInfinity(this)?this.curve.isInfinity(t):this.curve.isInfinity(t)?this.curve.isInfinity(this):0===t.y.multiply(this.z).subtract(this.y.multiply(t.z)).mod(this.curve.p).signum()&&0===t.x.multiply(this.z).subtract(this.x.multiply(t.z)).mod(this.curve.p).signum())},Point.prototype.negate=function(){var t=this.curve.p.subtract(this.y);return new Point(this.curve,this.x,t,this.z)},Point.prototype.add=function(t){if(this.curve.isInfinity(this))return t;if(this.curve.isInfinity(t))return this;var e=this.x,r=this.y,n=t.x,o=t.y.multiply(this.z).subtract(r.multiply(t.z)).mod(this.curve.p),s=n.multiply(this.z).subtract(e.multiply(t.z)).mod(this.curve.p);if(0===s.signum())return 0===o.signum()?this.twice():this.curve.infinity;var a=s.square(),c=a.multiply(s),u=e.multiply(a),f=o.square().multiply(this.z),h=f.subtract(u.shiftLeft(1)).multiply(t.z).subtract(c).multiply(s).mod(this.curve.p),l=u.multiply(i).multiply(o).subtract(r.multiply(c)).subtract(f.multiply(o)).multiply(t.z).add(o.multiply(c)).mod(this.curve.p),d=c.multiply(this.z).multiply(t.z).mod(this.curve.p);return new Point(this.curve,h,l,d)},Point.prototype.twice=function(){if(this.curve.isInfinity(this))return this;if(0===this.y.signum())return this.curve.infinity;var t=this.x,e=this.y,r=e.multiply(this.z).mod(this.curve.p),n=r.multiply(e).mod(this.curve.p),o=this.curve.a,s=t.square().multiply(i);0!==o.signum()&&(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.p)).square().subtract(t.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(r).mod(this.curve.p),c=s.multiply(i).multiply(t).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.pow(3)).mod(this.curve.p),u=r.pow(3).shiftLeft(3).mod(this.curve.p);return new Point(this.curve,a,c,u)},Point.prototype.multiply=function(t){if(this.curve.isInfinity(this))return this;if(0===t.signum())return this.curve.infinity;for(var e=t,r=e.multiply(i),n=this.negate(),o=this,s=r.bitLength()-2;s>0;--s){var a=r.testBit(s),c=e.testBit(s);o=o.twice(),a!==c&&(o=o.add(a?this:n))}return o},Point.prototype.multiplyTwo=function(t,e,r){for(var n=Math.max(t.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(e);n>=0;){var s=t.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(e)),--n}return i},Point.prototype.getEncoded=function(t){if(null==t&&(t=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var e,r=this.affineX,n=this.affineY,i=this.curve.pLength;return t?(e=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((e=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(e,1+i)),r.toBuffer(i).copy(e,1),e},Point.decodeFrom=function(t,e){var r,i=e.readUInt8(0),o=4!==i,s=Math.floor((t.p.bitLength()+7)/8),a=BigInteger.fromBuffer(e.slice(1,1+s));if(o){n.equal(e.length,s+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var c=3===i;r=t.pointFromX(c,a)}else{n.equal(e.length,1+s+s,"Invalid sequence length");var u=BigInteger.fromBuffer(e.slice(1+s));r=Point.fromAffine(t,a,u)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},{assert:23,bigi:32,"safe-buffer":321}],202:[function(t,e,r){"use strict";var n=r;n.version=t("../package.json").version,n.utils=t("./elliptic/utils"),n.rand=t("brorand"),n.curve=t("./elliptic/curve"),n.curves=t("./elliptic/curves"),n.ec=t("./elliptic/ec"),n.eddsa=t("./elliptic/eddsa")},{"../package.json":217,"./elliptic/curve":205,"./elliptic/curves":208,"./elliptic/ec":209,"./elliptic/eddsa":212,"./elliptic/utils":216,brorand:83}],203:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.getNAF,s=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<=s;f--)c=(c<<1)+n[f];u.push(c)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),d=i;d>0;d--){for(s=0;s=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){var a,c,u,f=this._wnafT1,h=this._wnafT2,l=this._wnafT3,d=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===f[b]&&1===f[y]){var m=[e[b],null,null,e[y]];0===e[b].y.cmp(e[y].y)?(m[1]=e[b].add(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg())):0===e[b].y.cmp(e[y].y.redNeg())?(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].add(e[y].neg())):(m[1]=e[b].toJ().mixedAdd(e[y]),m[2]=e[b].toJ().mixedAdd(e[y].neg()));var v=[-3,-1,-5,-7,0,7,5,1,3],g=s(r[b],r[y]);for(d=Math.max(g[0].length,d),l[b]=new Array(d),l[y]=new Array(d),c=0;c=0;a--){for(var k=0;a>=0;){var A=!0;for(c=0;c=0&&k++,E=E.dblp(k),a<0)break;for(c=0;c0?u=h[c][x-1>>1]:x<0&&(u=h[c][-x-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(a=0;a=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},Point.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(c);this.zOne?(t=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),e=u.redMul(n.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),t=s.redSub(a).redISub(c).redMul(o),e=u.redMul(n.redSub(c)),r=u.redMul(o))}else n=a.redAdd(c),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(c)),r=n.redMul(o);return this.curve.point(t,e,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),l=s.redMul(a);return this.curve.point(u,f,l,h)},Point.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(e=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(e=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,e,r)},Point.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},Point.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},Point.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},Point.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],205:[function(t,e,r){"use strict";var n=r;n.base=t("./base"),n.short=t("./short"),n.mont=t("./mont"),n.edwards=t("./edwards")},{"./base":203,"./edwards":204,"./mont":206,"./short":207}],206:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("inherits"),o=t("./base"),s=t("../utils");function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new Point(this,t,e)},a.prototype.pointFromJSON=function(t){return Point.fromJSON(this,t)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(t,e){return new Point(t,e[0],e[1]||t.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),c=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},Point.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],207:[function(t,e,r){"use strict";var n=t("../utils"),i=t("bn.js"),o=t("inherits"),s=t("./base"),a=n.assert;function c(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function u(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(c,s),e.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new i(t.a,16),b:new i(t.b,16)}}):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),l=t,d=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),m=new i(1),v=0;0!==l.cmpn(0);){var g=d.div(l);u=d.sub(g.mul(l)),f=y.sub(g.mul(p));var w=m.sub(g.mul(b));if(!n&&u.cmp(h)<0)e=c.neg(),r=p,n=u.neg(),o=f;else if(n&&2==++v)break;c=u,d=l,l=u,y=p,p=f,m=b,b=w}s=u.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Point.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Point.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(u,s.BasePoint),c.prototype.jpoint=function(t,e,r){return new u(this,t,e,r)},u.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},u.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},u.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),l=c.redSqr().redIAdd(f).redISub(h).redISub(h),d=c.redMul(h.redISub(l)).redISub(o.redMul(f)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(l,d,p)},u.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),l=a.redMul(f.redISub(h)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(h,l,d)},u.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":216,"./base":203,"bn.js":82,inherits:258}],208:[function(t,e,r){"use strict";var n,i=r,o=t("hash.js"),s=t("./curve"),a=t("./utils").assert;function c(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=t("./precomputed/secp256k1")}catch(t){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"./curve":205,"./precomputed/secp256k1":215,"./utils":216,"hash.js":244}],209:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("hmac-drbg"),o=t("../utils"),s=t("../curves"),a=t("brorand"),c=o.assert,u=t("./key"),f=t("./signature");function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}e.exports=h,h.prototype.keyPair=function(t){return new u(this,t)},h.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var s=this.n.byteLength(),a=e.getPrivate().toArray("be",s),c=t.toArray("be",s),u=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),h=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(u.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(h)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var b=p.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new f({r:y,s:m,recoveryParam:v})}}}}}},h.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(t).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,u=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var d=e.r.invm(o),p=o.sub(s).mul(d).umod(o),b=u.mul(d).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../curves":208,"../utils":216,"./key":210,"./signature":211,"bn.js":82,brorand:83,"hmac-drbg":256}],210:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils").assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}e.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},o.prototype.inspect=function(){return""}},{"../utils":216,"bn.js":82}],211:[function(t,e,r){"use strict";var n=t("bn.js"),i=t("../utils"),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o>>=0;return!(i<=127)&&(e.place=s,i)}function c(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}e.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new function(){this.place=0};if(48!==t[r.place++])return!1;var o=a(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=a(t,r);if(!1===s)return!1;var c=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var u=a(t,r);if(!1===u)return!1;if(t.length!==u+r.place)return!1;var f=t.slice(r.place,u+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}return this.r=new n(c),this.s=new n(f),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=c(e),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,e.length),(n=n.concat(e)).push(2),u(n,r.length);var o=n.concat(r),s=[48];return u(s,o.length),s=s.concat(o),i.encode(s,t)}},{"../utils":216,"bn.js":82}],212:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("../curves"),o=t("../utils"),s=o.assert,a=o.parseBytes,c=t("./key"),u=t("./signature");function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e(i>>1)-1?(i>>1)-c:c,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,c=t.andln(3)+i&3,u=e.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!=(n=t.andln(7)+i&7)&&5!==n||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!=(n=e.andln(7)+o&7)&&5!==n||2!==c?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},{"bn.js":82,"minimalistic-assert":265,"minimalistic-crypto-utils":266}],217:[function(t,e,r){e.exports={_args:[["elliptic@6.5.4","/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs"]],_from:"elliptic@6.5.4",_id:"elliptic@6.5.4",_inBundle:!1,_integrity:"sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",_location:"/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.5.4",name:"elliptic",escapedName:"elliptic",rawSpec:"6.5.4",saveSpec:null,fetchSpec:"6.5.4"},_requiredBy:["/create-ecdh","/crypto-browserify/browserify-sign","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",_spec:"6.5.4",_where:"/Users/bitmain/Desktop/js-project/github.com/blocktrail/blocktrail-sdk-nodejs",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"},description:"EC cryptography",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.5.4"}},{}],218:[function(t,e,r){var Buffer=t("safe-buffer").Buffer,n=t("md5.js");e.exports=function(t,e,r,i){if(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),e&&(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),8!==e.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,s=Buffer.alloc(o),a=Buffer.alloc(i||0),c=Buffer.alloc(0);o>0||i>0;){var u=new n;u.update(c),u.update(t),e&&u.update(e),c=u.digest();var f=0;if(o>0){var h=s.length-o;f=Math.min(o,c.length),c.copy(s,h,0,f),o-=f}if(f0){var l=a.length-i,d=Math.min(i,c.length-f);c.copy(a,l,f,f+d),i-=d}}return c.fill(0),{key:s,iv:a}}},{"md5.js":262,"safe-buffer":321}],219:[function(t,e,r){},{}],220:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var f=new Error('Uncaught, unspecified "error" event. ('+e+")");throw f.context=e,f}if(s(r=this._events[t]))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),n=(u=r.slice()).length,c=0;c0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var r,n,s,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(s=(r=this._events[t]).length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(r=this._events[t]))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},n.listenerCount=function(t,e){return t.listenerCount(e)}},{}],221:[function(t,e,r){(function(t){(function(){!function(n){var i="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,u=2147483647,f=36,h=1,l=26,d=38,p=700,b=72,y=128,m="-",v=/^xn--/,g=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=f-h,S=Math.floor,k=String.fromCharCode;function A(t){throw new RangeError(_[t])}function x(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function M(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+x((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,o=t.length;i=55296&&e<=56319&&i65535&&(e+=k((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=k(t)}).join("")}function P(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function B(t,e,r){var n=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>E*l>>1;n+=f)t=S(t/E);return S(n+(E+1)*t/(t+d))}function R(t){var e,r,n,i,o,s,a,c,d,p,v,g=[],w=t.length,_=0,E=y,k=b;for((r=t.lastIndexOf(m))<0&&(r=0),n=0;n=128&&A("not-basic"),g.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=w&&A("invalid-input"),((c=(v=t.charCodeAt(i++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:f)>=f||c>S((u-_)/s))&&A("overflow"),_+=c*s,!(c<(d=a<=k?h:a>=k+l?l:a-k));a+=f)s>S(u/(p=f-d))&&A("overflow"),s*=p;k=B(_-o,e=g.length+1,0==o),S(_/e)>u-E&&A("overflow"),E+=S(_/e),_%=e,g.splice(_++,0,E)}return I(g)}function C(t){var e,r,n,i,o,s,a,c,d,p,v,g,w,_,E,x=[];for(g=(t=T(t)).length,e=y,r=0,o=b,s=0;s=e&&vS((u-r)/(w=n+1))&&A("overflow"),r+=(a-e)*w,e=a,s=0;su&&A("overflow"),v==e){for(c=r,d=f;!(c<(p=d<=o?h:d>=o+l?l:d-o));d+=f)E=c-p,_=f-p,x.push(k(P(p+E%_,0))),c=S(E/_);x.push(k(P(c,0))),o=B(r,w,n==i),r=0,++n}++r,++e}return x.join("")}if(a={version:"1.4.1",ucs2:{decode:T,encode:I},decode:R,encode:C,toASCII:function(t){return M(t,function(t){return g.test(t)?"xn--"+C(t):t})},toUnicode:function(t){return M(t,function(t){return v.test(t)?R(t.slice(4).toLowerCase()):t})}},i&&o)if(e.exports==i)o.exports=a;else for(c in a)a.hasOwnProperty(c)&&(i[c]=a[c]);else n.punycode=a}(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],222:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":223}],223:[function(t,e,r){"use strict";var n=t("process-nextick-args"),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=h;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(h,s);for(var c=i(a.prototype),u=0;u0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):A(t,s)):w(t,s,e,!1))):n||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function S(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(k,t):k(t))}function k(t){l("emit readable"),t.emit("readable"),I(t)}function A(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;to.length?o.length:t;if(s===o.length?i+=o:i+=o.slice(0,t),0===(t-=s)){s===o.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=Buffer.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var o=n.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=o.slice(s));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function B(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(R,e,t))}function R(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function C(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?B(this):S(this),null;if(0===(t=E(t,e))&&e.ended)return 0===e.length&&B(this),null;var n,i=e.needReadable;return l("need readable",i),(0===e.length||e.length-t0?P(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&B(this)),null!==n&&this.emit("data",n),n},v.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},v.prototype.pipe=function(t,e){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,l("pipe count=%d opts=%j",o.pipesCount,e);var c=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:g;function u(e,r){l("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,l("cleanup"),t.removeListener("close",m),t.removeListener("finish",v),t.removeListener("drain",h),t.removeListener("error",y),t.removeListener("unpipe",u),n.removeListener("end",f),n.removeListener("end",g),n.removeListener("data",b),d=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function f(){l("onend"),t.end()}o.endEmitted?i.nextTick(c):n.once("end",c),t.on("unpipe",u);var h=function(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,I(t))}}(n);t.on("drain",h);var d=!1;var p=!1;function b(e){l("ondata"),p=!1,!1!==t.write(e)||p||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==C(o.pipes,t))&&!d&&(l("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,p=!0),n.pause())}function y(e){l("onerror",e),g(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function m(){t.removeListener("finish",v),g()}function v(){l("onfinish"),t.removeListener("close",m),g()}function g(){l("unpipe"),n.unpipe(t)}return n.on("data",b),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",m),t.once("finish",v),t.emit("pipe",n),o.flowing||(l("pipe resume"),n.resume()),t},v.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o-1?i:o.nextTick;m.WritableState=y;var u=Object.create(t("core-util-is"));u.inherits=t("inherits");var f={deprecate:t("util-deprecate")},h=t("./internal/streams/stream"),Buffer=t("safe-buffer").Buffer,l=n.Uint8Array||function(){};var d,p=t("./internal/streams/destroy");function b(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,f=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:f,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),S(t,e))}(t,r,n,e,i);else{var s=_(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||w(t,r),n?c(g,t,r,s,i):g(t,r,s,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function m(e){if(a=a||t("./_stream_duplex"),!(d.call(m,this)||this instanceof a))return new m(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),h.call(this)}function v(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function g(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),S(t,e)}function w(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),o=e.corkedRequestsFree;o.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,v(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,h=r.callback;if(v(t,e,!1,e.objectMode?1:u.length,u,f,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function E(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),S(t,e)})}function S(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,o.nextTick(E,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}u.inherits(m,h),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:f.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===m&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(t,e,r){var n,i=this._writableState,s=!1,a=!i.objectMode&&(n=t,Buffer.isBuffer(n)||n instanceof l);return a&&!Buffer.isBuffer(t)&&(t=function(t){return Buffer.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=b),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),o.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),o.nextTick(n,s),i=!1),i}(this,i,t,r))&&(i.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Buffer.from(e,r));return e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var c=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,S(t,e),r&&(e.finished?o.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":223,"./internal/streams/destroy":229,"./internal/streams/stream":230,_process:270,"core-util-is":116,inherits:258,"process-nextick-args":231,"safe-buffer":237,timers:348,"util-deprecate":356}],228:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,e.copy(r,n),s+=o.data.length,o=o.next;return i},t}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var t=n.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":237,util:219}],229:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":231}],230:[function(t,e,r){e.exports=t("events").EventEmitter},{events:220}],231:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;s>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],233:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":234}],234:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":223,"./lib/_stream_passthrough.js":224,"./lib/_stream_readable.js":225,"./lib/_stream_transform.js":226,"./lib/_stream_writable.js":227}],235:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":234}],236:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":227}],237:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],238:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",c));var s=!1;function a(){s||(s=!0,t.end())}function c(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function u(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",c),r.removeListener("error",u),t.removeListener("error",u),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",u),t.on("error",u),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t}},{events:220,inherits:258,"readable-stream/duplex.js":222,"readable-stream/passthrough.js":233,"readable-stream/readable.js":234,"readable-stream/transform.js":235,"readable-stream/writable.js":236}],239:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(Buffer.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=a,this.end=c,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=u,this.end=f,e=3;break;default:return this.write=h,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2)}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function a(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function u(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}r.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":237}],240:[function(t,e,r){arguments[4][24][0].apply(r,arguments)},{dup:24}],241:[function(t,e,r){arguments[4][25][0].apply(r,arguments)},{dup:25}],242:[function(t,e,r){arguments[4][26][0].apply(r,arguments)},{"./support/isBuffer":241,_process:270,dup:26,inherits:240}],243:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("readable-stream").Transform;function i(t){n.call(this),this._block=Buffer.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}t("inherits")(i,n),i.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},i.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},i.prototype.update=function(t,e){if(function(t,e){if(!Buffer.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(t)||(t=Buffer.from(t,e));for(var r=this._block,n=0;this._blockOffset+t.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},{inherits:258,"readable-stream":319,"safe-buffer":321}],244:[function(t,e,r){var n=r;n.utils=t("./hash/utils"),n.common=t("./hash/common"),n.sha=t("./hash/sha"),n.ripemd=t("./hash/ripemd"),n.hmac=t("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":245,"./hash/hmac":246,"./hash/ripemd":247,"./hash/sha":248,"./hash/utils":255}],245:[function(t,e,r){"use strict";var n=t("./utils"),i=t("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},{"../utils":255}],255:[function(t,e,r){"use strict";var n=t("minimalistic-assert"),i=t("inherits");function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},r.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(t,e){return t>>>e|t<<32-e},r.rotl32=function(t,e){return t<>>32-e},r.sum32=function(t,e){return t+e>>>0},r.sum32_3=function(t,e,r){return t+e+r>>>0},r.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},r.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},r.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},r.sum64_hi=function(t,e,r,n){return(e+n>>>0>>0},r.sum64_lo=function(t,e,r,n){return e+n>>>0},r.sum64_4_hi=function(t,e,r,n,i,o,s,a){var c=0,u=e;return c+=(u=u+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},r.sum64_5_hi=function(t,e,r,n,i,o,s,a,c,u){var f=0,h=e;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(t,e,r,n,i,o,s,a,c,u){return e+n+o+a+u>>>0},r.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},r.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},r.shr64_hi=function(t,e,r){return t>>>r},r.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},{inherits:258,"minimalistic-assert":265}],256:[function(t,e,r){"use strict";var n=t("hash.js"),i=t("minimalistic-crypto-utils"),o=t("minimalistic-assert");function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}e.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length>1,f=-7,h=r?i-1:0,l=r?-1:1,d=t[e+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?l/c:l*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*b}},{}],258:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],259:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],260:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],261:[function(t,e,r){(function(t){(function(){(function(){var n,i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",a="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",u=500,f="__lodash_placeholder__",h=1,l=2,d=4,p=1,b=2,y=1,m=2,v=4,g=8,w=16,_=32,E=64,S=128,k=256,A=512,x=30,M="...",T=800,I=16,P=1,B=2,R=1/0,C=9007199254740991,O=1.7976931348623157e308,L=NaN,j=4294967295,N=j-1,D=j>>>1,U=[["ary",S],["bind",y],["bindKey",m],["curry",g],["curryRight",w],["flip",A],["partial",_],["partialRight",E],["rearg",k]],K="[object Arguments]",H="[object Array]",q="[object AsyncFunction]",z="[object Boolean]",F="[object Date]",W="[object DOMException]",V="[object Error]",G="[object Function]",Y="[object GeneratorFunction]",J="[object Map]",Z="[object Number]",X="[object Null]",$="[object Object]",Q="[object Proxy]",tt="[object RegExp]",et="[object Set]",rt="[object String]",nt="[object Symbol]",it="[object Undefined]",ot="[object WeakMap]",st="[object WeakSet]",at="[object ArrayBuffer]",ct="[object DataView]",ut="[object Float32Array]",ft="[object Float64Array]",ht="[object Int8Array]",lt="[object Int16Array]",dt="[object Int32Array]",pt="[object Uint8Array]",bt="[object Uint8ClampedArray]",yt="[object Uint16Array]",mt="[object Uint32Array]",vt=/\b__p \+= '';/g,gt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,_t=/&(?:amp|lt|gt|quot|#39);/g,Et=/[&<>"']/g,St=RegExp(_t.source),kt=RegExp(Et.source),At=/<%-([\s\S]+?)%>/g,xt=/<%([\s\S]+?)%>/g,Mt=/<%=([\s\S]+?)%>/g,Tt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,It=/^\w*$/,Pt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Bt=/[\\^$.*+?()[\]{}|]/g,Rt=RegExp(Bt.source),Ct=/^\s+/,Ot=/\s/,Lt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jt=/\{\n\/\* \[wrapped with (.+)\] \*/,Nt=/,? & /,Dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ut=/[()=,{}\[\]\/\s]/,Kt=/\\(\\)?/g,Ht=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,qt=/\w*$/,zt=/^[-+]0x[0-9a-f]+$/i,Ft=/^0b[01]+$/i,Wt=/^\[object .+?Constructor\]$/,Vt=/^0o[0-7]+$/i,Gt=/^(?:0|[1-9]\d*)$/,Yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Jt=/($^)/,Zt=/['\n\r\u2028\u2029\\]/g,Xt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",$t="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Qt="[\\ud800-\\udfff]",te="["+$t+"]",ee="["+Xt+"]",re="\\d+",ne="[\\u2700-\\u27bf]",ie="[a-z\\xdf-\\xf6\\xf8-\\xff]",oe="[^\\ud800-\\udfff"+$t+re+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",se="\\ud83c[\\udffb-\\udfff]",ae="[^\\ud800-\\udfff]",ce="(?:\\ud83c[\\udde6-\\uddff]){2}",ue="[\\ud800-\\udbff][\\udc00-\\udfff]",fe="[A-Z\\xc0-\\xd6\\xd8-\\xde]",he="(?:"+ie+"|"+oe+")",le="(?:"+fe+"|"+oe+")",de="(?:"+ee+"|"+se+")"+"?",pe="[\\ufe0e\\ufe0f]?"+de+("(?:\\u200d(?:"+[ae,ce,ue].join("|")+")[\\ufe0e\\ufe0f]?"+de+")*"),be="(?:"+[ne,ce,ue].join("|")+")"+pe,ye="(?:"+[ae+ee+"?",ee,ce,ue,Qt].join("|")+")",me=RegExp("['’]","g"),ve=RegExp(ee,"g"),ge=RegExp(se+"(?="+se+")|"+ye+pe,"g"),we=RegExp([fe+"?"+ie+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[te,fe,"$"].join("|")+")",le+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[te,fe+he,"$"].join("|")+")",fe+"?"+he+"+(?:['’](?:d|ll|m|re|s|t|ve))?",fe+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",re,be].join("|"),"g"),_e=RegExp("[\\u200d\\ud800-\\udfff"+Xt+"\\ufe0e\\ufe0f]"),Ee=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ke=-1,Ae={};Ae[ut]=Ae[ft]=Ae[ht]=Ae[lt]=Ae[dt]=Ae[pt]=Ae[bt]=Ae[yt]=Ae[mt]=!0,Ae[K]=Ae[H]=Ae[at]=Ae[z]=Ae[ct]=Ae[F]=Ae[V]=Ae[G]=Ae[J]=Ae[Z]=Ae[$]=Ae[tt]=Ae[et]=Ae[rt]=Ae[ot]=!1;var xe={};xe[K]=xe[H]=xe[at]=xe[ct]=xe[z]=xe[F]=xe[ut]=xe[ft]=xe[ht]=xe[lt]=xe[dt]=xe[J]=xe[Z]=xe[$]=xe[tt]=xe[et]=xe[rt]=xe[nt]=xe[pt]=xe[bt]=xe[yt]=xe[mt]=!0,xe[V]=xe[G]=xe[ot]=!1;var Me={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Te=parseFloat,Ie=parseInt,Pe="object"==typeof t&&t&&t.Object===Object&&t,Be="object"==typeof self&&self&&self.Object===Object&&self,Re=Pe||Be||Function("return this")(),Ce="object"==typeof r&&r&&!r.nodeType&&r,Oe=Ce&&"object"==typeof e&&e&&!e.nodeType&&e,Le=Oe&&Oe.exports===Ce,je=Le&&Pe.process,Ne=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||je&&je.binding&&je.binding("util")}catch(t){}}(),De=Ne&&Ne.isArrayBuffer,Ue=Ne&&Ne.isDate,Ke=Ne&&Ne.isMap,He=Ne&&Ne.isRegExp,qe=Ne&&Ne.isSet,ze=Ne&&Ne.isTypedArray;function Fe(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function We(t,e,r,n){for(var i=-1,o=null==t?0:t.length;++i-1}function Xe(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function wr(t,e){for(var r=t.length;r--&&sr(e,t[r],0)>-1;);return r}var _r=hr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Er=hr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Sr(t){return"\\"+Me[t]}function kr(t){return _e.test(t)}function Ar(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function xr(t,e){return function(r){return t(e(r))}}function Mr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var Or=function t(e){var r,Ot=(e=null==e?Re:Or.defaults(Re.Object(),e,Or.pick(Re,Se))).Array,Xt=e.Date,$t=e.Error,Qt=e.Function,te=e.Math,ee=e.Object,re=e.RegExp,ne=e.String,ie=e.TypeError,oe=Ot.prototype,se=Qt.prototype,ae=ee.prototype,ce=e["__core-js_shared__"],ue=se.toString,fe=ae.hasOwnProperty,he=0,le=(r=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",de=ae.toString,pe=ue.call(ee),be=Re._,ye=re("^"+ue.call(fe).replace(Bt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Buffer=Le?e.Buffer:n,ge=e.Symbol,_e=e.Uint8Array,Me=Buffer?Buffer.allocUnsafe:n,Pe=xr(ee.getPrototypeOf,ee),Be=ee.create,Ce=ae.propertyIsEnumerable,Oe=oe.splice,je=ge?ge.isConcatSpreadable:n,Ne=ge?ge.iterator:n,nr=ge?ge.toStringTag:n,hr=function(){try{var t=Ko(ee,"defineProperty");return t({},"",{}),t}catch(t){}}(),Lr=e.clearTimeout!==Re.clearTimeout&&e.clearTimeout,jr=Xt&&Xt.now!==Re.Date.now&&Xt.now,Nr=e.setTimeout!==Re.setTimeout&&e.setTimeout,Dr=te.ceil,Ur=te.floor,Kr=ee.getOwnPropertySymbols,Hr=Buffer?Buffer.isBuffer:n,qr=e.isFinite,zr=oe.join,Fr=xr(ee.keys,ee),Wr=te.max,Vr=te.min,Gr=Xt.now,Yr=e.parseInt,Jr=te.random,Zr=oe.reverse,Xr=Ko(e,"DataView"),$r=Ko(e,"Map"),Qr=Ko(e,"Promise"),tn=Ko(e,"Set"),en=Ko(e,"WeakMap"),rn=Ko(ee,"create"),nn=en&&new en,on={},sn=ls(Xr),an=ls($r),cn=ls(Qr),un=ls(tn),fn=ls(en),hn=ge?ge.prototype:n,ln=hn?hn.valueOf:n,dn=hn?hn.toString:n;function pn(t){if(Ia(t)&&!va(t)&&!(t instanceof vn)){if(t instanceof mn)return t;if(fe.call(t,"__wrapped__"))return ds(t)}return new mn(t)}var bn=function(){function t(){}return function(e){if(!Ta(e))return{};if(Be)return Be(e);t.prototype=e;var r=new t;return t.prototype=n,r}}();function yn(){}function mn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=n}function vn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function gn(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function jn(t,e,r,i,o,s){var a,c=e&h,u=e&l,f=e&d;if(r&&(a=o?r(t,i,o,s):r(t)),a!==n)return a;if(!Ta(t))return t;var p=va(t);if(p){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&fe.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return no(t,a)}else{var b=zo(t),y=b==G||b==Y;if(Ea(t))return Xi(t,c);if(b==$||b==K||y&&!o){if(a=u||y?{}:Wo(t),!c)return u?function(t,e){return io(t,qo(t),e)}(t,function(t,e){return t&&io(e,sc(e),t)}(a,t)):function(t,e){return io(t,Ho(t),e)}(t,Rn(a,t))}else{if(!xe[b])return o?t:{};a=function(t,e,r){var n,i,o,s=t.constructor;switch(e){case at:return $i(t);case z:case F:return new s(+t);case ct:return function(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case ut:case ft:case ht:case lt:case dt:case pt:case bt:case yt:case mt:return Qi(t,r);case J:return new s;case Z:case rt:return new s(t);case tt:return(o=new(i=t).constructor(i.source,qt.exec(i))).lastIndex=i.lastIndex,o;case et:return new s;case nt:return n=t,ln?ee(ln.call(n)):{}}}(t,b,c)}}s||(s=new Sn);var m=s.get(t);if(m)return m;s.set(t,a),Oa(t)?t.forEach(function(n){a.add(jn(n,e,r,n,t,s))}):Pa(t)&&t.forEach(function(n,i){a.set(i,jn(n,e,r,i,t,s))});var v=p?n:(f?u?Co:Ro:u?sc:oc)(t);return Ve(v||t,function(n,i){v&&(n=t[i=n]),In(a,i,jn(n,e,r,i,t,s))}),a}function Nn(t,e,r){var i=r.length;if(null==t)return!i;for(t=ee(t);i--;){var o=r[i],s=e[o],a=t[o];if(a===n&&!(o in t)||!s(a))return!1}return!0}function Dn(t,e,r){if("function"!=typeof t)throw new ie(s);return os(function(){t.apply(n,r)},e)}function Un(t,e,r,n){var o=-1,s=Ze,a=!0,c=t.length,u=[],f=e.length;if(!c)return u;r&&(e=$e(e,yr(r))),n?(s=Xe,a=!1):e.length>=i&&(s=vr,a=!1,e=new En(e));t:for(;++o-1},wn.prototype.set=function(t,e){var r=this.__data__,n=Pn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new gn,map:new($r||wn),string:new gn}},_n.prototype.delete=function(t){var e=Do(this,t).delete(t);return this.size-=e?1:0,e},_n.prototype.get=function(t){return Do(this,t).get(t)},_n.prototype.has=function(t){return Do(this,t).has(t)},_n.prototype.set=function(t,e){var r=Do(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},En.prototype.add=En.prototype.push=function(t){return this.__data__.set(t,c),this},En.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.clear=function(){this.__data__=new wn,this.size=0},Sn.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Sn.prototype.get=function(t){return this.__data__.get(t)},Sn.prototype.has=function(t){return this.__data__.has(t)},Sn.prototype.set=function(t,e){var r=this.__data__;if(r instanceof wn){var n=r.__data__;if(!$r||n.length0&&r(a)?e>1?Wn(a,e-1,r,n,i):Qe(i,a):n||(i[i.length]=a)}return i}var Vn=co(),Gn=co(!0);function Yn(t,e){return t&&Vn(t,e,oc)}function Jn(t,e){return t&&Gn(t,e,oc)}function Zn(t,e){return Je(e,function(e){return Aa(t[e])})}function Xn(t,e){for(var r=0,i=(e=Gi(e,t)).length;null!=t&&re}function ei(t,e){return null!=t&&fe.call(t,e)}function ri(t,e){return null!=t&&e in ee(t)}function ni(t,e,r){for(var i=r?Xe:Ze,o=t[0].length,s=t.length,a=s,c=Ot(s),u=1/0,f=[];a--;){var h=t[a];a&&e&&(h=$e(h,yr(e))),u=Vr(h.length,u),c[a]=!r&&(e||o>=120&&h.length>=120)?new En(a&&h):n}h=t[0];var l=-1,d=c[0];t:for(;++l=a)return c;var u=r[n];return c*("desc"==u?-1:1)}}return t.index-e.index}(t,e,r)})}function gi(t,e,r){for(var n=-1,i=e.length,o={};++n-1;)a!==t&&Oe.call(a,c,1),Oe.call(t,c,1);return t}function _i(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==o){var o=i;Go(i)?Oe.call(t,i,1):Ui(t,i)}}return t}function Ei(t,e){return t+Ur(Jr()*(e-t+1))}function Si(t,e){var r="";if(!t||e<1||e>C)return r;do{e%2&&(r+=t),(e=Ur(e/2))&&(t+=t)}while(e);return r}function ki(t,e){return ss(es(t,e,Bc),t+"")}function Ai(t){return An(pc(t))}function xi(t,e){var r=pc(t);return us(r,Ln(e,0,r.length))}function Mi(t,e,r,i){if(!Ta(t))return t;for(var o=-1,s=(e=Gi(e,t)).length,a=s-1,c=t;null!=c&&++oi?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Ot(i);++n>>1,s=t[o];null!==s&&!ja(s)&&(r?s<=e:s=i){var f=e?null:ko(t);if(f)return Tr(f);a=!1,o=vr,u=new En}else u=e?[]:c;t:for(;++n=i?t:Bi(t,e,r)}var Zi=Lr||function(t){return Re.clearTimeout(t)};function Xi(t,e){if(e)return t.slice();var r=t.length,n=Me?Me(r):new t.constructor(r);return t.copy(n),n}function $i(t){var e=new t.constructor(t.byteLength);return new _e(e).set(new _e(t)),e}function Qi(t,e){var r=e?$i(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function to(t,e){if(t!==e){var r=t!==n,i=null===t,o=t==t,s=ja(t),a=e!==n,c=null===e,u=e==e,f=ja(e);if(!c&&!f&&!s&&t>e||s&&a&&u&&!c&&!f||i&&a&&u||!r&&u||!o)return 1;if(!i&&!s&&!f&&t1?r[o-1]:n,a=o>2?r[2]:n;for(s=t.length>3&&"function"==typeof s?(o--,s):n,a&&Yo(r[0],r[1],a)&&(s=o<3?n:s,o=1),e=ee(e);++i-1?o[s?e[a]:a]:n}}function po(t){return Bo(function(e){var r=e.length,i=r,o=mn.prototype.thru;for(t&&e.reverse();i--;){var a=e[i];if("function"!=typeof a)throw new ie(s);if(o&&!c&&"wrapper"==Lo(a))var c=new mn([],!0)}for(i=c?i:r;++i1&&g.reverse(),h&&uc))return!1;var f=s.get(t),h=s.get(e);if(f&&h)return f==e&&h==t;var l=-1,d=!0,y=r&b?new En:n;for(s.set(t,e),s.set(e,t);++l-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Lt,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return Ve(U,function(r){var n="_."+r[0];e&r[1]&&!Ze(t,n)&&t.push(n)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(Nt):[]}(n),r)))}function cs(t){var e=0,r=0;return function(){var i=Gr(),o=I-(i-r);if(r=i,o>0){if(++e>=T)return arguments[0]}else e=0;return t.apply(n,arguments)}}function us(t,e){var r=-1,i=t.length,o=i-1;for(e=e===n?i:e;++r1?t[e-1]:n;return Cs(t,r="function"==typeof r?(t.pop(),r):n)});function Ks(t){var e=pn(t);return e.__chain__=!0,e}function Hs(t,e){return e(t)}var qs=Bo(function(t){var e=t.length,r=e?t[0]:0,i=this.__wrapped__,o=function(e){return On(e,t)};return!(e>1||this.__actions__.length)&&i instanceof vn&&Go(r)?((i=i.slice(r,+r+(e?1:0))).__actions__.push({func:Hs,args:[o],thisArg:n}),new mn(i,this.__chain__).thru(function(t){return e&&!t.length&&t.push(n),t})):this.thru(o)});var zs=oo(function(t,e,r){fe.call(t,r)?++t[r]:Cn(t,r,1)});var Fs=lo(ms),Ws=lo(vs);function Vs(t,e){return(va(t)?Ve:Kn)(t,No(e,3))}function Gs(t,e){return(va(t)?Ge:Hn)(t,No(e,3))}var Ys=oo(function(t,e,r){fe.call(t,r)?t[r].push(e):Cn(t,r,[e])});var Js=ki(function(t,e,r){var n=-1,i="function"==typeof e,o=wa(t)?Ot(t.length):[];return Kn(t,function(t){o[++n]=i?Fe(e,t,r):ii(t,e,r)}),o}),Zs=oo(function(t,e,r){Cn(t,r,e)});function Xs(t,e){return(va(t)?$e:di)(t,No(e,3))}var $s=oo(function(t,e,r){t[r?0:1].push(e)},function(){return[[],[]]});var Qs=ki(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Yo(t,e[0],e[1])?e=[]:r>2&&Yo(e[0],e[1],e[2])&&(e=[e[0]]),vi(t,Wn(e,1),[])}),ta=jr||function(){return Re.Date.now()};function ea(t,e,r){return e=r?n:e,e=t&&null==e?t.length:e,xo(t,S,n,n,n,n,e)}function ra(t,e){var r;if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=n),r}}var na=ki(function(t,e,r){var n=y;if(r.length){var i=Mr(r,jo(na));n|=_}return xo(t,n,e,r,i)}),ia=ki(function(t,e,r){var n=y|m;if(r.length){var i=Mr(r,jo(ia));n|=_}return xo(e,n,t,r,i)});function oa(t,e,r){var i,o,a,c,u,f,h=0,l=!1,d=!1,p=!0;if("function"!=typeof t)throw new ie(s);function b(e){var r=i,s=o;return i=o=n,h=e,c=t.apply(s,r)}function y(t){var r=t-f;return f===n||r>=e||r<0||d&&t-h>=a}function m(){var t=ta();if(y(t))return v(t);u=os(m,function(t){var r=e-(t-f);return d?Vr(r,a-(t-h)):r}(t))}function v(t){return u=n,p&&i?b(t):(i=o=n,c)}function g(){var t=ta(),r=y(t);if(i=arguments,o=this,f=t,r){if(u===n)return function(t){return h=t,u=os(m,e),l?b(t):c}(f);if(d)return Zi(u),u=os(m,e),b(f)}return u===n&&(u=os(m,e)),c}return e=Fa(e)||0,Ta(r)&&(l=!!r.leading,a=(d="maxWait"in r)?Wr(Fa(r.maxWait)||0,e):a,p="trailing"in r?!!r.trailing:p),g.cancel=function(){u!==n&&Zi(u),h=0,i=f=o=u=n},g.flush=function(){return u===n?c:v(ta())},g}var sa=ki(function(t,e){return Dn(t,1,e)}),aa=ki(function(t,e,r){return Dn(t,Fa(e)||0,r)});function ca(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new ie(s);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ca.Cache||_n),r}function ua(t){if("function"!=typeof t)throw new ie(s);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}ca.Cache=_n;var fa=Yi(function(t,e){var r=(e=1==e.length&&va(e[0])?$e(e[0],yr(No())):$e(Wn(e,1),yr(No()))).length;return ki(function(n){for(var i=-1,o=Vr(n.length,r);++i=e}),ma=oi(function(){return arguments}())?oi:function(t){return Ia(t)&&fe.call(t,"callee")&&!Ce.call(t,"callee")},va=Ot.isArray,ga=De?yr(De):function(t){return Ia(t)&&Qn(t)==at};function wa(t){return null!=t&&Ma(t.length)&&!Aa(t)}function _a(t){return Ia(t)&&wa(t)}var Ea=Hr||Fc,Sa=Ue?yr(Ue):function(t){return Ia(t)&&Qn(t)==F};function ka(t){if(!Ia(t))return!1;var e=Qn(t);return e==V||e==W||"string"==typeof t.message&&"string"==typeof t.name&&!Ra(t)}function Aa(t){if(!Ta(t))return!1;var e=Qn(t);return e==G||e==Y||e==q||e==Q}function xa(t){return"number"==typeof t&&t==qa(t)}function Ma(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=C}function Ta(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ia(t){return null!=t&&"object"==typeof t}var Pa=Ke?yr(Ke):function(t){return Ia(t)&&zo(t)==J};function Ba(t){return"number"==typeof t||Ia(t)&&Qn(t)==Z}function Ra(t){if(!Ia(t)||Qn(t)!=$)return!1;var e=Pe(t);if(null===e)return!0;var r=fe.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&ue.call(r)==pe}var Ca=He?yr(He):function(t){return Ia(t)&&Qn(t)==tt};var Oa=qe?yr(qe):function(t){return Ia(t)&&zo(t)==et};function La(t){return"string"==typeof t||!va(t)&&Ia(t)&&Qn(t)==rt}function ja(t){return"symbol"==typeof t||Ia(t)&&Qn(t)==nt}var Na=ze?yr(ze):function(t){return Ia(t)&&Ma(t.length)&&!!Ae[Qn(t)]};var Da=_o(li),Ua=_o(function(t,e){return t<=e});function Ka(t){if(!t)return[];if(wa(t))return La(t)?Br(t):no(t);if(Ne&&t[Ne])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Ne]());var e=zo(t);return(e==J?Ar:e==et?Tr:pc)(t)}function Ha(t){return t?(t=Fa(t))===R||t===-R?(t<0?-1:1)*O:t==t?t:0:0===t?t:0}function qa(t){var e=Ha(t),r=e%1;return e==e?r?e-r:e:0}function za(t){return t?Ln(qa(t),0,j):0}function Fa(t){if("number"==typeof t)return t;if(ja(t))return L;if(Ta(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ta(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=br(t);var r=Ft.test(t);return r||Vt.test(t)?Ie(t.slice(2),r?2:8):zt.test(t)?L:+t}function Wa(t){return io(t,sc(t))}function Va(t){return null==t?"":Ni(t)}var Ga=so(function(t,e){if($o(e)||wa(e))io(e,oc(e),t);else for(var r in e)fe.call(e,r)&&In(t,r,e[r])}),Ya=so(function(t,e){io(e,sc(e),t)}),Ja=so(function(t,e,r,n){io(e,sc(e),t,n)}),Za=so(function(t,e,r,n){io(e,oc(e),t,n)}),Xa=Bo(On);var $a=ki(function(t,e){t=ee(t);var r=-1,i=e.length,o=i>2?e[2]:n;for(o&&Yo(e[0],e[1],o)&&(i=1);++r1),e}),io(t,Co(t),r),n&&(r=jn(r,h|l|d,Io));for(var i=e.length;i--;)Ui(r,e[i]);return r});var fc=Bo(function(t,e){return null==t?{}:function(t,e){return gi(t,e,function(e,r){return ec(t,r)})}(t,e)});function hc(t,e){if(null==t)return{};var r=$e(Co(t),function(t){return[t]});return e=No(e),gi(t,r,function(t,r){return e(t,r[0])})}var lc=Ao(oc),dc=Ao(sc);function pc(t){return null==t?[]:mr(t,oc(t))}var bc=fo(function(t,e,r){return e=e.toLowerCase(),t+(r?yc(e):e)});function yc(t){return kc(Va(t).toLowerCase())}function mc(t){return(t=Va(t))&&t.replace(Yt,_r).replace(ve,"")}var vc=fo(function(t,e,r){return t+(r?"-":"")+e.toLowerCase()}),gc=fo(function(t,e,r){return t+(r?" ":"")+e.toLowerCase()}),wc=uo("toLowerCase");var _c=fo(function(t,e,r){return t+(r?"_":"")+e.toLowerCase()});var Ec=fo(function(t,e,r){return t+(r?" ":"")+kc(e)});var Sc=fo(function(t,e,r){return t+(r?" ":"")+e.toUpperCase()}),kc=uo("toUpperCase");function Ac(t,e,r){return t=Va(t),(e=r?n:e)===n?function(t){return Ee.test(t)}(t)?function(t){return t.match(we)||[]}(t):function(t){return t.match(Dt)||[]}(t):t.match(e)||[]}var xc=ki(function(t,e){try{return Fe(t,n,e)}catch(t){return ka(t)?t:new $t(t)}}),Mc=Bo(function(t,e){return Ve(e,function(e){e=hs(e),Cn(t,e,na(t[e],t))}),t});function Tc(t){return function(){return t}}var Ic=po(),Pc=po(!0);function Bc(t){return t}function Rc(t){return ui("function"==typeof t?t:jn(t,h))}var Cc=ki(function(t,e){return function(r){return ii(r,t,e)}}),Oc=ki(function(t,e){return function(r){return ii(t,r,e)}});function Lc(t,e,r){var n=oc(e),i=Zn(e,n);null!=r||Ta(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=Zn(e,oc(e)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(t);return Ve(i,function(r){var n=e[r];t[r]=n,s&&(t.prototype[r]=function(){var e=this.__chain__;if(o||e){var r=t(this.__wrapped__);return(r.__actions__=no(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,Qe([this.value()],arguments))})}),t}function jc(){}var Nc=vo($e),Dc=vo(Ye),Uc=vo(rr);function Kc(t){return Jo(t)?fr(hs(t)):function(t){return function(e){return Xn(e,t)}}(t)}var Hc=wo(),qc=wo(!0);function zc(){return[]}function Fc(){return!1}var Wc=mo(function(t,e){return t+e},0),Vc=So("ceil"),Gc=mo(function(t,e){return t/e},1),Yc=So("floor");var Jc,Zc=mo(function(t,e){return t*e},1),Xc=So("round"),$c=mo(function(t,e){return t-e},0);return pn.after=function(t,e){if("function"!=typeof e)throw new ie(s);return t=qa(t),function(){if(--t<1)return e.apply(this,arguments)}},pn.ary=ea,pn.assign=Ga,pn.assignIn=Ya,pn.assignInWith=Ja,pn.assignWith=Za,pn.at=Xa,pn.before=ra,pn.bind=na,pn.bindAll=Mc,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return va(t)?t:[t]},pn.chain=Ks,pn.chunk=function(t,e,r){e=(r?Yo(t,e,r):e===n)?1:Wr(qa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var o=0,s=0,a=Ot(Dr(i/e));oo?0:o+r),(i=i===n||i>o?o:qa(i))<0&&(i+=o),i=r>i?0:za(i);r>>0)?(t=Va(t))&&("string"==typeof e||null!=e&&!Ca(e))&&!(e=Ni(e))&&kr(t)?Ji(Br(t),0,r):t.split(e,r):[]},pn.spread=function(t,e){if("function"!=typeof t)throw new ie(s);return e=null==e?0:Wr(qa(e),0),ki(function(r){var n=r[e],i=Ji(r,0,e);return n&&Qe(i,n),Fe(t,this,i)})},pn.tail=function(t){var e=null==t?0:t.length;return e?Bi(t,1,e):[]},pn.take=function(t,e,r){return t&&t.length?Bi(t,0,(e=r||e===n?1:qa(e))<0?0:e):[]},pn.takeRight=function(t,e,r){var i=null==t?0:t.length;return i?Bi(t,(e=i-(e=r||e===n?1:qa(e)))<0?0:e,i):[]},pn.takeRightWhile=function(t,e){return t&&t.length?Hi(t,No(e,3),!1,!0):[]},pn.takeWhile=function(t,e){return t&&t.length?Hi(t,No(e,3)):[]},pn.tap=function(t,e){return e(t),t},pn.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new ie(s);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(t,e,{leading:n,maxWait:e,trailing:i})},pn.thru=Hs,pn.toArray=Ka,pn.toPairs=lc,pn.toPairsIn=dc,pn.toPath=function(t){return va(t)?$e(t,hs):ja(t)?[t]:no(fs(Va(t)))},pn.toPlainObject=Wa,pn.transform=function(t,e,r){var n=va(t),i=n||Ea(t)||Na(t);if(e=No(e,4),null==r){var o=t&&t.constructor;r=i?n?new o:[]:Ta(t)&&Aa(o)?bn(Pe(t)):{}}return(i?Ve:Yn)(t,function(t,n,i){return e(r,t,n,i)}),r},pn.unary=function(t){return ea(t,1)},pn.union=Is,pn.unionBy=Ps,pn.unionWith=Bs,pn.uniq=function(t){return t&&t.length?Di(t):[]},pn.uniqBy=function(t,e){return t&&t.length?Di(t,No(e,2)):[]},pn.uniqWith=function(t,e){return e="function"==typeof e?e:n,t&&t.length?Di(t,n,e):[]},pn.unset=function(t,e){return null==t||Ui(t,e)},pn.unzip=Rs,pn.unzipWith=Cs,pn.update=function(t,e,r){return null==t?t:Ki(t,e,Vi(r))},pn.updateWith=function(t,e,r,i){return i="function"==typeof i?i:n,null==t?t:Ki(t,e,Vi(r),i)},pn.values=pc,pn.valuesIn=function(t){return null==t?[]:mr(t,sc(t))},pn.without=Os,pn.words=Ac,pn.wrap=function(t,e){return ha(Vi(e),t)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ns,pn.zip=Ds,pn.zipObject=function(t,e){return Fi(t||[],e||[],In)},pn.zipObjectDeep=function(t,e){return Fi(t||[],e||[],Mi)},pn.zipWith=Us,pn.entries=lc,pn.entriesIn=dc,pn.extend=Ya,pn.extendWith=Ja,Lc(pn,pn),pn.add=Wc,pn.attempt=xc,pn.camelCase=bc,pn.capitalize=yc,pn.ceil=Vc,pn.clamp=function(t,e,r){return r===n&&(r=e,e=n),r!==n&&(r=(r=Fa(r))==r?r:0),e!==n&&(e=(e=Fa(e))==e?e:0),Ln(Fa(t),e,r)},pn.clone=function(t){return jn(t,d)},pn.cloneDeep=function(t){return jn(t,h|d)},pn.cloneDeepWith=function(t,e){return jn(t,h|d,e="function"==typeof e?e:n)},pn.cloneWith=function(t,e){return jn(t,d,e="function"==typeof e?e:n)},pn.conformsTo=function(t,e){return null==e||Nn(t,e,oc(e))},pn.deburr=mc,pn.defaultTo=function(t,e){return null==t||t!=t?e:t},pn.divide=Gc,pn.endsWith=function(t,e,r){t=Va(t),e=Ni(e);var i=t.length,o=r=r===n?i:Ln(qa(r),0,i);return(r-=e.length)>=0&&t.slice(r,o)==e},pn.eq=pa,pn.escape=function(t){return(t=Va(t))&&kt.test(t)?t.replace(Et,Er):t},pn.escapeRegExp=function(t){return(t=Va(t))&&Rt.test(t)?t.replace(Bt,"\\$&"):t},pn.every=function(t,e,r){var i=va(t)?Ye:qn;return r&&Yo(t,e,r)&&(e=n),i(t,No(e,3))},pn.find=Fs,pn.findIndex=ms,pn.findKey=function(t,e){return ir(t,No(e,3),Yn)},pn.findLast=Ws,pn.findLastIndex=vs,pn.findLastKey=function(t,e){return ir(t,No(e,3),Jn)},pn.floor=Yc,pn.forEach=Vs,pn.forEachRight=Gs,pn.forIn=function(t,e){return null==t?t:Vn(t,No(e,3),sc)},pn.forInRight=function(t,e){return null==t?t:Gn(t,No(e,3),sc)},pn.forOwn=function(t,e){return t&&Yn(t,No(e,3))},pn.forOwnRight=function(t,e){return t&&Jn(t,No(e,3))},pn.get=tc,pn.gt=ba,pn.gte=ya,pn.has=function(t,e){return null!=t&&Fo(t,e,ei)},pn.hasIn=ec,pn.head=ws,pn.identity=Bc,pn.includes=function(t,e,r,n){t=wa(t)?t:pc(t),r=r&&!n?qa(r):0;var i=t.length;return r<0&&(r=Wr(i+r,0)),La(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&sr(t,e,r)>-1},pn.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:qa(r);return i<0&&(i=Wr(n+i,0)),sr(t,e,i)},pn.inRange=function(t,e,r){return e=Ha(e),r===n?(r=e,e=0):r=Ha(r),function(t,e,r){return t>=Vr(e,r)&&t=-C&&t<=C},pn.isSet=Oa,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Na,pn.isUndefined=function(t){return t===n},pn.isWeakMap=function(t){return Ia(t)&&zo(t)==ot},pn.isWeakSet=function(t){return Ia(t)&&Qn(t)==st},pn.join=function(t,e){return null==t?"":zr.call(t,e)},pn.kebabCase=vc,pn.last=ks,pn.lastIndexOf=function(t,e,r){var i=null==t?0:t.length;if(!i)return-1;var o=i;return r!==n&&(o=(o=qa(r))<0?Wr(i+o,0):Vr(o,i-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,o):or(t,cr,o,!0)},pn.lowerCase=gc,pn.lowerFirst=wc,pn.lt=Da,pn.lte=Ua,pn.max=function(t){return t&&t.length?zn(t,Bc,ti):n},pn.maxBy=function(t,e){return t&&t.length?zn(t,No(e,2),ti):n},pn.mean=function(t){return ur(t,Bc)},pn.meanBy=function(t,e){return ur(t,No(e,2))},pn.min=function(t){return t&&t.length?zn(t,Bc,li):n},pn.minBy=function(t,e){return t&&t.length?zn(t,No(e,2),li):n},pn.stubArray=zc,pn.stubFalse=Fc,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Zc,pn.nth=function(t,e){return t&&t.length?mi(t,qa(e)):n},pn.noConflict=function(){return Re._===this&&(Re._=be),this},pn.noop=jc,pn.now=ta,pn.pad=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return go(Ur(i),r)+t+go(Dr(i),r)},pn.padEnd=function(t,e,r){t=Va(t);var n=(e=qa(e))?Pr(t):0;return e&&ne){var i=t;t=e,e=i}if(r||t%1||e%1){var o=Jr();return Vr(t+o*(e-t+Te("1e-"+((o+"").length-1))),e)}return Ei(t,e)},pn.reduce=function(t,e,r){var n=va(t)?tr:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Kn)},pn.reduceRight=function(t,e,r){var n=va(t)?er:lr,i=arguments.length<3;return n(t,No(e,4),r,i,Hn)},pn.repeat=function(t,e,r){return e=(r?Yo(t,e,r):e===n)?1:qa(e),Si(Va(t),e)},pn.replace=function(){var t=arguments,e=Va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},pn.result=function(t,e,r){var i=-1,o=(e=Gi(e,t)).length;for(o||(o=1,t=n);++iC)return[];var r=j,n=Vr(t,j);e=No(e),t-=j;for(var i=pr(n,e);++r=s)return t;var c=r-Pr(i);if(c<1)return i;var u=a?Ji(a,0,c).join(""):t.slice(0,c);if(o===n)return u+i;if(a&&(c+=u.length-c),Ca(o)){if(t.slice(c).search(o)){var f,h=u;for(o.global||(o=re(o.source,Va(qt.exec(o))+"g")),o.lastIndex=0;f=o.exec(h);)var l=f.index;u=u.slice(0,l===n?c:l)}}else if(t.indexOf(Ni(o),c)!=c){var d=u.lastIndexOf(o);d>-1&&(u=u.slice(0,d))}return u+i},pn.unescape=function(t){return(t=Va(t))&&St.test(t)?t.replace(_t,Cr):t},pn.uniqueId=function(t){var e=++he;return Va(t)+e},pn.upperCase=Sc,pn.upperFirst=kc,pn.each=Vs,pn.eachRight=Gs,pn.first=ws,Lc(pn,(Jc={},Yn(pn,function(t,e){fe.call(pn.prototype,e)||(Jc[e]=t)}),Jc),{chain:!1}),pn.VERSION="4.17.21",Ve(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){pn[t].placeholder=pn}),Ve(["drop","take"],function(t,e){vn.prototype[t]=function(r){r=r===n?1:Wr(qa(r),0);var i=this.__filtered__&&!e?new vn(this):this.clone();return i.__filtered__?i.__takeCount__=Vr(r,i.__takeCount__):i.__views__.push({size:Vr(r,j),type:t+(i.__dir__<0?"Right":"")}),i},vn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ve(["filter","map","takeWhile"],function(t,e){var r=e+1,n=r==P||3==r;vn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:No(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}}),Ve(["head","last"],function(t,e){var r="take"+(e?"Right":"");vn.prototype[t]=function(){return this[r](1).value()[0]}}),Ve(["initial","tail"],function(t,e){var r="drop"+(e?"":"Right");vn.prototype[t]=function(){return this.__filtered__?new vn(this):this[r](1)}}),vn.prototype.compact=function(){return this.filter(Bc)},vn.prototype.find=function(t){return this.filter(t).head()},vn.prototype.findLast=function(t){return this.reverse().find(t)},vn.prototype.invokeMap=ki(function(t,e){return"function"==typeof t?new vn(this):this.map(function(r){return ii(r,t,e)})}),vn.prototype.reject=function(t){return this.filter(ua(No(t)))},vn.prototype.slice=function(t,e){t=qa(t);var r=this;return r.__filtered__&&(t>0||e<0)?new vn(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==n&&(r=(e=qa(e))<0?r.dropRight(-e):r.take(e-t)),r)},vn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},vn.prototype.toArray=function(){return this.take(j)},Yn(vn.prototype,function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),o=pn[i?"take"+("last"==e?"Right":""):e],s=i||/^find/.test(e);o&&(pn.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,c=e instanceof vn,u=a[0],f=c||va(e),h=function(t){var e=o.apply(pn,Qe([t],a));return i&&l?e[0]:e};f&&r&&"function"==typeof u&&1!=u.length&&(c=f=!1);var l=this.__chain__,d=!!this.__actions__.length,p=s&&!l,b=c&&!d;if(!s&&f){e=b?e:new vn(this);var y=t.apply(e,a);return y.__actions__.push({func:Hs,args:[h],thisArg:n}),new mn(y,l)}return p&&b?t.apply(this,a):(y=this.thru(h),p?i?y.value()[0]:y.value():y)})}),Ve(["pop","push","shift","sort","splice","unshift"],function(t){var e=oe[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);pn.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(va(i)?i:[],t)}return this[r](function(r){return e.apply(va(r)?r:[],t)})}}),Yn(vn.prototype,function(t,e){var r=pn[e];if(r){var n=r.name+"";fe.call(on,n)||(on[n]=[]),on[n].push({name:e,func:r})}}),on[bo(n,m).name]=[{name:"wrapper",func:n}],vn.prototype.clone=function(){var t=new vn(this.__wrapped__);return t.__actions__=no(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=no(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=no(this.__views__),t},vn.prototype.reverse=function(){if(this.__filtered__){var t=new vn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},vn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=va(t),n=e<0,i=r?t.length:0,o=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?n:this.__values__[this.__index__++]}},pn.prototype.plant=function(t){for(var e,r=this;r instanceof yn;){var i=ds(r);i.__index__=0,i.__values__=n,e?o.__wrapped__=i:e=i;var o=i;r=r.__wrapped__}return o.__wrapped__=t,e},pn.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof vn){var e=t;return this.__actions__.length&&(e=new vn(this)),(e=e.reverse()).__actions__.push({func:Hs,args:[Ts],thisArg:n}),new mn(e,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return qi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Ne&&(pn.prototype[Ne]=function(){return this}),pn}();Oe?((Oe.exports=Or)._=Or,Ce._=Or):Re._=Or}).call(this)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],262:[function(t,e,r){"use strict";var n=t("inherits"),i=t("hash-base"),Buffer=t("safe-buffer").Buffer,o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(t,e){return t<>>32-e}function c(t,e,r,n,i,o,s){return a(t+(e&r|~e&n)+i+o|0,s)+e|0}function u(t,e,r,n,i,o,s){return a(t+(e&n|r&~n)+i+o|0,s)+e|0}function f(t,e,r,n,i,o,s){return a(t+(e^r^n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return a(t+(r^(e|~n))+i+o|0,s)+e|0}n(s,i),s.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,s=this._d;n=h(n=h(n=h(n=h(n=f(n=f(n=f(n=f(n=u(n=u(n=u(n=u(n=c(n=c(n=c(n=c(n,i=c(i,s=c(s,r=c(r,n,i,s,t[0],3614090360,7),n,i,t[1],3905402710,12),r,n,t[2],606105819,17),s,r,t[3],3250441966,22),i=c(i,s=c(s,r=c(r,n,i,s,t[4],4118548399,7),n,i,t[5],1200080426,12),r,n,t[6],2821735955,17),s,r,t[7],4249261313,22),i=c(i,s=c(s,r=c(r,n,i,s,t[8],1770035416,7),n,i,t[9],2336552879,12),r,n,t[10],4294925233,17),s,r,t[11],2304563134,22),i=c(i,s=c(s,r=c(r,n,i,s,t[12],1804603682,7),n,i,t[13],4254626195,12),r,n,t[14],2792965006,17),s,r,t[15],1236535329,22),i=u(i,s=u(s,r=u(r,n,i,s,t[1],4129170786,5),n,i,t[6],3225465664,9),r,n,t[11],643717713,14),s,r,t[0],3921069994,20),i=u(i,s=u(s,r=u(r,n,i,s,t[5],3593408605,5),n,i,t[10],38016083,9),r,n,t[15],3634488961,14),s,r,t[4],3889429448,20),i=u(i,s=u(s,r=u(r,n,i,s,t[9],568446438,5),n,i,t[14],3275163606,9),r,n,t[3],4107603335,14),s,r,t[8],1163531501,20),i=u(i,s=u(s,r=u(r,n,i,s,t[13],2850285829,5),n,i,t[2],4243563512,9),r,n,t[7],1735328473,14),s,r,t[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,t[5],4294588738,4),n,i,t[8],2272392833,11),r,n,t[11],1839030562,16),s,r,t[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,t[1],2763975236,4),n,i,t[4],1272893353,11),r,n,t[7],4139469664,16),s,r,t[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,t[13],681279174,4),n,i,t[0],3936430074,11),r,n,t[3],3572445317,16),s,r,t[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,t[9],3654602809,4),n,i,t[12],3873151461,11),r,n,t[15],530742520,16),s,r,t[2],3299628645,23),i=h(i,s=h(s,r=h(r,n,i,s,t[0],4096336452,6),n,i,t[7],1126891415,10),r,n,t[14],2878612391,15),s,r,t[5],4237533241,21),i=h(i,s=h(s,r=h(r,n,i,s,t[12],1700485571,6),n,i,t[3],2399980690,10),r,n,t[10],4293915773,15),s,r,t[1],2240044497,21),i=h(i,s=h(s,r=h(r,n,i,s,t[8],1873313359,6),n,i,t[15],4264355552,10),r,n,t[6],2734768916,15),s,r,t[13],1309151649,21),i=h(i,s=h(s,r=h(r,n,i,s,t[4],4149444226,6),n,i,t[11],3174756917,10),r,n,t[2],718787259,15),s,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0},s.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},e.exports=s},{"hash-base":243,inherits:258,"safe-buffer":321}],263:[function(t,e,r){(function(Buffer){(function(){e.exports=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");for(var r=t.length,n=t.concat();r>1;){for(var i=0,o=0;o=0);return i},o.prototype._randrange=function(t,e){var r=e.sub(t);return t.add(this._randbelow(r))},o.prototype.test=function(t,e,r){var i=t.bitLength(),o=n.mont(t),s=new n(1).toRed(o);e||(e=Math.max(1,i/48|0));for(var a=t.subn(1),c=0;!a.testn(c);c++);for(var u=t.shrn(c),f=a.toRed(o);e>0;e--){var h=this._randrange(new n(2),a);r&&r(h);var l=h.toRed(o).redPow(u);if(0!==l.cmp(s)&&0!==l.cmp(f)){for(var d=1;d0;e--){var f=this._randrange(new n(2),s),h=t.gcd(f);if(0!==h.cmpn(1))return h;var l=f.toRed(i).redPow(c);if(0!==l.cmp(o)&&0!==l.cmp(u)){for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},{}],267:[function(t,e,r){var n=1e3,i=60*n,o=60*i,s=24*o,a=365.25*s;function c(t,e,r){if(!(t0)return function(t){if((t=String(t)).length>100)return;var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(!e)return;var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(t);if("number"===u&&!1===isNaN(t))return e.long?c(r=t,s,"day")||c(r,o,"hour")||c(r,i,"minute")||c(r,n,"second")||r+" ms":function(t){if(t>=s)return Math.round(t/s)+"d";if(t>=o)return Math.round(t/o)+"h";if(t>=i)return Math.round(t/i)+"m";if(t>=n)return Math.round(t/n)+"s";return t+"ms"}(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],268:[function(t,e,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,s,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),c=1;cn)throw new TypeError("Bad key length");var a;s=s||"sha1",Buffer.isBuffer(t)||(t=new Buffer(t,"binary")),Buffer.isBuffer(r)||(r=new Buffer(r,"binary"));var c,u,f=1,h=new Buffer(o),l=new Buffer(r.length+4);r.copy(l,0,0,r.length);for(var d=1;d<=f;d++){l.writeUInt32BE(d,r.length);var p=e(s,t).update(l).digest();a||(a=p.length,u=new Buffer(a),c=o-((f=Math.ceil(o/a))-1)*a),p.copy(u,0,0,a);for(var b=1;b1)for(var r=1;rd||new s(e).cmp(l.modulus)>=0)throw new Error("decryption error");h=r?u(new s(e),l):a(e,l);var p=Buffer.alloc(d-h.length);if(h=Buffer.concat([p,h],d),4===f)return function(t,e){var r=t.modulus.byteLength(),n=c("sha1").update(Buffer.alloc(0)).digest(),s=n.length;if(0!==e[0])throw new Error("decryption error");var a=e.slice(1,s+1),u=e.slice(s+1),f=o(a,i(u,s)),h=o(u,i(f,r-s-1));if(function(t,e){t=Buffer.from(t),e=Buffer.from(e);var r=0,n=t.length;t.length!==e.length&&(r++,n=Math.min(t.length,e.length));var i=-1;for(;++i=e.length){o++;break}var s=e.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;s.length<8&&o++;if(o)throw new Error("decryption error");return e.slice(i)}(0,h,r);if(3===f)return h;throw new Error("unknown padding")}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,"safe-buffer":321}],295:[function(t,e,r){var n=t("parse-asn1"),i=t("randombytes"),o=t("create-hash"),s=t("./mgf"),a=t("./xor"),c=t("bn.js"),u=t("./withPublic"),f=t("browserify-rsa"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e,r){var h;h=t.padding?t.padding:r?1:4;var l,d=n(t);if(4===h)l=function(t,e){var r=t.modulus.byteLength(),n=e.length,u=o("sha1").update(Buffer.alloc(0)).digest(),f=u.length,h=2*f;if(n>r-h-2)throw new Error("message too long");var l=Buffer.alloc(r-n-h-2),d=r-f-1,p=i(f),b=a(Buffer.concat([u,l,Buffer.alloc(1,1),e],d),s(p,d)),y=a(p,s(b,f));return new c(Buffer.concat([Buffer.alloc(1),y,b],r))}(d,e);else if(1===h)l=function(t,e,r){var n,o=e.length,s=t.modulus.byteLength();if(o>s-11)throw new Error("message too long");n=r?Buffer.alloc(s-o-3,255):function(t){var e,r=Buffer.allocUnsafe(t),n=0,o=i(2*t),s=0;for(;n=0)throw new Error("data too long for modulus")}return r?f(l,d):u(l,d)}},{"./mgf":272,"./withPublic":296,"./xor":297,"bn.js":82,"browserify-rsa":287,"create-hash":118,"parse-asn1":293,randombytes:303,"safe-buffer":321}],296:[function(t,e,r){var n=t("bn.js"),Buffer=t("safe-buffer").Buffer;e.exports=function(t,e){return Buffer.from(t.toRed(n.mont(e.modulus)).redPow(new n(e.publicExponent)).fromRed().toArray())}},{"bn.js":82,"safe-buffer":321}],297:[function(t,e,r){e.exports=function(t,e){for(var r=t.length,n=-1;++nt.length)return null;r=t.readUInt8(e+1),i=2}else if(o===n.OP_PUSHDATA2){if(e+3>t.length)return null;r=t.readUInt16LE(e+1),i=3}else{if(e+5>t.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=t.readUInt32LE(e+1),i=5}return{opcode:o,number:r,size:i}}}},{"bitcoin-ops":39}],299:[function(t,e,r){(function(t,n){(function(){!function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof r)e.exports=t();else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()}(function(){"use strict";var e=!1;try{throw new Error}catch(t){e=!!t.stack}var r,i=S(),o=function(){},s=function(){var e={task:void 0,next:null},r=e,i=!1,o=void 0,a=!1;function c(){for(;e.next;){var t=(e=e.next).task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(t){if(a)throw r&&r.exit(),setTimeout(c,0),r&&r.enter(),t;setTimeout(function(){throw t},0)}r&&r.exit()}i=!1}if(s=function(e){r=r.next={task:e,domain:a&&t.domain,next:null},i||(i=!0,o())},void 0!==t&&t.nextTick)a=!0,o=function(){t.nextTick(c)};else if("function"==typeof n)o="undefined"!=typeof window?n.bind(window,c):function(){n(c)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){o=f,u.port1.onmessage=c,c()};var f=function(){u.port2.postMessage(0)};o=function(){setTimeout(c,0),f()}}else o=function(){setTimeout(c,0)};return s}(),a=Function.call;function c(t){return function(){return a.apply(t,arguments)}}var u,f=c(Array.prototype.slice),h=c(Array.prototype.reduce||function(t,e){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){e=this[r++];break}if(++r>=n)throw new TypeError}for(;r=i&&o<=V}function S(){if(e)try{throw new Error}catch(e){var t=e.stack.split("\n"),n=_(t[0].indexOf("@")>0?t[1]:t[2]);if(!n)return;return r=n[0],n[1]}}function k(t){return B(t)?t:R(t)?(e=t,r=A(),s(function(){try{e.then(r.resolve,r.reject,r.notify)}catch(t){r.reject(t)}}),r.promise):H(t);var e,r}function A(){var t,r=[],n=[],i=p(A.prototype),o=p(T.prototype);if(o.promiseDispatch=function(e,i,o){var a=f(arguments);r?(r.push(a),"when"===i&&o[1]&&n.push(o[1])):s(function(){t.promiseDispatch.apply(t,a)})},o.valueOf=function(){if(r)return o;var e=P(t);return B(e)&&(t=e),e},o.inspect=function(){return t?t.inspect():{state:"pending"}},k.longStackSupport&&e)try{throw new Error}catch(t){o.stack=t.stack.substring(t.stack.indexOf("\n")+1)}function a(e){t=e,o.source=e,h(r,function(t,r){s(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,n=void 0}return i.promise=o,i.resolve=function(e){t||a(k(e))},i.fulfill=function(e){t||a(H(e))},i.reject=function(e){t||a(K(e))},i.notify=function(e){t||h(n,function(t,r){s(function(){r(e)})},void 0)},i}function x(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=A();try{t(e.resolve,e.reject,e.notify)}catch(t){e.reject(t)}return e.promise}function M(t){return x(function(e,r){for(var n=0,i=t.length;n2?t.resolve(f(arguments,1)):t.resolve(r)}},k.Promise=x,k.promise=x,x.race=M,x.all=F,x.reject=K,x.resolve=k,k.passByCopy=function(t){return t},T.prototype.passByCopy=function(){return this},k.join=function(t,e){return k(t).join(e)},T.prototype.join=function(t){return k([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},k.race=M,T.prototype.race=function(){return this.then(k.race)},k.makePromise=T,T.prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,e,r){var n=this,i=A(),o=!1;return s(function(){n.promiseDispatch(function(e){o||(o=!0,i.resolve(function(e){try{return"function"==typeof t?t(e):e}catch(t){return K(t)}}(e)))},"when",[function(t){o||(o=!0,i.resolve(function(t){if("function"==typeof e){w(t,n);try{return e(t)}catch(t){return K(t)}}return K(t)}(t)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=function(t){return"function"==typeof r?r(t):t}(t)}catch(t){if(n=!0,!k.onerror)throw t;k.onerror(t)}n||i.notify(e)}]),i.promise},k.when=I,T.prototype.thenResolve=function(t){return this.then(function(){return t})},k.thenResolve=function(t,e){return k(t).thenResolve(e)},T.prototype.thenReject=function(t){return this.then(function(){throw t})},k.thenReject=function(t,e){return k(t).thenReject(e)},k.nearer=P,k.isPromise=B,k.isPromiseAlike=R,k.isPending=function(t){return B(t)&&"pending"===t.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},k.isFulfilled=function(t){return!B(t)||"fulfilled"===t.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},k.isRejected=function(t){return B(t)&&"rejected"===t.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var C,O,L,j=[],N=[],D=!0;function U(){j.length=0,N.length=0,D||(D=!0)}function K(t){var e=T({when:function(e){return e&&function(t){if(D){var e=l(N,t);-1!==e&&(N.splice(e,1),j.splice(e,1))}}(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return function(t,e){D&&(N.push(t),e&&void 0!==e.stack?j.push(e.stack):j.push("(no stack) "+e))}(e,t),e}function H(t){return T({when:function(){return t},get:function(e){return t[e]},set:function(e,r){t[e]=r},delete:function(e){delete t[e]},post:function(e,r){return null===e||void 0===e?t.apply(void 0,r):t[e].apply(t,r)},apply:function(e,r){return t.apply(e,r)},keys:function(){return y(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function q(t,e,r){return k(t).spread(e,r)}function z(t,e,r){return k(t).dispatch(e,r)}function F(t){return I(t,function(t){var e=0,r=A();return h(t,function(n,i,o){var s;B(i)&&"fulfilled"===(s=i.inspect()).state?t[o]=s.value:(++e,I(i,function(n){t[o]=n,0==--e&&r.resolve(t)},r.reject,function(t){r.notify({index:o,value:t})}))},void 0),0===e&&r.resolve(t),r.promise})}function W(t){return I(t,function(t){return t=d(t,k),I(F(d(t,function(t){return I(t,o,o)})),function(){return t})})}k.resetUnhandledRejections=U,k.getUnhandledReasons=function(){return j.slice()},k.stopUnhandledRejectionTracking=function(){U(),D=!1},U(),k.reject=K,k.fulfill=H,k.master=function(t){return T({isDef:function(){}},function(e,r){return z(t,e,r)},function(){return k(t).inspect()})},k.spread=q,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},k.async=function(t){return function(){function e(t,e){var o;if("undefined"==typeof StopIteration){try{o=r[t](e)}catch(t){return K(t)}return o.done?o.value:I(o.value,n,i)}try{o=r[t](e)}catch(t){return function(t){return"[object StopIteration]"===m(t)||t instanceof u}(t)?t.value:K(t)}return I(o,n,i)}var r=t.apply(this,arguments),n=e.bind(e,"next"),i=e.bind(e,"throw");return n()}},k.spawn=function(t){k.done(k.async(t)())},k.return=function(t){throw new u(t)},k.promised=function(t){return function(){return q([this,F(arguments)],function(e,r){return t.apply(e,r)})}},k.dispatch=z,T.prototype.dispatch=function(t,e){var r=this,n=A();return s(function(){r.promiseDispatch(n.resolve,t,e)}),n.promise},k.get=function(t,e){return k(t).dispatch("get",[e])},T.prototype.get=function(t){return this.dispatch("get",[t])},k.set=function(t,e,r){return k(t).dispatch("set",[e,r])},T.prototype.set=function(t,e){return this.dispatch("set",[t,e])},k.del=k.delete=function(t,e){return k(t).dispatch("delete",[e])},T.prototype.del=T.prototype.delete=function(t){return this.dispatch("delete",[t])},k.mapply=k.post=function(t,e,r){return k(t).dispatch("post",[e,r])},T.prototype.mapply=T.prototype.post=function(t,e){return this.dispatch("post",[t,e])},k.send=k.mcall=k.invoke=function(t,e){return k(t).dispatch("post",[e,f(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(t){return this.dispatch("post",[t,f(arguments,1)])},k.fapply=function(t,e){return k(t).dispatch("apply",[void 0,e])},T.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},k.try=k.fcall=function(t){return k(t).dispatch("apply",[void 0,f(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,f(arguments)])},k.fbind=function(t){var e=k(t),r=f(arguments,1);return function(){return e.dispatch("apply",[this,r.concat(f(arguments))])}},T.prototype.fbind=function(){var t=this,e=f(arguments);return function(){return t.dispatch("apply",[this,e.concat(f(arguments))])}},k.keys=function(t){return k(t).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},k.all=F,T.prototype.all=function(){return F(this)},k.allResolved=(C=W,O="allResolved",L="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(O+" is deprecated, use "+L+" instead.",new Error("").stack),C.apply(C,arguments)}),T.prototype.allResolved=function(){return W(this)},k.allSettled=function(t){return k(t).allSettled()},T.prototype.allSettled=function(){return this.then(function(t){return F(d(t,function(t){function e(){return t.inspect()}return(t=k(t)).then(e,e)}))})},k.fail=k.catch=function(t,e){return k(t).then(void 0,e)},T.prototype.fail=T.prototype.catch=function(t){return this.then(void 0,t)},k.progress=function(t,e){return k(t).then(void 0,void 0,e)},T.prototype.progress=function(t){return this.then(void 0,void 0,t)},k.fin=k.finally=function(t,e){return k(t).finally(e)},T.prototype.fin=T.prototype.finally=function(t){return t=k(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},k.done=function(t,e,r,n){return k(t).done(e,r,n)},T.prototype.done=function(e,r,n){var i=function(t){s(function(){if(w(t,o),!k.onerror)throw t;k.onerror(t)})},o=e||r||n?this.then(e,r,n):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),o.then(void 0,i)},k.timeout=function(t,e,r){return k(t).timeout(e,r)},T.prototype.timeout=function(t,e){var r=A(),n=setTimeout(function(){r.reject(new Error(e||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(n),r.resolve(t)},function(t){clearTimeout(n),r.reject(t)},r.notify),r.promise},k.delay=function(t,e){return void 0===e&&(e=t,t=void 0),k(t).delay(e)},T.prototype.delay=function(t){return this.then(function(e){var r=A();return setTimeout(function(){r.resolve(e)},t),r.promise})},k.nfapply=function(t,e){return k(t).nfapply(e)},T.prototype.nfapply=function(t){var e=A(),r=f(t);return r.push(e.makeNodeResolver()),this.fapply(r).fail(e.reject),e.promise},k.nfcall=function(t){var e=f(arguments,1);return k(t).nfapply(e)},T.prototype.nfcall=function(){var t=f(arguments),e=A();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},k.nfbind=k.denodeify=function(t){var e=f(arguments,1);return function(){var r=e.concat(f(arguments)),n=A();return r.push(n.makeNodeResolver()),k(t).fapply(r).fail(n.reject),n.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var t=f(arguments);return t.unshift(this),k.denodeify.apply(void 0,t)},k.nbind=function(t,e){var r=f(arguments,2);return function(){var n=r.concat(f(arguments)),i=A();return n.push(i.makeNodeResolver()),k(function(){return t.apply(e,arguments)}).fapply(n).fail(i.reject),i.promise}},T.prototype.nbind=function(){var t=f(arguments,0);return t.unshift(this),k.nbind.apply(void 0,t)},k.nmapply=k.npost=function(t,e,r){return k(t).npost(e,r)},T.prototype.nmapply=T.prototype.npost=function(t,e){var r=f(e||[]),n=A();return r.push(n.makeNodeResolver()),this.dispatch("post",[t,r]).fail(n.reject),n.promise},k.nsend=k.nmcall=k.ninvoke=function(t,e){var r=f(arguments,2),n=A();return r.push(n.makeNodeResolver()),k(t).dispatch("post",[e,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(t){var e=f(arguments,1),r=A();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},k.nodeify=function(t,e){return k(t).nodeify(e)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){s(function(){t(null,e)})},function(e){s(function(){t(e)})})};var V=S();return k})}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:270,timers:348}],300:[function(t,e,r){"use strict";function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;o&&"number"==typeof o.maxKeys&&(c=o.maxKeys);var u=t.length;c>0&&u>c&&(u=c);for(var f=0;f=0?(h=b.substr(0,y),l=b.substr(y+1)):(h=b,l=""),d=decodeURIComponent(h),p=decodeURIComponent(l),n(s,d)?i(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],301:[function(t,e,r){"use strict";var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),function(s){var a=encodeURIComponent(n(s))+r;return i(t[s])?o(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],n=0;no)throw new RangeError("requested too many random bytes");var n=Buffer.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;au||t<0)throw new TypeError("offset must be a uint32");if(t>a||t>e)throw new RangeError("offset out of range")}function h(t,e,r){if("number"!=typeof t||t!=t)throw new TypeError("size must be a number");if(t>u||t<0)throw new TypeError("size must be a uint32");if(t+e>r||t>a)throw new RangeError("buffer too small")}function l(t,r,n,i){if(e.browser){var o=t.buffer,a=new Uint8Array(o,r,n);return c.getRandomValues(a),i?void e.nextTick(function(){i(null,t)}):t}if(!i)return s(n).copy(t,r),t;s(n,function(e,n){if(e)return i(e);n.copy(t,r),i(null,t)})}c&&c.getRandomValues||!e.browser?(r.randomFill=function(t,e,r,i){if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof e)i=e,e=0,r=t.length;else if("function"==typeof r)i=r,r=t.length-e;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return f(e,t.length),h(r,e,t.length),l(t,e,r,i)},r.randomFillSync=function(t,e,r){void 0===e&&(e=0);if(!(Buffer.isBuffer(t)||t instanceof n.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');f(e,t.length),void 0===r&&(r=t.length-e);return h(r,e,t.length),l(t,e,r)}):(r.randomFill=i,r.randomFillSync=i)}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:270,randombytes:303,"safe-buffer":321}],305:[function(t,e,r){"use strict";var n={};function i(t,e,r){r||(r=Error);var i=function(t){var r,n;function i(r,n,i){return t.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i))||this}return n=t,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=t,n[t]=i}function o(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map(function(t){return String(t)}),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,s,a;if("string"==typeof e&&(i="not ",e.substr(!s||s<0?0:+s,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var c=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(c," ").concat(n," ").concat(o(e,"type"))}return a+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],306:[function(t,e,r){(function(r){(function(){"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=u;var i=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(u,i);for(var s=n(o.prototype),a=0;a0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===Buffer.prototype||(e=function(t){return Buffer.from(t)}(e)),n)s.endEmitted?_(t,new w):x(t,s,e,!0);else if(s.ended)_(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):B(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,B(t,s));return!s.ended&&(s.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=M?t=M:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function I(t){var e=t._readableState;c("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(P,t))}function P(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,j(t)}function B(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(R,t,e))}function R(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function O(t){c("readable nexttick read 0"),t.read(0)}function L(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),j(t),e.flowing&&!e.reading&&t.read(0)}function j(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function N(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(U,e,t))}function U(t,e){if(c("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function K(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):I(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t0?N(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){_(this,new g("_read()"))},k.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,c("pipe count=%d opts=%j",i.pipesCount,e);var s=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?u:y;function a(e,r){c("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),t.removeListener("close",p),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",d),t.removeListener("unpipe",a),n.removeListener("end",u),n.removeListener("end",y),n.removeListener("data",l),h=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function u(){c("onend"),t.end()}i.endEmitted?r.nextTick(s):n.once("end",s),t.on("unpipe",a);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,j(t))}}(n);t.on("drain",f);var h=!1;function l(e){c("ondata");var r=t.write(e);c("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==K(i.pipes,t))&&!h&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function d(e){c("onerror",e),y(),t.removeListener("error",d),0===o(t,"error")&&_(t,e)}function p(){t.removeListener("finish",b),y()}function b(){c("onfinish"),t.removeListener("close",p),y()}function y(){c("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",d),t.once("close",p),t.once("finish",b),t.emit("pipe",n),i.flowing||(c("pipe resume"),n.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,c("on readable",i.length,i.reading),i.length?I(this):i.reading||r.nextTick(O,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(C,this),n},k.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(C,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),!r.objectMode||null!==i&&void 0!==i)&&((r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause())))}),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new p("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!==t&&void 0!==t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,P(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n));e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":305,"./_stream_duplex":306,"./internal/streams/destroy":313,"./internal/streams/state":317,"./internal/streams/stream":318,_process:270,buffer:110,inherits:258,"util-deprecate":356}],311:[function(t,e,r){(function(r){(function(){"use strict";var n;function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),l=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[l].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}var b=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((i(n={get stream(){return this[l]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise(function(e,n){r.nextTick(function(){t[c]?n(t[c]):e(d(void 0,!0))})});var n,i=this[f];if(i)n=new Promise(function(t,e){return function(r,n){t.then(function(){e[u]?r(d(void 0,!0)):e[h](r,n)},n)}}(i,this));else{var o=this[l].read();if(null!==o)return Promise.resolve(d(o,!1));n=new Promise(this[h])}return this[f]=n,n}},Symbol.asyncIterator,function(){return this}),i(n,"return",function(){var t=this;return new Promise(function(e,r){t[l].destroy(null,function(t){t?r(t):e(d(void 0,!0))})})}),n),b);e.exports=function(t){var e,n=Object.create(y,(i(e={},l,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,c,{value:null,writable:!0}),i(e,u,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var r=n[l].read();r?(n[f]=null,n[s]=null,n[a]=null,t(d(r,!1))):(n[s]=t,n[a]=e)},writable:!0}),e));return n[f]=null,o(t,function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[a];return null!==e&&(n[f]=null,n[s]=null,n[a]=null,e(t)),void(n[c]=t)}var r=n[s];null!==r&&(n[f]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[u]=!0}),t.on("readable",function(t){r.nextTick(p,t)}.bind(null,n)),n}}).call(this)}).call(this,t("_process"))},{"./end-of-stream":314,_process:270}],312:[function(t,e,r){"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){for(var r=0;r0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return Buffer.alloc(0);for(var e,r,n,i=Buffer.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,Buffer.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=Buffer.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0===(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:a,value:function(t,e){return s(this,function(t){for(var e=1;e0,function(t){f||(f=t),t&&l.forEach(c),o||(l.forEach(c),h(f))})});return r.reduce(u)}},{"../../../errors":305,"./end-of-stream":314}],317:[function(t,e,r){"use strict";var n=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},{"../../../errors":305}],318:[function(t,e,r){arguments[4][230][0].apply(r,arguments)},{dup:230,events:220}],319:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":306,"./lib/_stream_passthrough.js":307,"./lib/_stream_readable.js":308,"./lib/_stream_transform.js":309,"./lib/_stream_writable.js":310,"./lib/internal/streams/end-of-stream.js":314,"./lib/internal/streams/pipeline.js":316}],320:[function(t,e,r){"use strict";var Buffer=t("buffer").Buffer,n=t("inherits"),i=t("hash-base"),o=new Array(16),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],a=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],c=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],u=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function l(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function p(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function y(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function v(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}n(l,i),l.prototype._update=function(){for(var t=o,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,l=0|this._d,g=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,A=0;A<80;A+=1){var x,M;A<16?(x=p(r,n,i,l,g,t[s[A]],f[0],c[A]),M=v(w,_,E,S,k,t[a[A]],h[0],u[A])):A<32?(x=b(r,n,i,l,g,t[s[A]],f[1],c[A]),M=m(w,_,E,S,k,t[a[A]],h[1],u[A])):A<48?(x=y(r,n,i,l,g,t[s[A]],f[2],c[A]),M=y(w,_,E,S,k,t[a[A]],h[2],u[A])):A<64?(x=m(r,n,i,l,g,t[s[A]],f[3],c[A]),M=b(w,_,E,S,k,t[a[A]],h[3],u[A])):(x=v(r,n,i,l,g,t[s[A]],f[4],c[A]),M=p(w,_,E,S,k,t[a[A]],h[4],u[A])),r=g,g=l,l=d(i,10),i=n,n=x,w=k,k=S,S=d(E,10),E=_,_=M}var T=this._b+i+S|0;this._b=this._c+l+k|0,this._c=this._d+g+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=T},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},e.exports=l},{buffer:110,"hash-base":243,inherits:258}],321:[function(t,e,r){var n=t("buffer"),Buffer=n.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return Buffer(t,e,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,r),r.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return Buffer(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=Buffer(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Buffer(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:110}],322:[function(t,e,r){(function(r){(function(){"use strict";var n,i=t("buffer"),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var s=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(s[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,s.from&&s.from!==Uint8Array.from||(s.from=function(t,e,r){if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof t);if(t&&void 0===t.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);return Buffer(t,e,r)}),s.alloc||(s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError('The "size" argument must be of type number. Received type '+typeof t);if(t<0||t>=2*(1<<30))throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=Buffer(t);return e&&0!==e.length?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=r.binding("buffer").kStringMaxLength}catch(t){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this)}).call(this,t("_process"))},{_process:270,buffer:110}],323:[function(t,e,r){"use strict";e.exports=t("./lib")(t("./lib/elliptic"))},{"./lib":327,"./lib/elliptic":326}],324:[function(t,e,r){(function(Buffer){(function(){"use strict";var t=Object.prototype.toString;r.isArray=function(t,e){if(!Array.isArray(t))throw TypeError(e)},r.isBoolean=function(e,r){if("[object Boolean]"!==t.call(e))throw TypeError(r)},r.isBuffer=function(t,e){if(!Buffer.isBuffer(t))throw TypeError(e)},r.isFunction=function(e,r){if("[object Function]"!==t.call(e))throw TypeError(r)},r.isNumber=function(e,r){if("[object Number]"!==t.call(e))throw TypeError(r)},r.isObject=function(e,r){if("[object Object]"!==t.call(e))throw TypeError(r)},r.isBufferLength=function(t,e,r){if(t.length!==e)throw RangeError(r)},r.isBufferLength2=function(t,e,r,n){if(t.length!==e&&t.length!==r)throw RangeError(n)},r.isLengthGTZero=function(t,e){if(0===t.length)throw RangeError(e)},r.isNumberInInterval=function(t,e,r,n){if(t<=e||t>=r)throw RangeError(n)}}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":259}],325:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("bip66"),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);r.privateKeyExport=function(t,e,r){var n=Buffer.from(r?i:o);return t.copy(n,r?8:9),e.copy(n,r?181:214),n},r.privateKeyImport=function(t){var e=t.length,r=0;if(!(e2||e1?t[r+n-2]<<8:0);if(!(e<(r+=n)+i||e32||e1&&0===e[i]&&!(128&e[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),t.s]),s=33,a=0;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);return n.encode(e.slice(i),o.slice(a))},r.signatureImport=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(t);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(t){return}return i.r.copy(e,32-i.r.length),i.s.copy(r,32-i.s.length),{r:e,s:r}},r.signatureImportLax=function(t){var e=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=t.length,i=0;if(48===t[i++]){var o=t[i++];if(!(128&o&&(i+=o-128)>n)&&2===t[i++]){var s=t[i++];if(128&s){if(i+(o=s-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(s=0;o>0;i+=1,o-=1)s=(s<<8)+t[i]}if(!(s>n-i)){var a=i;if(i+=s,2===t[i++]){var c=t[i++];if(128&c){if(i+(o=c-128)>n)return;for(;o>0&&0===t[i];i+=1,o-=1);for(c=0;o>0;i+=1,o-=1)c=(c<<8)+t[i]}if(!(c>n-i)){var u=i;for(i+=c;s>0&&0===t[a];s-=1,a+=1);if(!(s>32)){var f=t.slice(a,a+s);for(f.copy(e,32-f.length);c>0&&0===t[u];c-=1,u+=1);if(!(c>32)){var h=t.slice(u,u+c);return h.copy(r,32-h.length),{r:e,s:r}}}}}}}}}},{bip66:38,"safe-buffer":321}],326:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=t("create-hash"),i=t("bn.js"),o=t("elliptic").ec,s=t("../messages.json"),a=new o("secp256k1"),c=a.curve;function u(t){var e=t[0];switch(e){case 2:case 3:return 33!==t.length?null:function(t,e){var r=new i(e);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===t!==n.isOdd()&&(n=n.redNeg()),a.keyPair({pub:{x:r,y:n}})}(e,t.slice(1,33));case 4:case 6:case 7:return 65!==t.length?null:function(t,e,r){var n=new i(e),o=new i(r);if(n.cmp(c.p)>=0||o.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),o=o.toRed(c.red),(6===t||7===t)&&o.isOdd()!==(7===t))return null;var s=n.redSqr().redIMul(n);return o.redSqr().redISub(s.redIAdd(c.b)).isZero()?a.keyPair({pub:{x:n,y:o}}):null}(e,t.slice(1,33),t.slice(33,65));default:return null}}r.privateKeyVerify=function(t){var e=new i(t);return e.cmp(c.n)<0&&!e.isZero()},r.privateKeyExport=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.privateKeyNegate=function(t){var e=new i(t);return e.isZero()?Buffer.alloc(32):c.n.sub(e).umod(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyModInverse=function(t){var e=new i(t);if(e.cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PRIVATE_KEY_RANGE_INVALID);return e.invm(c.n).toArrayLike(Buffer,"be",32)},r.privateKeyTweakAdd=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0)throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(t)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},r.privateKeyTweakMul=function(t,e){var r=new i(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(t)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(Buffer,"be",32)},r.publicKeyCreate=function(t,e){var r=new i(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(s.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(a.keyFromPrivate(t).getPublic(e,!0))},r.publicKeyConvert=function(t,e){var r=u(t);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(e,!0))},r.publicKeyVerify=function(t){return null!==u(t)},r.publicKeyTweakAdd=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0)throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=c.g.mul(e).add(n.pub);if(o.isInfinity())throw new Error(s.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},r.publicKeyTweakMul=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);if((e=new i(e)).cmp(c.n)>=0||e.isZero())throw new Error(s.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(e).encode(!0,r))},r.publicKeyCombine=function(t,e){for(var r=new Array(t.length),n=0;n=0||r.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(t);return 1===r.cmp(a.nh)&&c.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},r.signatureExport=function(t){var e=t.slice(0,32),r=t.slice(32,64);if(new i(e).cmp(c.n)>=0||new i(r).cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);return{r:e,s:r}},r.signatureImport=function(t){var e=new i(t.r);e.cmp(c.n)>=0&&(e=new i(0));var r=new i(t.s);return r.cmp(c.n)>=0&&(r=new i(0)),Buffer.concat([e.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},r.sign=function(t,e,r,n){if("function"==typeof r){var o=r;r=function(r){var a=o(t,e,null,n,r);if(!Buffer.isBuffer(a)||32!==a.length)throw new Error(s.ECDSA_SIGN_FAIL);return new i(a)}}var u=new i(e);if(u.cmp(c.n)>=0||u.isZero())throw new Error(s.ECDSA_SIGN_FAIL);var f=a.sign(t,e,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([f.r.toArrayLike(Buffer,"be",32),f.s.toArrayLike(Buffer,"be",32)]),recovery:f.recoveryParam}},r.verify=function(t,e,r){var n={r:e.slice(0,32),s:e.slice(32,64)},o=new i(n.r),f=new i(n.s);if(o.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(a.nh)||o.isZero()||f.isZero())return!1;var h=u(r);if(null===h)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return a.verify(t,n,{x:h.pub.x,y:h.pub.y})},r.recover=function(t,e,r,n){var o={r:e.slice(0,32),s:e.slice(32,64)},u=new i(o.r),f=new i(o.s);if(u.cmp(c.n)>=0||f.cmp(c.n)>=0)throw new Error(s.ECDSA_SIGNATURE_PARSE_FAIL);try{if(u.isZero()||f.isZero())throw new Error;var h=a.recoverPubKey(t,o,r);return Buffer.from(h.encode(!0,n))}catch(t){throw new Error(s.ECDSA_RECOVER_FAIL)}},r.ecdh=function(t,e){var i=r.ecdhUnsafe(t,e,!0);return n("sha256").update(i).digest()},r.ecdhUnsafe=function(t,e,r){var n=u(t);if(null===n)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(e);if(o.cmp(c.n)>=0||o.isZero())throw new Error(s.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},{"../messages.json":328,"bn.js":82,"create-hash":118,elliptic:202,"safe-buffer":321}],327:[function(t,e,r){"use strict";var n=t("./assert"),i=t("./der"),o=t("./messages.json");function s(t,e){return void 0===t?e:(n.isBoolean(t,o.COMPRESSED_TYPE_INVALID),t)}e.exports=function(t){return{privateKeyVerify:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),32===e.length&&t.privateKeyVerify(e)},privateKeyExport:function(e,r){n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=t.privateKeyExport(e,r);return i.privateKeyExport(e,a,r)},privateKeyImport:function(e){if(n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),(e=i.privateKeyImport(e))&&32===e.length&&t.privateKeyVerify(e))return e;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyNegate(e)},privateKeyModInverse:function(e){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),t.privateKeyModInverse(e)},privateKeyTweakAdd:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakAdd(e,r)},privateKeyTweakMul:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),t.privateKeyTweakMul(e,r)},publicKeyCreate:function(e,r){return n.isBuffer(e,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(e,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyCreate(e,r)},publicKeyConvert:function(e,r){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),t.publicKeyConvert(e,r)},publicKeyVerify:function(e){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),t.publicKeyVerify(e)},publicKeyTweakAdd:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakAdd(e,r,i)},publicKeyTweakMul:function(e,r,i){return n.isBuffer(e,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(e,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),t.publicKeyTweakMul(e,r,i)},publicKeyCombine:function(e,r){n.isArray(e,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(e,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},{"safe-buffer":321}],330:[function(t,e,r){(r=e.exports=function(t){t=t.toLowerCase();var e=r[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e}).sha=t("./sha"),r.sha1=t("./sha1"),r.sha224=t("./sha224"),r.sha256=t("./sha256"),r.sha384=t("./sha384"),r.sha512=t("./sha512")},{"./sha":331,"./sha1":332,"./sha224":333,"./sha256":334,"./sha384":335,"./sha512":336}],331:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function u(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=n)<<5|e>>>27)+u(d,i,s,a)+f+r[l]+o[d];f=a,a=s,s=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],332:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function u(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(a,i),a.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),b=c(n)+f(p,i,s,a)+h+r[d]+o[p]|0;h=a,a=s,s=u(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=h+this._e|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],333:[function(t,e,r){var n=t("inherits"),i=t("./sha256"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(64);function a(){this.init(),this._w=s,o.call(this,64,56)}n(a,i),a.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},e.exports=a},{"./hash":329,"./sha256":334,inherits:258,"safe-buffer":321}],334:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function a(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(a,i),a.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},a.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,s=0|this._c,a=0|this._d,d=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=t.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((e=r[m-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[m-7]+l(r[m-15])+r[m-16];for(var v=0;v<64;++v){var g=y+h(d)+c(d,p,b)+o[v]+r[v]|0,w=f(n)+u(n,i,s)|0;y=b,b=p,p=d,d=a+g|0,a=s,s=i,i=n,n=g+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=s+this._c|0,this._d=a+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],335:[function(t,e,r){var n=t("inherits"),i=t("./sha512"),o=t("./hash"),Buffer=t("safe-buffer").Buffer,s=new Array(160);function a(){this.init(),this._w=s,o.call(this,128,112)}n(a,i),a.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},a.prototype._hash=function(){var t=Buffer.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},e.exports=a},{"./hash":329,"./sha512":336,inherits:258,"safe-buffer":321}],336:[function(t,e,r){var n=t("inherits"),i=t("./hash"),Buffer=t("safe-buffer").Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function a(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function u(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function p(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function y(t,e){return t>>>0>>0?1:0}n(a,i),a.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},a.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,s=0|this._dh,a=0|this._eh,m=0|this._fh,v=0|this._gh,g=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,A=0|this._fl,x=0|this._gl,M=0|this._hl,T=0;T<32;T+=2)e[T]=t.readInt32BE(4*T),e[T+1]=t.readInt32BE(4*T+4);for(;T<160;T+=2){var I=e[T-30],P=e[T-30+1],B=l(I,P),R=d(P,I),C=p(I=e[T-4],P=e[T-4+1]),O=b(P,I),L=e[T-14],j=e[T-14+1],N=e[T-32],D=e[T-32+1],U=R+j|0,K=B+L+y(U,R)|0;K=(K=K+C+y(U=U+O|0,O)|0)+N+y(U=U+D|0,D)|0,e[T]=K,e[T+1]=U}for(var H=0;H<160;H+=2){K=e[H],U=e[H+1];var q=u(r,n,i),z=u(w,_,E),F=f(r,w),W=f(w,r),V=h(a,k),G=h(k,a),Y=o[H],J=o[H+1],Z=c(a,m,v),X=c(k,A,x),$=M+G|0,Q=g+V+y($,M)|0;Q=(Q=(Q=Q+Z+y($=$+X|0,X)|0)+Y+y($=$+J|0,J)|0)+K+y($=$+U|0,U)|0;var tt=W+z|0,et=F+q+y(tt,W)|0;g=v,M=x,v=m,x=A,m=a,A=k,a=s+Q+y(k=S+$|0,S)|0,s=i,S=E,i=n,E=_,n=r,_=w,r=Q+et+y(w=$+tt|0,$)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+M|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+s+y(this._dl,S)|0,this._eh=this._eh+a+y(this._el,k)|0,this._fh=this._fh+m+y(this._fl,A)|0,this._gh=this._gh+v+y(this._gl,x)|0,this._hh=this._hh+g+y(this._hl,M)|0},a.prototype._hash=function(){var t=Buffer.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},e.exports=a},{"./hash":329,inherits:258,"safe-buffer":321}],337:[function(t,e,r){"use strict";var n={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function i(t,e,r){if(4!==e.length)throw new n.exception.invalid("invalid aes block size");var i=t.c[r],o=e[0]^i[0],s=e[r?3:1]^i[1],a=e[2]^i[2];e=e[r?1:3]^i[3];var c,u,f,h,l=i.length/4-2,d=4,p=[0,0,0,0];t=(c=t.j[r])[0];var b=c[1],y=c[2],m=c[3],v=c[4];for(h=0;h>>24]^b[s>>16&255]^y[a>>8&255]^m[255&e]^i[d],u=t[s>>>24]^b[a>>16&255]^y[e>>8&255]^m[255&o]^i[d+1],f=t[a>>>24]^b[e>>16&255]^y[o>>8&255]^m[255&s]^i[d+2],e=t[e>>>24]^b[o>>16&255]^y[s>>8&255]^m[255&a]^i[d+3],d+=4,o=c,s=u,a=f;for(h=0;4>h;h++)p[r?3&-h:h]=v[o>>>24]<<24^v[s>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^i[d++],c=o,o=s,s=a,a=e,e=c;return p}n.cipher.aes=function(t){this.j[0][0][0]||this.m();var e,r,i,o,s=this.j[0][4],a=this.j[1],c=1;if(4!==(e=t.length)&&6!==e&&8!==e)throw new n.exception.invalid("invalid aes key size");for(this.c=[i=t.slice(0),o=[]],t=e;t<4*e+28;t++)r=i[t-1],(0==t%e||8===e&&4==t%e)&&(r=s[r>>>24]<<24^s[r>>16&255]<<16^s[r>>8&255]<<8^s[255&r],0==t%e&&(r=r<<8^r>>>24^c<<24,c=c<<1^283*(c>>7))),i[t]=i[t-e]^r;for(e=0;t;e++,t--)r=i[3&e?t:t-4],o[e]=4>=t||4>e?r:a[0][s[r>>>24]]^a[1][s[r>>16&255]]^a[2][s[r>>8&255]]^a[3][s[255&r]]},n.cipher.aes.prototype={encrypt:function(t){return i(this,t,0)},decrypt:function(t){return i(this,t,1)},j:[[[],[],[],[],[]],[[],[],[],[],[]]],m:function(){var t,e,r,n,i,o,s,a=this.j[0],c=this.j[1],u=a[4],f=c[4],h=[],l=[];for(t=0;256>t;t++)l[(h[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(o=(o=r^r<<1^r<<2^r<<3^r<<4)>>8^255&o^99,u[e]=o,f[o]=e,s=16843009*(i=h[t=h[n=h[e]]])^65537*t^257*n^16843008*e,i=257*h[o]^16843008*o,t=0;4>t;t++)a[t][e]=i=i<<24^i>>>8,c[t][o]=s=s<<24^s>>>8;for(t=0;5>t;t++)a[t]=a[t].slice(0),c[t]=c[t].slice(0)}},n.bitArray={bitSlice:function(t,e,r){return t=n.bitArray.v(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:n.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(n.bitArray.bitLength(t)!==n.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r>>e),r=t[o]<<32-e;return o=t.length?t[t.length-1]:0,t=n.bitArray.getPartial(o),i.push(n.bitArray.partial(e+t&31,32>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},n.codec.utf8String={fromBits:function(t){var e,r,i="",o=n.bitArray.bitLength(t);for(e=0;e>>24),r<<=8;return decodeURIComponent(escape(i))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],i=0;for(e=0;en;i++){for(r=!0,e=2;e*e<=i;e++)if(0==i%e){r=!1;break}r&&(8>n&&(this.i[n]=t(Math.pow(i,.5))),this.c[n]=t(Math.pow(i,1/3)),n++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7];for(e=0;64>e;e++)16>e?r=t[e]:(r=t[e+1&15],n=t[e+14&15],r=t[15&e]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+d+(f>>>6^f>>>11^f>>>25^f<<26^f<<21^f<<7)+(l^f&(h^l))+o[e],d=l,l=h,h=f,f=u+r|0,u=c,c=a,s=r+((a=s)&c^u&(a^c))+(a>>>2^a>>>13^a>>>22^a<<30^a<<19^a<<10)|0;i[0]=i[0]+s|0,i[1]=i[1]+a|0,i[2]=i[2]+c|0,i[3]=i[3]+u|0,i[4]=i[4]+f|0,i[5]=i[5]+h|0,i[6]=i[6]+l|0,i[7]=i[7]+d|0}},n.hash.sha512=function(t){this.c[0]||this.m(),t?(this.f=t.f.slice(0),this.b=t.b.slice(0),this.a=t.a):this.reset()},n.hash.sha512.hash=function(t){return(new n.hash.sha512).update(t).finalize()},n.hash.sha512.prototype={blockSize:1024,reset:function(){return this.f=this.i.slice(0),this.b=[],this.a=0,this},update:function(t){"string"==typeof t&&(t=n.codec.utf8String.toBits(t));var e,r=this.b=n.bitArray.concat(this.b,t);if(e=this.a,9007199254740991<(t=this.a=e+n.bitArray.bitLength(t)))throw new n.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(r),o=0;for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(i.subarray(32*o,32*(o+1))),o+=1;r.splice(0,32*o)}else for(e=1024+e-(1024+e&1023);e<=t;e+=1024)this.g(r.splice(0,32));return this},finalize:function(){var t,e=this.b,r=this.f;for(t=(e=n.bitArray.concat(e,[n.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this.a/4294967296)),e.push(0|this.a);e.length;)this.g(e.splice(0,32));return this.reset(),r},i:[],B:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],c:[],C:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],m:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}function e(t){return 1099511627776*(t-Math.floor(t))&255}for(var r,n,i=0,o=2;80>i;o++){for(n=!0,r=2;r*r<=o;r++)if(0==o%r){n=!1;break}n&&(8>i&&(this.i[2*i]=t(Math.pow(o,.5)),this.i[2*i+1]=e(Math.pow(o,.5))<<24|this.B[i]),this.c[2*i]=t(Math.pow(o,1/3)),this.c[2*i+1]=e(Math.pow(o,1/3))<<24|this.C[i],i++)}},g:function(t){var e,r,n,i=this.f,o=this.c,s=i[0],a=i[1],c=i[2],u=i[3],f=i[4],h=i[5],l=i[6],d=i[7],p=i[8],b=i[9],y=i[10],m=i[11],v=i[12],g=i[13],w=i[14],_=i[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var E=0;32>E;E++)n[E]=t[E]}else n=t;E=s;var S=a,k=c,A=u,x=f,M=h,T=l,I=d,P=p,B=b,R=y,C=m,O=v,L=g,j=w,N=_;for(t=0;80>t;t++){if(16>t)e=n[2*t],r=n[2*t+1];else{r=n[2*(t-15)],e=((U=n[2*(t-15)+1])<<31|r>>>1)^(U<<24|r>>>8)^r>>>7;var D=(r<<31|U>>>1)^(r<<24|U>>>8)^(r<<25|U>>>7);r=n[2*(t-2)];var U=((K=n[2*(t-2)+1])<<13|r>>>19)^(r<<3|K>>>29)^r>>>6,K=(r<<13|K>>>19)^(K<<3|r>>>29)^(r<<26|K>>>6),H=n[2*(t-7)],q=n[2*(t-16)],z=n[2*(t-16)+1];e=e+H+((r=D+n[2*(t-7)+1])>>>0>>0?1:0),e+=U+((r+=K)>>>0>>0?1:0),e+=q+((r+=z)>>>0>>0?1:0)}n[2*t]=e|=0,n[2*t+1]=r|=0;H=P&R^~P&O;var F=B&C^~B&L,W=(K=E&k^E&x^k&x,S&A^S&M^A&M),V=(q=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),z=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),o[2*t]),G=o[2*t+1];D=(D=(D=(D=j+((B<<18|P>>>14)^(B<<14|P>>>18)^(P<<23|B>>>9))+((U=N+((P<<18|B>>>14)^(P<<14|B>>>18)^(B<<23|P>>>9)))>>>0>>0?1:0))+(H+((U=U+F)>>>0>>0?1:0)))+(V+((U=U+G)>>>0>>0?1:0)))+(e+((U=U+r|0)>>>0>>0?1:0));e=q+K+((r=z+W)>>>0>>0?1:0),j=O,N=L,O=R,L=C,R=P,C=B,P=T+D+((B=I+U|0)>>>0>>0?1:0)|0,T=x,I=M,x=k,M=A,k=E,A=S,E=D+e+((S=U+r|0)>>>0>>0?1:0)|0}a=i[1]=a+S|0,i[0]=s+E+(a>>>0>>0?1:0)|0,u=i[3]=u+A|0,i[2]=c+k+(u>>>0>>0?1:0)|0,h=i[5]=h+M|0,i[4]=f+x+(h>>>0>>0?1:0)|0,d=i[7]=d+I|0,i[6]=l+T+(d>>>0>>0?1:0)|0,b=i[9]=b+B|0,i[8]=p+P+(b>>>0>>0?1:0)|0,m=i[11]=m+C|0,i[10]=y+R+(m>>>0>>0?1:0)|0,g=i[13]=g+L|0,i[12]=v+O+(g>>>0>>0?1:0)|0,_=i[15]=_+N|0,i[14]=w+j+(_>>>0>>0?1:0)|0}},n.mode.gcm={name:"gcm",encrypt:function(t,e,r,i,o){var s=e.slice(0);return e=n.bitArray,i=i||[],t=n.mode.gcm.s(!0,t,s,i,r,o||128),e.concat(t.data,t.tag)},decrypt:function(t,e,r,i,o){var s=e.slice(0),a=n.bitArray,c=a.bitLength(s);if(o=o||128,i=i||[],o<=c?(e=a.bitSlice(s,c-o),s=a.bitSlice(s,0,c-o)):(e=s,s=[]),t=n.mode.gcm.s(!1,t,s,i,r,o),!a.equal(t.tag,e))throw new n.exception.corrupt("gcm: tag doesn't match");return t.data},A:function(t,e){var r,i,o,s,a,c=n.bitArray.D;for(o=[0,0,0,0],s=e.slice(0),r=0;128>r;r++){for((i=0!=(t[Math.floor(r/32)]&1<<31-r%32))&&(o=c(o,s)),a=0!=(1&s[3]),i=3;0>>1|(1&s[i-1])<<31;s[0]>>>=1,a&&(s[0]^=-520093696)}return o},h:function(t,e,r){var i,o=r.length;for(e=e.slice(0),i=0;io&&(t=e.hash(t)),r=0;ri||0>r)throw new n.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=n.codec.utf8String.toBits(t)),"string"==typeof e&&(e=n.codec.utf8String.toBits(e)),t=new(o=o||n.misc.hmac)(t);var s,a,c,u,f=[],h=n.bitArray;for(u=1;32*f.length<(i||1);u++){for(o=s=t.encrypt(h.concat(e,[u])),a=1;a=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||f.serialize[i?i.split(";")[0]:""];!o&&b(i)&&(o=f.serialize["application/json"]),o&&(r=o(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},f.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){c.prototype[t.toLowerCase()]=function(e,r){var n=new f.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),c.prototype.del=c.prototype.delete,f.get=function(t,e,r){var n=f("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.head=function(t,e,r){var n=f("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},f.options=function(t,e,r){var n=f("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.del=v,f.delete=v,f.patch=function(t,e,r){var n=f("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.post=function(t,e,r){var n=f("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},f.put=function(t,e,r){var n=f("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},{"./agent-base":342,"./is-object":344,"./request-base":345,"./response-base":346,"component-emitter":115}],344:[function(t,e,r){"use strict";e.exports=function(t){return null!==t&&"object"==typeof t}},{}],345:[function(t,e,r){"use strict";var n=t("./is-object");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},i.prototype.parse=function(t){return this._parser=t,this},i.prototype.responseType=function(t){return this._responseType=t,this},i.prototype.serialize=function(t){return this._serializer=t,this},i.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},i.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var o=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];i.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~o.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},i.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},i.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},i.prototype.catch=function(t){return this.then(void 0,t)},i.prototype.use=function(t){return t(this),this},i.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},i.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},i.prototype.get=function(t){return this._header[t.toLowerCase()]},i.prototype.getHeader=i.prototype.get,i.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},i.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},i.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var i in e)this.field(t,e[i]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},i.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},i.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},i.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},i.prototype.redirects=function(t){return this._maxRedirects=t,this},i.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},i.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},i.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var i in t)this._data[i]=t[i];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},i.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},i.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},i.prototype._appendQueryString=function(){console.trace("Unsupported")},i.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},i.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":344}],346:[function(t,e,r){"use strict";var n=t("./utils");function i(t){if(t)return function(t){for(var e in i.prototype)t[e]=i.prototype[e];return t}(t)}e.exports=i,i.prototype.get=function(t){return this.header[t.toLowerCase()]},i.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var i in r)this[i]=r[i];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},i.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},{"./utils":347}],347:[function(t,e,r){"use strict";r.type=function(t){return t.split(/ *; */).shift()},r.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{})},r.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},r.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},{}],348:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,o=Function.prototype.apply,s=Array.prototype.slice,a={},c=0;function u(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new u(o.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new u(o.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},u.prototype.unref=u.prototype.ref=function(){},u.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=c++,n=!(arguments.length<2)&&s.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":270,timers:348}],349:[function(t,e,r){var n=t("./native");function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function c(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function u(t,e,r){r=r||o(e),this.message=c(t,e,r),s(this,u),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),c('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,u),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,f.prototype=Object.create(Error.prototype),f.prototype.constructor=u,e.exports={TfTypeError:u,TfPropertyTypeError:f,tfCustomError:function(t,e){return new u(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof u&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},{"./native":352}],350:[function(t,e,r){(function(Buffer){(function(){var r=t("./native"),n=t("./errors");function i(t){return Buffer.isBuffer(t)}function o(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function s(t,e){var r=t.toJSON();function i(i){if(!t(i))return!1;if(i.length===e)return!0;throw n.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var a=s.bind(null,r.Array),c=s.bind(null,i),u=s.bind(null,o),f=s.bind(null,r.String);var h=Math.pow(2,53)-1;var l={ArrayN:a,Buffer:i,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:o,HexN:u,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-h&&t<=h&&Math.floor(t)===t},Range:function(t,e,n){function i(r,i){return n(r,i)&&r>t&&r>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=h&&Math.floor(t)===t}};for(var d in l)l[d].toJSON=function(t){return t}.bind(null,d);e.exports=l}).call(this)}).call(this,{isBuffer:t("../is-buffer/index.js")})},{"../is-buffer/index.js":259,"./errors":349,"./native":352}],351:[function(t,e,r){var n=t("./errors"),i=t("./native"),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,c=n.tfSubError,u=n.getValueTypeName,f={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&(!i.Nil(r)&&(!(void 0!==e.minLength&&r.lengthe.maxLength)&&((void 0===e.length||r.length===e.length)&&r.every(function(e,r){try{return l(t,e,n)}catch(t){throw c(t,r)}})))))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&l(e,o,n)}catch(t){throw c(t,o,"key")}try{var s=r[o];l(t,s,n)}catch(t){throw c(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e){l(e[n],t[n],r)}}catch(t){throw c(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every(function(t){try{return l(t,e,r)}catch(t){return!1}})}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===u(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&(!i.Nil(e.length)&&((!r||e.length===t.length)&&t.every(function(t,n){try{return l(t,e[n],r)}catch(t){throw c(t,n)}})))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function l(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return l(h(t),e,r)}for(var d in f.oneOf=f.anyOf,i)l[d]=i[d];for(d in f)l[d]=f[d];var p=t("./extra");for(d in p)l[d]=p[d];l.compile=h,l.TfTypeError=s,l.TfPropertyTypeError=a,e.exports=l},{"./errors":349,"./extra":350,"./native":352}],352:[function(t,e,r){var n={Array:function(t){return null!==t&&void 0!==t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return void 0===t||null===t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var i in n.Null=n.Nil,n)n[i].toJSON=function(t){return t}.bind(null,i);e.exports=n},{}],353:[function(t,e,r){!function(t){"use strict";for(var r=[null,0,{}],n=10,i=44032,o=4352,s=4449,a=4519,c=19,u=21,f=28,h=u*f,l=c*h,d=function(t,e){this.codepoint=t,this.feature=e},p={},b=[],y=0;y<=255;++y)b[y]=0;var m=[function(t,e,n){return e<60||13311>8&255]>n&&(p[e]=i),i},function(t,e,r){return r?t(e,r):new d(e,null)},function(t,e,r){var n;if(e=55296&&t<=56319},d.isLowSurrogate=function(t){return t>=56320&&t<=57343},d.prototype.prepFeature=function(){this.feature||(this.feature=d.fromCharCode(this.codepoint,!0).feature)},d.prototype.toString=function(){if(this.codepoint<65536)return String.fromCharCode(this.codepoint);var t=this.codepoint-65536;return String.fromCharCode(Math.floor(t/1024)+55296,t%1024+56320)},d.prototype.getDecomp=function(){return this.prepFeature(),this.feature[0]||null},d.prototype.isCompatibility=function(){return this.prepFeature(),!!this.feature[1]&&256&this.feature[1]},d.prototype.isExclude=function(){return this.prepFeature(),!!this.feature[1]&&512&this.feature[1]},d.prototype.getCanonicalClass=function(){return this.prepFeature(),this.feature[1]?255&this.feature[1]:0},d.prototype.getComposite=function(t){if(this.prepFeature(),!this.feature[2])return null;var e=this.feature[2][t.codepoint];return e?d.fromCharCode(e):null};var v=function(t){this.str=t,this.cursor=0};v.prototype.next=function(){if(this.str&&this.cursor0;--r){if(this.resBuf[r-1].getCanonicalClass()<=t)break}this.resBuf.splice(r,0,e)}while(0!==t);return this.resBuf.shift()};var _=function(t){this.it=t,this.procBuf=[],this.resBuf=[],this.lastClass=null};_.prototype.next=function(){for(;0===this.resBuf.length;){var t=this.it.next();if(!t){this.resBuf=this.procBuf,this.procBuf=[];break}if(0===this.procBuf.length)this.lastClass=t.getCanonicalClass(),this.procBuf.push(t);else{var e=this.procBuf[0].getComposite(t),r=t.getCanonicalClass();e&&(this.lastClass",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),h=["%","/","?",";","#"].concat(f),l=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function g(t,e,r){if(t&&i.isObject(t)&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}o.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o127?C+="x":C+=R[O];if(!C.match(d)){var j=P.slice(0,M),N=P.slice(M+1),D=R.match(p);D&&(j.push(D[1]),N.unshift(D[2])),N.length&&(g="/"+N.join(".")+g),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var U=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+U,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==g[0]&&(g="/"+g))}if(!b[E])for(M=0,B=f.length;M0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift());return r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=S.slice(-1)[0],x=(r.host||t.host||S.length>1)&&("."===A||".."===A)||""===A,M=0,T=S.length;T>=0;T--)"."===(A=S[T])?S.splice(T,1):".."===A?(S.splice(T,1),M++):M&&(S.splice(T,1),M--);if(!_&&!E)for(;M--;M)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),x&&"/"!==S.join("/").substr(-1)&&S.push("");var I,P=""===S[0]||S[0]&&"/"===S[0].charAt(0);k&&(r.hostname=r.host=P?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift()));return(_=_||r.host&&S.length)&&!P&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":355,punycode:221,querystring:302}],355:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],356:[function(t,e,r){(function(t){(function(){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],357:[function(t,e,r){"use strict";var Buffer=t("safe-buffer").Buffer,n=9007199254740991;function i(t){if(t<0||t>n||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.exports={encode:function t(e,r,n){if(i(e),r||(r=Buffer.allocUnsafe(o(e))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),e<253?(r.writeUInt8(e,n),t.bytes=1):e<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(e,n+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(e,n+1),t.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(e>>>0,n+1),r.writeUInt32LE(e/4294967296|0,n+5),t.bytes=9),r},decode:function t(e,r){if(!Buffer.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=e.readUInt8(r);if(n<253)return t.bytes=1,n;if(253===n)return t.bytes=3,e.readUInt16LE(r+1);if(254===n)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var o=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+o;return i(s),s},encodingLength:o}},{"safe-buffer":321}],358:[function(t,e,r){var n=arguments[3],i=arguments[4],o=arguments[5],s=JSON.stringify;e.exports=function(t,e){for(var r,a=Object.keys(o),c=0,u=a.length;c 300) { + if (utxoArray.length > maxInputLength) { // max inputs length, otherwise the tx-size will over 100KB - chunk = 300; + // default: 300 + chunk = maxInputLength; } else { chunk = utxoArray.length; } @@ -784,7 +785,7 @@ WalletSweeper.prototype.createTransactionList = function(destinationAddress, fee } rawTransactionList.push(this.signTransaction(rawTransaction, temp)); } - console.log("rawTransactionList:",rawTransactionList); + console.log("raw transaction list:",rawTransactionList); return rawTransactionList; };